diff options
author | Alexey Borzenkov <snaury@gmail.com> | 2014-06-25 22:16:11 +0400 |
---|---|---|
committer | Alexey Borzenkov <snaury@gmail.com> | 2014-06-25 22:16:11 +0400 |
commit | 3299cf1962171aa1b33f8cdb05d8de268592b20f (patch) | |
tree | f205d0d9707428581c62318255edb2a74c32c25b | |
parent | bc0a78d77ab5a79af226b7c3d390439f5dabd070 (diff) | |
download | greenlet-3299cf1962171aa1b33f8cdb05d8de268592b20f.tar.gz |
Don't symlink libraries unless inplace build is requested
-rw-r--r-- | conftest.py | 2 | ||||
-rw-r--r-- | my_build_ext.py | 22 | ||||
-rwxr-xr-x | run-tests.py | 4 | ||||
-rw-r--r-- | tests/__init__.py | 4 |
4 files changed, 26 insertions, 6 deletions
diff --git a/conftest.py b/conftest.py index aed8e5d..e3d92a1 100644 --- a/conftest.py +++ b/conftest.py @@ -6,7 +6,7 @@ from distutils.spawn import spawn def pytest_configure(config): os.chdir(os.path.dirname(__file__)) - cmd = [sys.executable, "setup.py", "-q", "build_ext", "-q"] + cmd = [sys.executable, "setup.py", "-q", "build_ext", "-q", "-i"] spawn(cmd, search_path=0) from tests import build_test_extensions diff --git a/my_build_ext.py b/my_build_ext.py index 049f0e7..6ff733c 100644 --- a/my_build_ext.py +++ b/my_build_ext.py @@ -22,9 +22,29 @@ def symlink_or_copy(src, dst): class build_ext(_build_ext): + """Command for building extensions + + Prepends library directory to sys.path on normal builds (for tests). + Otherwise it forces a non-inplace build and symlinks libraries instead. + """ + + def initialize_options(self): + self.my_inplace = None + _build_ext.initialize_options(self) + + def finalize_options(self): + if self.my_inplace is None: + self.my_inplace = self.inplace + self.inplace = 0 + _build_ext.finalize_options(self) + def build_extension(self, ext): - self.inplace = 0 _build_ext.build_extension(self, ext) + if not self.my_inplace: + build_lib = os.path.abspath(self.build_lib) + if build_lib not in sys.path: + sys.path.insert(0, build_lib) + return filename = self.get_ext_filename(ext.name) build_path = os.path.abspath(os.path.join(self.build_lib, filename)) src_path = os.path.abspath(filename) diff --git a/run-tests.py b/run-tests.py index 26e6959..525dc9b 100755 --- a/run-tests.py +++ b/run-tests.py @@ -31,9 +31,9 @@ for o, a in opts: # -- build greenlet if build: if verbosity == 0: - cmd = [sys.executable, "setup.py", "-q", "build_ext", "-q"] + cmd = [sys.executable, "setup.py", "-q", "build_ext", "-q", "-i"] else: - cmd = [sys.executable, "setup.py", "build_ext"] + cmd = [sys.executable, "setup.py", "build_ext", "-i"] spawn(cmd, search_path=0) diff --git a/tests/__init__.py b/tests/__init__.py index eb1c2e5..2f73330 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -39,8 +39,8 @@ def build_test_extensions(): results dir (e.g. build/lib.linux-i686-2.6) during installation. That means that we can't put any files there that we don't want to distribute. - To deal with it, this code will compile test extensions inplace, but - will use a separate directory for build files. This way testing with + To deal with it, this code will compile test extensions in a separate + directory, prepending it to sys.path afterwards. This way testing with multiple Python release and pydebug versions works and test extensions are not distributed. """ |