RELATED ARTICLE :: https://iamjohnnym.com/2018/11/15/managing-python-with-pyenv-and-direnv.html
This project is meant to ease the process of managing python for given projects. Leveraging pyenv
, virtualenv
, and direnv
, users will automatically create and source a python virtualenv for their projects.
Ensure you have both pyenv and direnv installed on your system.
Navigate to the root dir of a python project and copy down this projects .envrc
. Having the file in this dir will trigger direnv
to prompt you to allow execution of that file.
$ wget https://raw.githubusercontent.com/iamjohnnym/auto-pyvenv/master/.envrc
direnv: error .envrc is blocked. Run `direnv allow` to approve its content.
$ direnv allow
direnv: loading .envrc
Installing virtualenv for Python 3.7.0
Activating Python 3.7.0 virtualenv
Virtualenv has been activated for Python 3.7.0
/Users/iamjohnnym/.personal/tutorials/pyenv-direnv/.venv/bin/python
direnv: export +VIRTUAL_ENV ~PATH
You can also specify what version of python you want to use with your project by creating a .python-version
file.
$ pyenv local 3.6.1
$ cat .python-version
3.6.1
$ pyenv versions
system
2.7.15
3.5.0
* 3.6.1 (set by /Users/iamjohnnym/.personal/auto-venv/.python-version)
3.7.0
$ rm .envrc
- Johnny Martin - Initial work - iamjohnnym
See also the list of contributors who participated in this project.
Your contributions are always welcome! Please have a look at the contribution guidelines first.
Apache License, Version 2.0 2018 - Johnny Martin. Please have a look at the LICENSE.md for more details.
We use SemVer for versioning. For the versions available, see the tags on this repository.