问题描述
我正在重新设计/重构我的 Python 量子化学包 (pyquante).我不喜欢现有版本的一件事是我必须安装包才能运行测试套件.也就是说,测试套件有类似from PyQuante import SCF
这样的语句,当然,这个PyQuante可以指安装的版本或本地版本.
I'm in the process of redesigning/refactoring my Python quantum chemistry package (pyquante). One of the things I don't like about the existing release is that I have to install the package to run the test suite. That is, the test suite has statements like from PyQuante import SCF
, and, of course, this PyQuante could refer to the installed version or a local version.
我了解 virtualenv,并意识到这对我来说是一个选择.但我想知道是否还有其他合适的方法.在过去,我曾为这样的事情黑过 sys.path
,并且被更好的 Python 程序员告知我不应该这样做.
I know about virtualenv, and realize this is an option for me. But I was wondering whether anything else might be appropriate. In the past I've hacked sys.path
for things like this, and have been told by better Python programmers that I shouldn't ever to this.
有人对我如何做到这一点有任何建议吗?关键是我想测试当前版本的代码而不安装它.
Does anyone have any suggestions for how I can do this? The point is that I want to test the current version of the code without installing it.
提前感谢任何能看穿我的胡言乱语并提供建议的人!
Thanks in advance for anyone who can see through my babbling and offer suggestions!
推荐答案
为你的东西创建一个合适的包并使用
Create a proper package for your stuff and use
python setup.py develop
使其成为合适的开发包.
to make it a proper dev-package.
见:
- https://stackoverflow.com/a/19048754/548039
- http://setuptools.readthedocs.io/en/latest/setuptools.html#development-mode
这篇关于如何在不安装的情况下测试我的 python 模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!