Skip to content

Commit

Permalink
pep8
Browse files Browse the repository at this point in the history
  • Loading branch information
henryborchers committed Oct 9, 2023
1 parent 4acc997 commit 64ef821
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 28 deletions.
8 changes: 8 additions & 0 deletions uiucprescon/build/__init__.py
Original file line number Diff line number Diff line change
@@ -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'
]
16 changes: 10 additions & 6 deletions uiucprescon/build/compiler_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand Down Expand Up @@ -160,4 +165,3 @@ def get_compiler_version():
if len(parsed_version) <= 2:
return full_version
return f"{parsed_version[0]}.{parsed_version[1]}"

36 changes: 25 additions & 11 deletions uiucprescon/build/conan_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
37 changes: 29 additions & 8 deletions uiucprescon/build/local_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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')

Expand Down
16 changes: 13 additions & 3 deletions uiucprescon/build/pybind11_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 64ef821

Please sign in to comment.