question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make default venv created have a more appropriate name (like the project name)

See original GitHub issue

I’ve seen that many projects have this folder venv where they keep their virtual environment. While that’s cool because for structural reasons, it’s not as nice to see (venv) at the beginning of the prompt line, for all of your virtual envs.

I usually create virtual environments like this:

$ virtualenv my-project
$ ln -s venv my-project

This way, there is a good old standard venv folder (for using in paths), but then when you activate, the prompt you see is not

(venv) user@host :~/path$

but

(my-project) user@host: ~/path$

This is much nicer, and actually quite important for people working with many projects/virtual environments (as me 😃 ). It’s not necessary to have a symbolic link. One could create a virtualenv like this

$ python -m virtualenv my-project
$ mv my-project venv

This way we only have the venv folder in the end, but when activating it, it automatically uses a good name.

I did investigate whether there is an option to pass to python -m virtualenv so that it knows that the destination folder and the virtual env names are different, but there is no such option. Moreover, the name is very deeply hardcoded as the folder name. Still the workarounds I provided could be a source of inspiration 😄

I also did try fiddling with the configuration file, where I found an option venv_dir… That didn’t seem to do anything though (or at least not what I had hoped - to make the prompt more explicit when I activate the venv).

Anyway, I am sorry for being lazy and not making a PR with the feature, but I think it’s a good feature to have, and maybe if you have time, you’ll get to it 😄 - or maybe I get less lazy at some point and try to help with a PR.

Thanks, Sorry for being lazy, Cool project. I’m evaluating/playing with it, keep on the god work!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
jberendscommented, Oct 31, 2017

It seems that using venv inside the ‘project’ directory is supported out of the box by a.o. pycharm nowadays (will autodetect). Having ‘centralised’ venv_* directories is in our company really frowned upon, as you never know if you have the proper package versions installed for said project. I would remain the default on venv inside the project package.

Alternatively I see some people make a new venv and develop the code of the package inside a src inside that venv. Activation is then done using source ./bin/activate and the various directories are ourside version control. The ‘src’ is however. Unsure if you want to support this in hatch.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Make default venv created have a more appropriate name ...
It seems that using venv inside the 'project' directory is supported out of the box by a.o. pycharm nowadays (will autodetect). Having ' ......
Read more >
Trying to come up with a default directory name for virtual ...
I have projects split between scripts, apps, and notebooks. I use project based names for my virtual environments so that when I create...
Read more >
How to rename a virtualenv in Python? - Stack Overflow
It is safer to just delete the virtualenv directory and create a new one with the correct name. You can do this by:...
Read more >
Python virtualenv and venv dos and don'ts - InfoWorld
Use a name that describes your project unambiguously. Don't share virtual environments between projects. If you have multiple projects that have ...
Read more >
Creating a Virtual Environment - Real Python
Create a project directory; Change into the project directory; Run python3 -m venv <name_of_virtualenv>.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found