开发者

How can I test my python module without installing it

开发者 https://www.devze.com 2023-02-24 22:07 出处:网络
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 t

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.

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 off开发者_C百科er suggestions!


Create a proper package for your stuff and use

python setup.py develop

to make it a proper dev-package.

See:

  • https://stackoverflow.com/a/19048754/548039
  • http://setuptools.readthedocs.io/en/latest/setuptools.html#development-mode


I would honestly insist on using virtualenv, its designed for this exact reason in mind. very small overhead, and if you ever mess up just delete directory. I am sure as you grow, things won't be as simple as they are now for your current situation. Take it as an opportunity to learn.


Altering sys.path much in production environment may be unwise. Altering it for testing is usually OK.

If you don't want to tinker with the variable from sys, use an environment variable named PYTHONPATH, it's a clean and documented way.

0

精彩评论

暂无评论...
验证码 换一张
取 消