pyenv / pyenv-virtualenv

a pyenv plugin to manage virtualenv (a.k.a. python-virtualenv)
MIT License
6.24k stars 399 forks source link

Exporting pyenv-virtualenv project #243

Open srflaxu40 opened 6 years ago

srflaxu40 commented 6 years ago

Does the functionality exist to export a pyenv-virtualenv project to a directory for a use-case say like committing to a repo or project? I'd like to do this to give users of the repo access to the pyenv-virtualenv project, but I noticed it does not support path creation like regular virtualenv does?

example:

pyenv virtualenv 2.7.10 ~/path/to/git-project/<pyenv-projectname>

native-api commented 4 months ago

You can't really commit a virtualenv to version control because it contains a reference to its base environment -- which is OS- and machine-dependent. You are supposed to instead commit requirements.txt and recreate virtual environments on demand.

For a project-centric rathe than environment-centric ecosystem, Pipenv may be a better fit. IIRC you are supposed to commit Pipfile to version control (which has richer logic than requirements.txt) and recreate an environment on demand with pipenv install. The pipenv command is a part of the same-named Python package so it can be used in conjuction with Pyenv.


That said, you can create an environment with plain virtualenv and symlink it into $(pyenv root)/versions (there's a 3rd-party plugin that can do the symlinking with a pyenv subcommand). Or do vice versa: create an environment on the usual path and symlink to it from the project directory.