简体   繁体   English

如何在不将所有内容复制到lib / site-packages的情况下安装python包?

[英]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. 我想开发一个通用的python包,我得到了其他依赖于它的包。 For example: 例如:

  • packageA/ 程序包A /
  • packageB/ packageB /
  • packageC/ packageC /
  • commonPackage/ commonPackage /

packageA, packageB and packageC can all be executed directly, but they are all depend on commonPackage. packageA,packageB和packageC都可以直接执行,但是它们都依赖于commonPackage。 I want to install the commonPackage into lib/site-packages, but I don't want it copys the source code. 我想将commonPackage安装到lib / site-packages中,但是我不希望它复制源代码。 Instead, I want it creates a commonPackage.pth in lib/site-packages with the path of where the commonPackage at. 相反,我希望它在lib / site-packages中使用commonPackage所在的路径创建一个commonPackage.pth。 So that when I modify commonPackage or update it from SVN, I don't need to install it again. 这样,当我修改commonPackage或从SVN更新它时,就无需再次安装它。 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? 问题来了,我该如何编写setup.py或使用python setup.py install的选项来执行我想要的工作?

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. 您可以随时查看virtualenv,它允许您为每个项目创建一个python环境-这是开发/构建/部署应用程序的理想方法,而无需加载所有内容和杂项的site-packages目录。

There's a good tutorial here: 这里有一个很好的教程:

http://iamzed.com/2009/05/07/a-primer-on-virtualenv/ 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. 我说的是setuptools的开发命令。 Here you type 在这里输入

python setup.py develop

It creates .pth rather than copying everything into site-packages. 它创建.pth,而不是将所有内容复制到站点程序包中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在“ site-packages”中安装python包? - how to install python packages in “site-packages”? 如何手动将文件夹复制到/app/.heroku/python/lib/python2.7/site-packages/? - How to manually copy folder to /app/.heroku/python/lib/python2.7/site-packages/? 如何在Linux下的/usr/local/lib/python2.7/site-packages下安装Pip - how to Install Pip under /usr/local/lib/python2.7/site-packages in Linux 将python包安装到相对于site-packages的目录中 - Install python package into directory relative to site-packages 如何在特定 python 安装的站点包中通过 pip 安装 python 包? - How to Install a python package via pip in site-packages of specific python installation? 如何将文件从Python程序包(站点程序包)复制到目录? - How can I copy files from a Python package (site-packages) to a directory? 如何为本地Python 2.7安装设置site-packages目录 - How to set site-packages directory for local Python 2.7 install Python将DLL复制到Windows上的站点包 - Python copy a DLL to site-packages on Windows 如何在其模块搜索路径中不包含〜/ .local / lib / pythonX.Y / site-packages的情况下运行python - How to run python without including ~/.local/lib/pythonX.Y/site-packages in its module search path Python package 位于 venv/lib/site-packages 文件夹中,并显示为安装在 PyCharm 但抛出 ModuleNotFoundError - Python package is in venv/lib/site-packages folder and shows as installed in PyCharm but throws ModuleNotFoundError
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM