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

Support environments without pip #651

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

orsinium
Copy link
Contributor

Before: use pip installed in the target environment.

After: If pip is available in the current environment, use it, pointing it to the target environment using the --python flag. Otherwise, if Python is not installed in the same environment as flit, fall back to the old behavior.

This change is inspired by rye. It allows to use flit with virtual environments created with --without-pip flag.

@orsinium
Copy link
Contributor Author

Right. I broke tests because they mock pip in the target environment. Well, tell me if you like the change, and I'll take care of actualizing tests.

@takluyver
Copy link
Member

Thanks, I think this makes sense, if people are going to rely on this new-ish pip feature to make virtualenvs without pip inside. Sorry it's taken me a while to look at it.

There's at least one more call to pip that should be changed in the same way:

cmd = [self.python, '-m', 'pip', 'install', req_with_extras]

I think that's all, but please have a look yourself in case I've missed one.

Unfortunately I suspect this will be quite a pain for the tests, because as you spotted, we use the ability to point it to an arbitrary Python to mock out the installation command for the tests. If you get stuck with that, one way out might be to swap around the priority, e.g. doing target_python -m pip --version to check if it's installed in the target environment, and only using the pip --python option if not. 🤔

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.

2 participants