Package: venvlink
🔗 venvlinkThe job ofvenvlinkis create alinkfor the./venv/Scripts/activatescript inside the project folder and, if needed, create a virtual environment outside your project folder, usingpython -m venv <project_name>.Table of ContentsWithout venvlinkWith venvlinkMotivationInstallingRequirementsInstallation with pipGetting startedCreating a virtual environmentGetting helpRemoving virtual environmentsConfigurationConsiderationsSpecial casesFile structure tipVenvlink and other toolsContributingWithout venvlinkThis is how work with virtual environments looks like withpython -m venv venv:With venvlinkWithvenvlinkthe virtual environment is created in a centralized folder, and only a proxy ("link") of theactivatescript is created to the project folder:MotivationThe reason for one using venvlink might be one or multiple from below.🚫📤 don't backup venv/*If you want to keep your virtual environments from being backed up toe.g.OneDrive/Dropbox or other backup service with your project files, venvlink is one way to do it. You might want to do this to save space on your cloud storage or resources on your computer / network (prevent checking and uploading new/modified files).🗂️🧹centralized & tidyIf you want to centralize your virtual environments just because you think it is clean or it makes you happy.✨♻️ reusabilityIf you want to reuse some of your virtual environments in multiple projects (sharing same imports) or want to use a general(tmp)virtual environment for all of your one-off testing, for example.🏗️✔️relocating projectsIf you want to be able to relocate projects on hard disk (on same machine) by just copy-pasting them, even with virtual environments. Or, if you want to be able rename a part of the project path without breaking the virtual environment.🔑🎯 centralized, but with anactivatescriptIf you want to have centralized virtual environments, but would want to activate them, without having to remember the name of the virtual environment, just by running./venv/Scripts/activateTheactivatescript in your project folder is just a proxy ("link") for the realactivatescript located elsewhere.🗑️🤝 remove anytimeThevenvlinkphilosophy is that a tool should not chain it's user. You can remove it anytime and your virtual environments and activate proxy scripts will still work. Venvlink is only used for creation of virtual environments.💼✔️ works with an existing venv collectionIf you happen to have already a collection of virtual environments inside one folder, you can start using them withvenvlinkright away. Just configure thevenv_folderin the.venvlinkrc, and you're good to go.🐍🐍 multipythonIt is not a problem if you have multiple python versions installed. The syntax is<path_to_python_exe> -m venvlink ...Therefore, you can usevenvlinkonPython 3.6.4 32-bitandPython 3.9.2 64-bitat the same time. What you need to do is to installvenvlinkfor both python versions with<path_to_python_exe> -m pip install venvlink
<path_to_another_python_exe> -m pip install venvlinkand the rest you can use normally. Note that virtual environments in the centralized folder will have the same python version which was used to create the virtual environment in the first place. You can later on use your main python executable to create more links for an existing virtual environment, no matter what version of python it is using. Use descriptive venv names to distinguish the venvs with different python versions, if needed.✨🔥 auto-activateThevenvlinksupports a Powershell addon calledvenvlink-autoenvwhich will automatically activate/deactivate the virtual environment on Windows Powershell! (Works also with exampleVS Code Integrated Terminal, when Powershell is selected )New in version 0.5.0InstallingRequirementsvenvlinkis currently supporting only Windows, but it shouldn't be too hard to create Linux/maxOS support. I personally use only Windows, but I would be really happy to receive pull request(s) for Linux/macOS support.Installation with pippip install venvlinkFor installation for development, seeCONTRIBUTING.md.Getting started✨ Creating a virtual environmentAssume that you have a project atC:\workdir\someproject\and you would like to create virtual environment for that folder.
Instead of the regularPSC:\workdir\someproject>python-mvenvvenvusingvenvlinkone would typePSC:\workdir\someproject>python-mvenvlinkproject-nameThis would create, inside your project directory, avenvfolder with only few files (<1Kb in total), such as theactivatescript.:venv
├── Scripts
│   ├── Activate.ps1
│   ├── activate
│   └── activate.bat
└── venvlinkand inside yourvenv_folder(located elsewhere), the actual virtual environment files (can be up to hundreds of Mb, and thousands of files):project-name/
├── Include
├── Lib
│   └── site-packages
├── Scripts
│   ├── Activate.ps1
│   ├── activate
│   ├── activate.bat
│   └── deactivate.bat
├── pyvenv.cfg
└── shareTo activate the virtual environment(project-name), you would callPSC:\workdir\someproject>.\venv\Scripts\activatewhich would then call transparently*C:\Python\venvs\project-name\Scripts\activateand result you having that virtual environment activated, as:(project-name) PS C:\workdir\someproject>[*] assuming that you have defined thevenv_folderto beC:\Python\venvs\in the.venvlinkrc.📖❔ Getting helpYou can use  the-hflag:PS C:\somepath\project> python -m venvlink -h

usage: venvlink [-h] [--init] [-d] [-S] [projectname]

venvlink 0.3.1

positional arguments:
  projectname

optional arguments:
  -h, --help            show this help message and exit
  --init                Initiate the venvlink configuration file (.venvlinkrc)
  -d, --delete          Delete the virtual environment associated with project_name (instead of creating)
  -S, --system-site-packages
                        Give the virtual environment access to the system site-packages dir.🗑️ Removing virtual environmentsIf you want to fully remove a virtual environment and all its contents, you can either runpython -m venvlink -d <venv_to_be_removed>or just navigate to the centralized virtual env folder, and remove the folder(s) you want. There is no centralized bookkeeping between the virtual environments and theactivateproxies (just a one-way link from proxy to the venv), and therefore allactivateproxies associated with the venv will stop working after deletion, or until a venv with same name is created.If you want to just remove the link between a virtual environment and your project, you can safely remove theactivateproxy/link from your project folder. If you are planning to create a link to another virtual environment, you can simplypython -m venvlink anothervenvAll what this does is recreates the proxy and, if anothervenv does not exist, creates anothervenv.🛠️ ConfigurationSee:Configuration.Considerations🔍❕ Special casesMoving your virtual environment to centralized place means that you'll might have to tell to some tools where you have located your virtual environments. One example ispylint, which needs to kown where the project venv is located, to prevent false positiveimport-errors. See:Usage with linters (e.g. pylint).💡📁 File structure tipFollowing file structure has found to be useful:C:\Python\Python365\          # python installation
C:\Python\Python386\          # python installation
C:\Python\Python386-32\       # python installation
C:\Python\Python392\          # python installation
C:\Python\venvs\              # virtual environmentssince it is easy to findpython.exebehind for creating a venvC:\Python\Python386\python.exe -m venvlink myprojand it is also easy to browse the venvs when they are after a short path.🍎🍌 venvlink and other toolsThese tools work well together and have synergies withvenlink:venvlink-autoenv: The Powershell addon for venvlink >= 0.5.0.pyenv-win: Python version management/switcherpew: Virtual environment managementOther tools and how they relate tovenvlink:Python environment management toolsContributingWhat?How?🐞 Found a bug?🎟File an Issue🙋‍♂️ Need help?❔Ask a question on StackOverflow💡 Got a suggestion?🎫 File an Issue (feature request)🧙  Want to write code?🔥Here's how you get started!