简体   繁体   中英

How to install python package without copy everything into lib/site-packages?

I want to develop a common python package, I got other packages depends on it. For example:

  • packageA/
  • packageB/
  • packageC/
  • commonPackage/

packageA, packageB and packageC can all be executed directly, but they are all depend on commonPackage. I want to install the commonPackage into lib/site-packages, but I don't want it copys the source code. Instead, I want it creates a commonPackage.pth in lib/site-packages with the path of where the commonPackage at. So that when I modify commonPackage or update it from SVN, I don't need to install it again. Here comes the problem, how can I write the setup.py or use the options of python setup.py install so that it would do what I want?

You can always take a look at virtualenv which will allow you to create a python environment for each of your projects - this is the ideal way to develop/build/deploy your app without having load up your site-packages directory with all and sundry.

There's a good tutorial here:

http://iamzed.com/2009/05/07/a-primer-on-virtualenv/

Good luck !

Oops, I just find exactly what I want here . The develop command of setuptools do what I said. Here you type

python setup.py develop

It creates .pth rather than copying everything into site-packages.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM