Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow use of system packages in venv #72

Open
mcepl opened this issue May 5, 2022 · 2 comments
Open

Allow use of system packages in venv #72

mcepl opened this issue May 5, 2022 · 2 comments

Comments

@mcepl
Copy link

mcepl commented May 5, 2022

When packaging nptyping for openSUSE we build packages (as every other Linux distribution does) in the environment completely isolated from the network. We pre-install all packages in the build environment, but we need to able to use it:

---
 tests/test_wheel.py |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

--- a/tests/test_wheel.py
+++ b/tests/test_wheel.py
@@ -93,10 +93,9 @@ class WheelTest(TestCase):

     def test_wheel_can_be_installed(self):
         with working_dir(Path(self.temp_dir.name)):
-            venv.create(_VENV_NAME, with_pip=False)
-            # For some reason, with_pip=True fails, so we do it separately.
-            subprocess.check_output(
-                f"{self.py} -m ensurepip --upgrade --default-pip", shell=True
+            venv.create(_VENV_NAME, system_site_packages=True, with_pip=True)
+            print(
+                f"{self.pip} install {_ROOT / 'dist' / _WHEEL_NAME}"
             )
             subprocess.check_output(
                 f"{self.pip} install {_ROOT / 'dist' / _WHEEL_NAME}", shell=True

I am not sure whether with_pip is relevant, but using it seems to make the code slightly simple.

@ramonhagenaars
Copy link
Owner

Hi @mcepl. The argument with_pip=True should create a virtual environment with pip. This is relevant, because later in this test, it is checked whether nptyping and all its dependencies can be installed with it.

But as the comment states, for some reason that command failed for me with with_pip=True. That's the reason for the line that follows with ensurepip; to still make pip available after the virtual environment creation.

What exactly is your question/suggestion?

@mcepl
Copy link
Author

mcepl commented May 5, 2022

That for running the test suite inside of the environments without the Internet access, it is necessary to add system_site_packages=True, so that previously installed system packages can be used.

That with_pip=True is probably irrelevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants