From d0d5b835a99515894f01045ca05bfb183798791b Mon Sep 17 00:00:00 2001 From: LittleStar <59785146+LinZhihao-723@users.noreply.github.com> Date: Sat, 11 Nov 2023 18:39:33 -0500 Subject: [PATCH 1/3] Update setup tools --- setup.py | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/setup.py b/setup.py index 4583d991..f5fc66c0 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import sys import toml from setuptools import setup, Extension -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional ir_native: Extension = Extension( name="clp_ffi_py.ir.native", @@ -55,13 +55,29 @@ if None is version: sys.exit("Error: The version number was not found in pyproject.toml") - setup( - name="clp_ffi_py", - description="CLP FFI Python Interface", - ext_modules=[ir_native], - packages=["clp_ffi_py"], - version=version, - ) + if (3, 7) > sys.version_info: + # For Python3.6, we need to explicitly specify the packages and the + # package data. Submodules and .pyi/.type files are not + # automatically included. + packages: List[str] = ["clp_ffi_py", "clp_ffi_py.ir"] + data_to_include: List[str] = ["*.py", "*.pyi", "*.typed"] + package_data: Dict[str, List[str]] = {package: data_to_include for package in packages} + setup( + name="clp_ffi_py", + description="CLP FFI Python Interface", + ext_modules=[ir_native], + packages=packages, + package_data=package_data, + version=version, + ) + else: + setup( + name="clp_ffi_py", + description="CLP FFI Python Interface", + ext_modules=[ir_native], + packages=["clp_ffi_py"], + version=version, + ) except Exception as e: sys.exit(f"Error: {e}") From 13e1015795bbfb9197de650a39ad227750bdaba4 Mon Sep 17 00:00:00 2001 From: LittleStar <59785146+LinZhihao-723@users.noreply.github.com> Date: Sat, 11 Nov 2023 20:21:23 -0500 Subject: [PATCH 2/3] Adapt code review comments --- setup.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/setup.py b/setup.py index f5fc66c0..3fd80d6f 100644 --- a/setup.py +++ b/setup.py @@ -55,26 +55,29 @@ if None is version: sys.exit("Error: The version number was not found in pyproject.toml") + project_name: str = "clp_ffi_py" + description: str = "CLP FFI Python Interface" + extension_modules: List[Exception] = [ir_native] if (3, 7) > sys.version_info: - # For Python3.6, we need to explicitly specify the packages and the - # package data. Submodules and .pyi/.type files are not - # automatically included. + # For Python3.6, setuptools doesn't automatically include submodules + # and .pyi/.type files, so we need to explicitly specify the + # packages and the files to include per package (package_data). packages: List[str] = ["clp_ffi_py", "clp_ffi_py.ir"] data_to_include: List[str] = ["*.py", "*.pyi", "*.typed"] package_data: Dict[str, List[str]] = {package: data_to_include for package in packages} setup( - name="clp_ffi_py", - description="CLP FFI Python Interface", - ext_modules=[ir_native], + name=project_name, + description=description, + ext_modules=extension_modules, packages=packages, package_data=package_data, version=version, ) else: setup( - name="clp_ffi_py", - description="CLP FFI Python Interface", - ext_modules=[ir_native], + name=project_name, + description=description, + ext_modules=extension_modules, packages=["clp_ffi_py"], version=version, ) From 9a32ce3502f71ab9b46404d30e7717755a024c0d Mon Sep 17 00:00:00 2001 From: LittleStar <59785146+LinZhihao-723@users.noreply.github.com> Date: Sat, 11 Nov 2023 20:27:01 -0500 Subject: [PATCH 3/3] CSC101: Do Not Trust Your IDE --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 3fd80d6f..38b6c9a6 100644 --- a/setup.py +++ b/setup.py @@ -57,7 +57,7 @@ project_name: str = "clp_ffi_py" description: str = "CLP FFI Python Interface" - extension_modules: List[Exception] = [ir_native] + extension_modules: List[Extension] = [ir_native] if (3, 7) > sys.version_info: # For Python3.6, setuptools doesn't automatically include submodules # and .pyi/.type files, so we need to explicitly specify the