From 64ef8212622467d9d8ad23908949035960bf1038 Mon Sep 17 00:00:00 2001 From: henry Date: Mon, 9 Oct 2023 13:14:13 -0500 Subject: [PATCH] pep8 --- uiucprescon/build/__init__.py | 8 ++++++ uiucprescon/build/compiler_info.py | 16 +++++++----- uiucprescon/build/conan_libs.py | 36 ++++++++++++++++++-------- uiucprescon/build/local_backend.py | 37 +++++++++++++++++++++------ uiucprescon/build/pybind11_builder.py | 16 +++++++++--- 5 files changed, 85 insertions(+), 28 deletions(-) diff --git a/uiucprescon/build/__init__.py b/uiucprescon/build/__init__.py index 1e9b815..b59cd32 100644 --- a/uiucprescon/build/__init__.py +++ b/uiucprescon/build/__init__.py @@ -1,3 +1,11 @@ from .local_backend import build_sdist, \ build_wheel, prepare_metadata_for_build_wheel, get_requires_for_build_sdist + VERSION = "0.1.3.dev0" + +__all__ = [ + 'build_sdist', + 'build_wheel', + 'prepare_metadata_for_build_wheel', + 'get_requires_for_build_sdist' +] diff --git a/uiucprescon/build/compiler_info.py b/uiucprescon/build/compiler_info.py index 8ad70a3..8b60052 100644 --- a/uiucprescon/build/compiler_info.py +++ b/uiucprescon/build/compiler_info.py @@ -48,8 +48,12 @@ def get_visual_studio_version(): for v in possible_versions: try: - winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, key % v, 0, - winreg.KEY_ALL_ACCESS) + winreg.OpenKey( + winreg.HKEY_LOCAL_MACHINE, + key % v, + 0, + winreg.KEY_ALL_ACCESS + ) installed_versions.append(v) except Exception as e: pass @@ -76,10 +80,11 @@ def get_clang_version(): # This ensures extension modules are built with correct # compatibility values, specifically LDSHARED which can use # '-undefined dynamic_lookup' which only works on >= 10.3. - cur_target = os.environ.get('MACOSX_DEPLOYMENT_TARGET', _cfg_target) + cur_target =\ + os.environ.get('MACOSX_DEPLOYMENT_TARGET', _cfg_target) + cur_target_split = [int(x) for x in cur_target.split('.')] - if _cfg_target_split[:2] >= [10, 3] and cur_target_split[:2] < [10, - 3]: + if _cfg_target_split[:2] >= [10, 3] > cur_target_split[:2]: my_msg = ('$MACOSX_DEPLOYMENT_TARGET mismatch: ' 'now "%s" but "%s" during configure;' 'must use 10.3 or later' @@ -160,4 +165,3 @@ def get_compiler_version(): if len(parsed_version) <= 2: return full_version return f"{parsed_version[0]}.{parsed_version[1]}" - diff --git a/uiucprescon/build/conan_libs.py b/uiucprescon/build/conan_libs.py index 7503c40..c4c760a 100644 --- a/uiucprescon/build/conan_libs.py +++ b/uiucprescon/build/conan_libs.py @@ -11,12 +11,16 @@ from distutils import ccompiler from pathlib import Path from uiucprescon.build.deps import get_win_deps -from uiucprescon.build.compiler_info import get_compiler_version, get_compiler_name +from uiucprescon.build.compiler_info import ( + get_compiler_version, + get_compiler_name +) import json from distutils.dist import Distribution import toml from conans.client import conan_api, conf + class ConanBuildInfoParser: def __init__(self, fp): self._fp = fp @@ -76,21 +80,31 @@ def parse(self, filename: str) -> Dict[str, Union[str, List[str]]]: "bindirs": data.get(f"bindirs_{library_name}", []), "resdirs": data.get(f"resdirs_{library_name}", []), "builddirs": data.get(f"builddirs_{library_name}", []), - "system_libs": data.get(f"system_libs_{library_name}", []), - "defines": data.get(f"defines_{library_name}", []), - "cppflags": data.get(f"cppflags_{library_name}", []), - "cxxflags": data.get(f"cxxflags_{library_name}", []), + "system_libs": + data.get(f"system_libs_{library_name}", []), + "defines": + data.get(f"defines_{library_name}", []), + "cppflags": + data.get(f"cppflags_{library_name}", []), + "cxxflags": + data.get(f"cxxflags_{library_name}", []), "cflags": data.get(f"cflags_{library_name}", []), - "sharedlinkflags": data.get(f"sharedlinkflags_{library_name}", []), - "exelinkflags": data.get(f"exelinkflags_{library_name}", []), + "sharedlinkflags": + data.get(f"sharedlinkflags_{library_name}", []), + "exelinkflags": + data.get(f"exelinkflags_{library_name}", []), "sysroot": data.get(f"sysroot_{library_name}", []), - "frameworks": data.get(f"frameworks_{library_name}", []), - "frameworkdirs": data.get(f"frameworkdirs_{library_name}", []), + "frameworks": + data.get(f"frameworks_{library_name}", []), + "frameworkdirs": + data.get(f"frameworkdirs_{library_name}", []), "rootpath": data.get(f"rootpath_{library_name}", []), "name": library_name, "version": version[0] if version else None, - "generatornames": data.get(f"generatornames_{library_name}", []), - "generatorfilenames": data.get(f"generatorfilenames_{library_name}", []), + "generatornames": + data.get(f"generatornames_{library_name}", []), + "generatorfilenames": + data.get(f"generatorfilenames_{library_name}", []), } return { "definitions": definitions, diff --git a/uiucprescon/build/local_backend.py b/uiucprescon/build/local_backend.py index a82a495..a2f1c43 100644 --- a/uiucprescon/build/local_backend.py +++ b/uiucprescon/build/local_backend.py @@ -3,6 +3,7 @@ import setuptools.build_meta from . import conan_libs from pathlib import Path + print("pre pyproject.toml") pyproj_toml = Path('pyproject.toml') print("post pyproject.toml") @@ -13,10 +14,20 @@ def build_sdist(sdist_directory, config_settings=None): return setuptools.build_meta.build_sdist(sdist_directory, config_settings) -def build_wheel(wheel_directory, config_settings=None, metadata_directory=None): - if config_settings is not None and config_settings.get('conan_cache') is not None: - if "CONAN_USER_HOME" in os.environ: - config_settings['conan_cache'] = os.path.join(os.environ["CONAN_USER_HOME"], ".conan") +def build_wheel( + wheel_directory, + config_settings=None, + metadata_directory=None +): + if ( + config_settings is not None and + config_settings.get('conan_cache') is not None and + "CONAN_USER_HOME" in os.environ + ): + config_settings['conan_cache'] = os.path.join( + os.environ["CONAN_USER_HOME"], + ".conan" + ) conan_libs.build_conan( wheel_directory, @@ -28,8 +39,16 @@ def build_wheel(wheel_directory, config_settings=None, metadata_directory=None): try: if config_settings is not None and "conan_cache" in config_settings: - os.environ["CONAN_USER_HOME"] = os.path.normpath(os.path.join(config_settings['conan_cache'], "..")) - return setuptools.build_meta.build_wheel(wheel_directory, config_settings, metadata_directory) + os.environ["CONAN_USER_HOME"] = os.path.normpath( + os.path.join(config_settings['conan_cache'], "..") + ) + + return setuptools.build_meta.build_wheel( + wheel_directory, + config_settings, + metadata_directory + ) + finally: if original_conan_user_home: os.environ["CONAN_USER_HOME"] = original_conan_user_home @@ -48,11 +67,13 @@ def get_requires_for_build_sdist(config_settings=None): print("get_requires_for_build_sdist - Done") - def prepare_metadata_for_build_wheel(metadata_directory, config_settings=None): print('prepare_metadata_for_build_wheel') try: - return setuptools.build_meta.prepare_metadata_for_build_wheel(metadata_directory, config_settings) + return setuptools.build_meta.prepare_metadata_for_build_wheel( + metadata_directory, + config_settings + ) finally: print('prepare_metadata_for_build_wheel done') diff --git a/uiucprescon/build/pybind11_builder.py b/uiucprescon/build/pybind11_builder.py index 86cd768..b61eb49 100644 --- a/uiucprescon/build/pybind11_builder.py +++ b/uiucprescon/build/pybind11_builder.py @@ -51,7 +51,10 @@ def find_missing_libraries(self, ext, strategies=None): conan_info_dir = os.environ.get('CONAN_BUILD_INFO_DIR') if conan_info_dir: conanfileinfo_locations.insert(0, conan_info_dir) - conanbuildinfo = conan_libs.locate_conanbuildinfo(conanfileinfo_locations) + + conanbuildinfo =\ + conan_libs.locate_conanbuildinfo(conanfileinfo_locations) + if conanbuildinfo: strategies.insert( 0, @@ -108,8 +111,15 @@ def _add_conan_libs_to_ext(self, ext: Pybind11Extension): else: ext.runtime_library_dirs.append(os.path.abspath(lib_output)) ext.library_dirs.insert(0, os.path.abspath(lib_output)) - ext.library_dirs = list(parse_conan_build_info(conan_build_info, "libdirs")) + ext.library_dirs - ext.include_dirs = list(parse_conan_build_info(conan_build_info, "includedirs")) + ext.include_dirs + + ext.library_dirs = list( + parse_conan_build_info(conan_build_info, "libdirs") + ) + ext.library_dirs + + ext.include_dirs = list( + parse_conan_build_info(conan_build_info, "includedirs") + ) + ext.include_dirs + defines = parse_conan_build_info(conan_build_info, "defines") ext.define_macros = [(d, None) for d in defines] + ext.define_macros