Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
251 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,3 @@ | |
__author__ = 'The scikit-build team' | ||
__email__ = 'scikit-build@googlegroups.com' | ||
__version__ = '0.2.0' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
|
||
from wheel.bdist_wheel import bdist_wheel as _bdist_wheel | ||
|
||
from ..cmaker import SETUPTOOLS_INSTALL_DIR | ||
|
||
|
||
class bdist_wheel(_bdist_wheel): | ||
def finalize_options(self): | ||
try: | ||
if not self.build_base or self.build_base == 'build': | ||
self.build_base = cmaker.SETUPTOOLS_INSTALL_DIR | ||
self.build_base = SETUPTOOLS_INSTALL_DIR | ||
except AttributeError: | ||
pass | ||
_bdist_wheel.finalize_options(self) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,104 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import inspect | ||
import os | ||
import os.path | ||
import shutil | ||
import sys | ||
|
||
from contextlib import contextmanager | ||
from types import FunctionType | ||
|
||
from skbuild.cmaker import SKBUILD_DIR | ||
|
||
PYTHON2 = (sys.version_info < (3, 0)) | ||
|
||
# NOTE(opadron): we need to use separate files for the Python 2 and 3 cases | ||
# because there's no way to write code that executes a file that parses | ||
# successfully for both versions. | ||
if PYTHON2: | ||
from .exec_2 import execute | ||
else: | ||
from .exec_3 import execute | ||
|
||
|
||
@contextmanager | ||
def push_dir(dir): | ||
old_cwd = os.getcwd() | ||
os.chdir(dir) | ||
yield | ||
os.chdir(old_cwd) | ||
|
||
|
||
@contextmanager | ||
def push_argv(argv): | ||
old_argv = sys.argv | ||
sys.argv = argv | ||
yield | ||
sys.argv = old_argv | ||
|
||
|
||
def _noop(): | ||
pass | ||
|
||
|
||
class project_test(): | ||
def __init__(self, project): | ||
self.project = project | ||
|
||
def __call__(self, func=_noop): | ||
def result(*args, **kwargs): | ||
dir = list(self.project) | ||
dir.insert(0, os.path.dirname(os.path.abspath(__file__))) | ||
dir = os.path.join(*dir) | ||
|
||
with push_dir(dir): | ||
result2 = func(*args, **kwargs) | ||
|
||
return result2 | ||
|
||
return FunctionType( | ||
result.__code__, | ||
result.__globals__, | ||
func.__name__, | ||
result.__defaults__, | ||
result.__closure__ | ||
) | ||
|
||
|
||
class project_setup_py_test(): | ||
def __init__(self, project, setup_args, clear_cache=False): | ||
self.project = project | ||
self.setup_args = setup_args | ||
self.clear_cache = clear_cache | ||
|
||
f = inspect.currentframe().f_back | ||
self.locals = f.f_locals | ||
self.globals = f.f_globals | ||
|
||
def __call__(self, func=_noop): | ||
@project_test(self.project) | ||
def result(*args, **kwargs): | ||
argv = ["setup.py"] + self.setup_args | ||
with push_argv(argv): | ||
if self.clear_cache and os.path.exists(SKBUILD_DIR): | ||
shutil.rmtree(SKBUILD_DIR) | ||
|
||
setup_code = None | ||
with open("setup.py", "r") as fp: | ||
setup_code = compile(fp.read(), "setup.py", mode="exec") | ||
|
||
if setup_code is not None: | ||
execute(setup_code, self.globals, self.locals) | ||
|
||
result2 = func(*args, **kwargs) | ||
|
||
return result2 | ||
|
||
return FunctionType( | ||
result.__code__, | ||
result.__globals__, | ||
func.__name__, | ||
result.__defaults__, | ||
result.__closure__ | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
def execute(code, _globals, _locals): | ||
exec code in _globals, _locals # flake8: noqa: E901: SyntaxError |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
def execute(code, _globals, _locals): | ||
exec(code, _globals, _locals) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.