-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Add custom venv name support #4974
Conversation
check environment variable PIPENV_CUSTOM_VENV_NAME
@darelf I am wondering about this with respect to managing multiple projects--since this current patch seems to indicate that an environment variable is set to name the project's virtualenv it would not scale well beyond one project. I am wondering if it would be better to have a variable like Other than that, once we settle on the approach here, we will want to document the change with a news fragment and update any documentation. Also tests, we should cover the change with at least some unit test. |
@matteius I had originally done just such a thing. However, in my own workflow I realized that the pain point for me was similar to the one @ianyoung in the thread on that issue. Namely, I would have a project directory, then one or more subdirectories in which where the python project(s). My original looked something like this:
This is certainly easier if your Pipfile is in a directory with the name you want for the venv, and it solved the original request for #1226 but didn't actually solve "custom" venv names. In the case of a directory structure with a common base name, and a "frontend" and "backend" subdirectory with separate Pipfile, you'd want something like "myproject-frontend" and "myproject-backend". And that doesn't solve that you might actually want the hash appended in that case. To satisfy custom naming, it might be better to have a scheme like this: PIPENV_CUSTOM_VENV_NAME - overrides the venv name This would mean the code for that function would look something like this:
|
I guess I should outline what that would do. Assume a directory called "frontend" with your
|
@darelf I think the logical complexity of that method has grown beyond what is good maintainability with the current iteration. I like where you have went with it, but do we really need |
Also the thing about |
So, is the thinking that the custom name could include the base name if desired? That makes a lot of sense and reduces the complexity. You're already setting a variable with a custom name... So, if you have 2 subdirectories under
|
Apologies for the extra commits.... we don't use pull requests at work, so I was unaware it tracked changes. |
@darelf It is fine, if we eventually merge it we can use the Squash and Merge options which will take the current change delta and make a single commit out of it.
Exactly, and keep in mind that the method will need tests. Adding two custom environment variables may be a tough sell, but three for this would probably be a non-starter.
I think that makes sense, except perhaps for the naming of |
I have no problem with the "nit picking". A lot of these are just "here's a name that works for me that I thought of in 0.25 seconds" so I'm not married to any of that.
As an additional note: I mainly use the join() to avoid |
Ok that sounds like a solid argument, thanks for putting thought into this. I think leaving it a join seems reasonable. |
@darelf Can you work on some unit test(s) for this and add a feature news fragment to start the documentation updates? Once you do that I can run the workflow. We should also consider updating the actual documentation about these environment variables. |
I'll start looking at tests, etc. for this as I get time. |
I am sorry for the late review here.
The following commits added complexity, which also always adds a hyphen to the VENV name. If you have a scenario with different
And in another shell, with:
Easy to use when running anything like a modern terminal with tabs or tmux ... This also works for any IDE. This will make this feature easy to understand for users as well as maintainers. |
check environment variable PIPENV_CUSTOM_VENV_NAME
Resolves #1226