Skip to content

env: pop PIP_REQUIRE_VIRTUALENV from isolated environment #91

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

Merged
merged 1 commit into from
Sep 11, 2020

Conversation

adamchainz
Copy link
Contributor

@adamchainz adamchainz commented Sep 9, 2020

Fixes #90.

@adamchainz
Copy link
Contributor Author

If this is found to break anything, the approach from pypa/pyproject-hooks@a03b4e8 could be copied

@FFY00
Copy link
Member

FFY00 commented Sep 9, 2020

Hum, will --isolated break PIP_USE_FEATURE=2020-resolver? Maybe we should be setting that all ourselves when it is required.

@pradyunsg could you recommend anything here? In some cases we might end up with duplicated requirements and the dependency resolver would be able to handle that. Are any possible drawbacks to using the dependency resolver in all cases?

What I've been doing is.

PIP_USE_FEATURE=2020-resolver python -m build

But I agree here that passing --isolated would be good.

I think we should remove PIP_REQUIRE_VIRTUALENV regardless, can you please add that to the PR? Thanks!

@adamchainz
Copy link
Contributor Author

Hum, will --isolated break PIP_USE_FEATURE=2020-resolver?

I imagine so

I think we should remove PIP_REQUIRE_VIRTUALENV regardless, can you please add that to the PR? Thanks!

I don't see why we'd do both fixes? PIP_REQUIRE_VIRTUALENV has no effect when --isolated is passed.

@pganssle
Copy link
Member

pganssle commented Sep 9, 2020

I think we should go with the approach where we pop PIP_REQUIRE_VIRTUALENV.

To me, the whole purpose of the PIP_* environment variables is to allow you to configure pip invocations nested within other programs. For PIP_REQUIRE_VIRTUALENV, it makes sense to remove it because we are installing to a virtual environment of sorts (I actually wonder if there's something we can do to make pip recognize this), so the actual criterion is satisfied.

For other things like the resolver, setting --no-binary :all:, etc, we don't want to be overriding people's pip settings.

@FFY00
Copy link
Member

FFY00 commented Sep 9, 2020

Okay, so you can add a _pop_env method to IsolatedEnvironment that will pop the env if present and add it to self._env to be restored later. Please also add a test for this if you can 😊

@pradyunsg
Copy link
Member

I see I've been mentioned here, but I don't have anything to add beyond what @pganssle said (all of which I agree with). :)

@adamchainz adamchainz force-pushed the issue_90_require_virtualenv branch from dd19792 to d1e9df0 Compare September 10, 2020 09:06
@adamchainz adamchainz changed the title Pass --isolated to 'pip install' Remove PIP_REQUIRE_VIRTUALENV from environment when invoking pip Sep 10, 2020
@adamchainz adamchainz force-pushed the issue_90_require_virtualenv branch from d1e9df0 to 1eb82c4 Compare September 10, 2020 09:12
@adamchainz adamchainz changed the title Remove PIP_REQUIRE_VIRTUALENV from environment when invoking pip Pop PIP_REQUIRE_VIRTUALENV from isolated environment Sep 10, 2020
@FFY00
Copy link
Member

FFY00 commented Sep 10, 2020

@pradyunsg my question for you was if it was a good idea to set PIP_USE_FEATURE=2020-resolver as we need it in some cases.

@pradyunsg
Copy link
Member

pradyunsg commented Sep 10, 2020

Unconditionally in build, I'd say don't.

pip's going to flip the switch soon, and we'll remove that flag eventually as well. Sticking to what pip does by default will be easier to explain and justify. It might be a good idea to pass-through environment variables starting with PIP_ into the pip call TBH.

@FFY00
Copy link
Member

FFY00 commented Sep 10, 2020

@adamchainz you are just missing the type hint, # type: (str) -> None, if you could add it it would be great! Thanks 😁

@adamchainz
Copy link
Contributor Author

Use github suggestions for such minutiae.

@adamchainz adamchainz force-pushed the issue_90_require_virtualenv branch from 1eb82c4 to 28f22e6 Compare September 10, 2020 15:36
@FFY00 FFY00 changed the title Pop PIP_REQUIRE_VIRTUALENV from isolated environment env: pop PIP_REQUIRE_VIRTUALENV from isolated environment Sep 11, 2020
@FFY00 FFY00 merged commit b805ff7 into pypa:master Sep 11, 2020
@FFY00
Copy link
Member

FFY00 commented Sep 11, 2020

Thank you 😊

@adamchainz adamchainz deleted the issue_90_require_virtualenv branch September 11, 2020 09:07
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

Successfully merging this pull request may close these issues.

Unset PIP_REQUIRE_VIRTUALENV when running 'pip'
4 participants