问题:相当于python的Maven

我是Java开发人员/ python初学者,但我缺少maven功能,特别是依赖管理和构建自动化(我是说您没有构建,但是如何创建用于部署的软件包?)

是否有等效的Python实现这些功能?
注意:我使用python 2.x

谢谢。

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?)

Is there a python equivalent to achieve these features?
Note: I use python 2.x

Thanks.


回答 0

Python使用distutils和setuptools进行依赖和打包。

以下是介绍基本知识的教程: http //docs.activestate.com/activepython/3.2/diveintopython3/html/packaging.html

简而言之,您将拥有setup.py文件,该文件包含依赖项和脚本编译/安装信息,并且您可以使用它来构建egg,dist tarball,binary tarball等。

Python uses distutils and setuptools for dependency and packaging.

Heres a tutorial which explains basics: 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.


回答 1

没有直接匹配。但是,您可以获得的最接近的:

  • zc.buildout:它可以设置封闭环境,下载/处理依赖项,初始化脚本等。它还基于插件(或称其为“配方”)。几年前,当它处于beta阶段时,我就使用了它,也许它从那时起就已经发展了。与Maven一样,学习曲线也很丰富,但它也是最强大的。

其他产品是Maven / zc.buildout的子集:

您可能知道Ant和Shell脚本,因此您还可以检查以下Python工具:

  • 织物摊铺机:具有更多风味的命令行任务运行程序。它们将您的传统命令行执行包装在python中,并允许以更强大的方式管理各种任务(任务依赖关系,解释输出,在远程服务器中运行命令等)。基本上,您无法使用Shell脚本执行任何操作,但是在python中,它的神秘性要低得多。

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.

Other offerings are subsets of Maven/zc.buildout:

You probably know Ant and shell scripting, so you could check also these Python tools:

  • Fabric or 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.

回答 2

我想指出PyBuilder,它受maven的启发很大,但是使用python而不是XML进行配置,因此它实际上是可读的,恕我直言。

有一个用于依赖性管理的插件(在后台使用pip并区分构建和运行时依赖性),并且与maven一样,您可以使用单个命令在整个构建生命周期中运行。

I’d like to point out PyBuilder which is heavily inspired by maven but uses python instead of XML for configuration, so it’s actually readable, IMHO.

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.


回答 3

对于部署,除了distutils / setuptoos外,还请查看pip包(使用下面的setuptools)。它可以回滚失败的安装,也可以卸载(easy_install / setuptools中缺少的东西)。另外,您可以通过需求文本文件指定依赖关系。

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.


回答 4

最好使用virtualenv创建独立的项目环境,并使用pip / easy_install来管理依赖项。

It’s good to use virtualenv to create standalone project environment and use pip/easy_install to management dependencies.


声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。