python的Maven等价物
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3324108/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Maven equivalent for python
提问by Enno Shioji
I'm a java developer/python beginner, and I'm missing my maven features, particularly dependency management and build automation (I mean you don't build, but how to create a package for deployment?)
我是一名 Java 开发人员/python 初学者,我缺少我的 maven 功能,特别是依赖项管理和构建自动化(我的意思是你不构建,但如何创建用于部署的包?)
Is there a python equivalent to achieve these features?
Note: I use python 2.x
是否有等效的 python 来实现这些功能?
注意:我使用python 2.x
Thanks.
谢谢。
采纳答案by Daniel Kluev
Python uses distutils and setuptools for dependency and packaging.
Python 使用 distutils 和 setuptools 进行依赖和打包。
Heres a tutorial which explains basics: http://docs.activestate.com/activepython/3.2/diveintopython3/html/packaging.html
这是一个解释基础知识的教程:http: //docs.activestate.com/activepython/3.2/diveintopython3/html/packaging.html
In short, you will have setup.py file, which has dependency and script compilation/installation information, and you can build eggs, dist tarballs, binary tarballs, etc with it.
简而言之,您将拥有 setup.py 文件,其中包含依赖项和脚本编译/安装信息,您可以使用它构建鸡蛋、dist tarball、二进制 tarball 等。
回答by ars
For deployment, in addition to distutils/setuptoos, also take a look at the pip package(uses setuptools underneath). It can rollback failed installations and also uninstall (something missing from easy_install/setuptools). In addition, you can specify dependencies through a requirements text file.
对于部署,除了distutils/setuptoos,还要看一下pip包(下面使用setuptools)。它可以回滚失败的安装,也可以卸载(easy_install/setuptools 中缺少的东西)。此外,您可以通过需求文本文件指定依赖项。
回答by Ning Sun
It's good to use virtualenv to create standalone project environment and use pip/easy_install to management dependencies.
使用virtualenv创建独立项目环境并使用pip/easy_install管理依赖关系很好。
回答by Tuukka Mustonen
There is no direct match. However, the closest you can get:
没有直接匹配。但是,您可以获得的最接近:
- zc.buildout: It can setup closed environments, download/handle dependencies, initialize scripts, etc. It also builds on plugins (or "recipes", as they call them). I used it a few years ago when it was in beta stages, probably it has evolved since then. There is learning curve, as with Maven, but it's also the most powerful.
- zc.buildout:它可以设置封闭环境、下载/处理依赖项、初始化脚本等。它还建立在插件(或“食谱”,他们称之为)之上。几年前我在它处于测试阶段时使用过它,可能从那时起它就已经发展了。与 Maven 一样,有学习曲线,但它也是最强大的。
Other offerings are subsets of Maven/zc.buildout:
其他产品是 Maven/zc.buildout 的子集:
- Setuptools: package creation / installation
- Pip: dependency management
- Virtualenv+ virtualenvwrapper: Managing separate python environments (something you don't need with Java)
- 安装工具:包创建/安装
- Pip:依赖管理
- Virtualenv+ virtualenvwrapper:管理单独的python环境(Java不需要的东西)
You probably know Ant and shell scripting, so you could check also these Python tools:
您可能了解 Ant 和 shell 脚本,因此您还可以查看这些 Python 工具:
- Fabricor Paver: command-line task runners with added flavors. They wrap your traditional command-line execution in python, and allow to manage various tasks in a more powerful way (task dependencies, interpreting output, running commands in remote server, etc.). Basically nothing you couldn't do with shell scripting, but in python, it's much less cryptic.
回答by user245678
I'd like to point out PyBuilderwhich is heavily inspired by maven but uses python instead of XML for configuration, so it's actually readable, IMHO.
我想指出PyBuilder,它深受 maven 的启发,但使用 python 而不是 XML 进行配置,所以它实际上是可读的,恕我直言。
There is a plugin for dependency management (uses pip under the hood and differentiates between build and runtime dependencies) and, not unlike maven, you can run through the full build lifecycle with a single command.
有一个用于依赖项管理的插件(在底层使用 pip 并区分构建和运行时依赖项),并且与 maven 不同,您可以使用单个命令运行完整的构建生命周期。

