使用git来管理virtualenv状态:这会导致问题吗? [英] Using git to manage virtualenv state: will this cause problems?
问题描述
我现在有一个git和virtualenv,它的设置正好符合我的需求,迄今为止,并没有引起任何问题。然而,我知道
我的设置是非标准的,我想知道是否有人更熟悉virtualenv的
内部可以指出是否可能出错,以及在哪里出错。
我的设置
我的virtualenv在我的git仓库中,但git被设置为忽略 bin
和 include
目录以及 lib
中除外的所有内容 site-packages
目录。
更准确地说,我的 .gitignore
file看起来像这样:
*。pyc
#忽略所有的virtualenv内容,除了实际软件包
#自己
/ bin
/ include
/ lib / python * / *
!/ lib / python * / site-packages
#忽略easyinstall和setuptools
/lib/python*/site-packages/easy-install.pth
/lib/python*/site-packages/setuptools.pth
/ lib / python * / site-packages / setuptools- *
/ lib / python * / site-packages / pip- *
通过这种安排,我和其他任何正在从事项目结算的人员可以正常使用virtualenv和pip,但具有以下优点:$ b
$ b
-
如果有人更新或安装软件包并推送其更改,则任何自动获取这些更改的人都会获得更新:他们不需要注意
requirements.txt
文件已更改或执行任何post-receive
hook魔术。 没有网络依赖性:所有让应用程序工作的代码都在git仓库中。
我是意识到这只适用于纯Python包,但这就是我目前所关心的。
有人知道这种方法有任何其他问题吗?我应该知道吗?
如果您有任何 -e
项目在你的 requirements.txt
中 - 换句话说,如果你有任何可编辑的话如格式中所述使用 git
版本控制系统,当你的 src
目录被提交时,你很有可能遇到问题。如果您只是将 / src
添加到 .gitignore
中,那么您可以避免此问题,但通常安装只会添加一个指向 site-packages
到这个位置,所以你需要它!
I currently have git and virtualenv set up in a way which exactly suits my needs and, so far, hasn't caused any problems. However I'm aware that my setup is non-standard and I'm wondering if anyone more familiar with virtualenv's internals can point out if, and where, it's likely to go wrong.
My setup
My virtualenv is inside my git repository, but git is set to ignore the bin
and include
directories and everything in lib
except for the site-packages
directory.
More precisely, my .gitignore
file looks like this:
*.pyc
# Ignore all the virtualenv stuff except the actual packages
# themselves
/bin
/include
/lib/python*/*
!/lib/python*/site-packages
# Ignore easyinstall and setuptools
/lib/python*/site-packages/easy-install.pth
/lib/python*/site-packages/setuptools.pth
/lib/python*/site-packages/setuptools-*
/lib/python*/site-packages/pip-*
With this arrangement I -- and anyone else working on a checkout of the project -- can use virtualenv and pip as normal but with the following advantages:
If anyone updates or installs a package and pushes their changes, anyone else who pulls those changes automatically gets the update: they don't need to notice that a
requirements.txt
file has changed or do anypost-receive
hook magic.There are no network dependencies: all the code to make the application work lives in the git repository.
I'm aware that this only works with pure-Python packages, but that's all I'm concerned with at the moment.
Does anyone know of any other problems with this approach that I should be aware of?
If you have any -e
items in your requirements.txt
- in other words if you have any editable dependencies as described in the format that are using the git
version control system you will most likely run into issues when your src
directory is committed. If you just add /src
to your .gitignore
then you can avoid this problem, but often the installation just adds a pointer in site-packages
to this location, so you need it!
这篇关于使用git来管理virtualenv状态:这会导致问题吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!