Skip to content

Commit

Permalink
fix readability and style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
opadron committed Jul 21, 2016
1 parent e551643 commit 82cb708
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 62 deletions.
102 changes: 46 additions & 56 deletions skbuild/cmaker.py
Expand Up @@ -110,37 +110,23 @@ def configure(self, clargs=(), generator_id=None):
python_library = CMaker.get_python_library(python_version)

cwd = os.getcwd()
cmd = ['cmake', cwd, '-G', generator_id]
cmd.extend(
"=".join((cmake_variable, value)) for cmake_variable, value in (
(
"-DCMAKE_INSTALL_PREFIX:PATH",
os.path.join(cwd, CMAKE_INSTALL_DIR)
), (
"-DPYTHON_EXECUTABLE:FILEPATH",
sys.executable
), (
"-DPYTHON_VERSION_STRING:STRING",
sys.version.split(' ')[0]
), (
"-DPYTHON_INCLUDE_DIR:PATH",
python_include_dir
), (
"-DPYTHON_LIBRARY:FILEPATH",
python_library
), (
"-DSKBUILD:BOOL",
"TRUE"
), (
"-DCMAKE_MODULE_PATH:PATH",
os.path.join(
os.path.dirname(__file__),
"resources",
"cmake"
)
)
)
)
cmd = [
'cmake', cwd, '-G', generator_id,
("-DCMAKE_INSTALL_PREFIX:PATH=" +
os.path.join(cwd, CMAKE_INSTALL_DIR)),
("-DPYTHON_EXECUTABLE:FILEPATH=" +
sys.executable),
("-DPYTHON_VERSION_STRING:STRING=" +
sys.version.split(' ')[0]),
("-DPYTHON_INCLUDE_DIR:PATH=" +
python_include_dir),
("-DPYTHON_LIBRARY:FILEPATH=" +
python_library),
("-DSKBUILD:BOOL=" +
"TRUE"),
("-DCMAKE_MODULE_PATH:PATH=" +
os.path.join(os.path.dirname(__file__), "resources", "cmake"))
]

cmd.extend(clargs)

Expand Down Expand Up @@ -191,43 +177,46 @@ def get_python_include_dir(python_version):
# NOTE(opadron): these possible prefixes must be guarded against
# AttributeErrors and KeyErrors because they each can throw on
# different platforms or even different builds on the same platform.
try:
candidate_prefixes.append(
os.path.dirname(sysconfig.get_config_var('INCLUDEPY')))
except (AttributeError, KeyError):
pass
include_py = sysconfig.get_config_var('INCLUDEPY')
include_dir = sysconfig.get_config_var('INCLUDEDIR')
include = None
plat_include = None
python_inc = None
python_inc2 = None

try:
candidate_prefixes.append(
sysconfig.get_config_var('INCLUDEDIR'))
include = sysconfig.get_path('include')
except (AttributeError, KeyError):
pass

try:
candidate_prefixes.append(
os.path.dirname(sysconfig.get_path('include')))
plat_include = sysconfig.get_path('platinclude')
except (AttributeError, KeyError):
pass

try:
candidate_prefixes.append(
os.path.dirname(sysconfig.get_path('platinclude')))
except (AttributeError, KeyError):
python_inc = sysconfig.get_python_inc()
except AttributeError:
pass

try:
candidate_prefixes.append(
os.path.join(sysconfig.get_python_inc(),
".".join(map(str, sys.version_info[:2]))))
except (AttributeError, KeyError):
pass

try:
candidate_prefixes.append(sysconfig.get_python_inc())
except (AttributeError, KeyError):
pass

candidate_prefixes = tuple(filter(bool, candidate_prefixes))
if include_py is not None:
include_py = os.path.dirname(include_py)
if include is not None:
include = os.path.dirname(include)
if plat_include is not None:
plat_include = os.path.dirname(plat_include)
if python_inc is not None:
python_inc2 = os.path.join(
python_inc, ".".join(map(str, sys.version_info[:2])))

candidate_prefixes = list(filter(bool, (
include_py,
include_dir,
include,
plat_include,
python_inc,
python_inc2,
)))

candidate_versions = (python_version,)
if python_version:
Expand All @@ -248,6 +237,7 @@ def get_python_include_dir(python_version):
break

# TODO(opadron): what happens if we don't find an include directory?
# Throw SKBuildError?

return python_include_dir

Expand Down
9 changes: 3 additions & 6 deletions skbuild/setuptools_wrap.py
Expand Up @@ -63,12 +63,9 @@ def parse_args():
concatenate_value=True)
dutils, cmake = move_arg('-G', dutils, cmake)
dutils, make = move_arg('-j', dutils, make)
absappend = (
lambda x: os.path.join(
os.path.dirname(os.path.abspath(sys.argv[0])),
x
)
)

def absappend(x):
return os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), x)

dutils, dutils = move_arg('--egg-base', dutils, dutils, f=absappend)

Expand Down

0 comments on commit 82cb708

Please sign in to comment.