Python distutils - 有谁知道如何使用它?

时间:2021-11-15 02:47:32

I wrote a quick program in python to add a gtk GUI to a cli program. I was wondering how I can create an installer using distutils. Since it's just a GUI frontend for a command line app it only works in *nix anyway so I'm not worried about it being cross platform.

我在python中编写了一个快速程序,为一个cli程序添加一个gtk GUI。我想知道如何使用distutils创建安装程序。因为它只是一个命令行应用程序的GUI前端,所以它只适用于* nix,所以我并不担心它是跨平台的。

my main goal is to create a .deb package for debian/ubuntu users, but I don't understand make/configure files. I've primarily been a web developer up until now.

我的主要目标是为debian / ubuntu用户创建一个.deb包,但我不懂make / configure文件。到目前为止,我主要是一名网络开发人员。

Thanks for your help!

谢谢你的帮助!

edit: Does anyone know of a project that uses distutils so I could see it in action and, you know, actually try building it?

编辑:有没有人知道一个使用distutils的项目,所以我可以看到它在行动,你知道,实际上尝试构建它?

Here are a few useful links

  • Ubuntu Python Packaging Guide

    Ubuntu Python包装指南

    This Guide is very helpful. I don't know how I missed it during my initial wave of gooling. It even walks you through packaging up an existing python application

    本指南非常有用。我不知道在最初的淘汰赛中我是如何错过的。它甚至会引导您完成现有python应用程序的打包

  • The Ubuntu MOTU Project

    Ubuntu MOTU项目

    This is the official package maintaining project at ubuntu. Anyone can join, and there are lots of tutorials and info about creating packages, of all types, which include the above 'python packaging guide'.

    这是ubuntu的官方包维护项目。任何人都可以加入,并且有很多关于创建所有类型的包的教程和信息,其中包括上面的“python包装指南”。

  • "Python distutils to deb?" - Ars Technica Forum discussion

    “Python会让人厌烦吗?” - Ars Technica论坛讨论

    According to this conversation, you can't just use distutils. It doesn't follow the debian packaging format (or something like that). I guess that's why you need dh_make as seen in the Ubuntu Packaging guide

    根据这个对话,你不能只使用distutils。它不遵循debian打包格式(或类似的东西)。我想这就是你需要dh_make的原因,如Ubuntu Packaging指南中所示

  • "A bdist_deb command for distutils

    “用于distutils的bdist_deb命令

    This one has some interesting discussion (it's also how I found the ubuntu guide) about concatenating a zip-file and a shell script to create some kind of universal executable (anything with python and bash that is). weird. Let me know if anyone finds more info on this practice because I've never heard of it.

    这个有一些有趣的讨论(它也是我如何找到ubuntu指南)关于连接zip文件和shell脚本来创建某种通用可执行文件(任何使用python和bash的东西)。奇怪的。如果有人发现有关这种做法的更多信息,请告诉我,因为我从未听说过。

  • Description of the deb format and how distutils fit in - python mailing list

    deb格式的描述以及distutils如何适应 - python邮件列表

5 个解决方案

#1


13  

See the distutils simple example. That's basically what it is like, except real install scripts usually contain a bit more information. I have not seen any that are fundamentally more complicated, though. In essence, you just give it a list of what needs to be installed. Sometimes you need to give it some mapping dicts since the source and installed trees might not be the same.

请参阅distutils简单示例。这基本上是它的样子,除了真正的安装脚本通常包含更多的信息。但是,我没有看到任何基本上更复杂的东西。实质上,您只需要列出需要安装的内容。有时你需要给它一些映射dicts,因为源和安装的树可能不一样。

Here is a real-life (anonymized) example:

这是一个现实生活(匿名)的例子:

#!/usr/bin/python 

from distutils.core import setup 

setup (name = 'Initech Package 3', 
          description = "Services and libraries ABC, DEF", 
          author = "That Guy, Initech Ltd", 
          author_email = "that.guy@initech.com", 
          version = '1.0.5', 
          package_dir = {'Package3' : 'site-packages/Package3'}, 
          packages = ['Package3', 'Package3.Queries'], 
          data_files = [ 
                       ('/etc/Package3', ['etc/Package3/ExternalResources.conf']) 
          ])

#2


6  

apt-get install python-stdeb

apt-get install python-stdeb

Python to Debian source package conversion utility

Python到Debian源包转换实用程序

This package provides some tools to produce Debian packages from Python packages via a new distutils command, sdist_dsc. Automatic defaults are provided for the Debian package, but many aspects of the resulting package can be customized via a configuration file.

该软件包提供了一些工具,可以通过新的distutils命令sdist_dsc从Python包生成Debian软件包。为Debian软件包提供了自动默认值,但是可以通过配置文件自定义生成的软件包的许多方面。

  • pypi-install will query the Python Package Index (PyPI) for a package, download it, create a .deb from it, and then install the .deb.
  • pypi-install将查询包的Python包索引(PyPI),下载它,从中创建.deb,然后安装.deb。
  • py2dsc will convert a distutils-built source tarball into a Debian source package.
  • py2dsc会将distutils构建的源代码tarball转换为Debian源代码包。

#3


2  

Most Python programs will use distutils. Django is a one - see http://code.djangoproject.com/svn/django/trunk/setup.py

大多数Python程序都会使用distutils。 Django是一个 - 见http://code.djangoproject.com/svn/django/trunk/setup.py

You should also read the documentation, as it's very comprehensive and has some good examples.

您还应该阅读文档,因为它非常全面并且有一些很好的示例。

#4


2  

I found the following tutorial to be very helpful. It's shorter than the distutils documentation and explains how to setup a typical project step by step.

我发现以下教程非常有用。它比distutils文档更短,并解释了如何逐步设置典型项目。

#5


1  

distutils really isn't all that difficult once you get the hang of it. It's really just a matter of putting in some meta-information (program name, author, version, etc) and then selecting what files you want to include. For example, here's a sample distutils setup.py module from a decently complex python library:

一旦你掌握了它,distutils真的不是那么困难。这只是放入一些元信息(程序名称,作者,版本等),然后选择要包含的文件。例如,这是一个来自一个相当复杂的python库的distutils setup.py模块示例:

Kamaelia setup.py

Kamaelia setup.py

Note that this doesn't deal with any data files or or whatnot, so YMMV.

请注意,这不处理任何数据文件或什么,所以YMMV。

On another note, I agree that the distutils documentation is probably some of python's worst documentation. It is extremely inclusive in some areas, but neglects some really important information in others.

另外,我同意distutils文档可能是python最糟糕的文档。它在某些领域极具包容性,但忽略了其他领域的一些非常重要的信息。

#1


13  

See the distutils simple example. That's basically what it is like, except real install scripts usually contain a bit more information. I have not seen any that are fundamentally more complicated, though. In essence, you just give it a list of what needs to be installed. Sometimes you need to give it some mapping dicts since the source and installed trees might not be the same.

请参阅distutils简单示例。这基本上是它的样子,除了真正的安装脚本通常包含更多的信息。但是,我没有看到任何基本上更复杂的东西。实质上,您只需要列出需要安装的内容。有时你需要给它一些映射dicts,因为源和安装的树可能不一样。

Here is a real-life (anonymized) example:

这是一个现实生活(匿名)的例子:

#!/usr/bin/python 

from distutils.core import setup 

setup (name = 'Initech Package 3', 
          description = "Services and libraries ABC, DEF", 
          author = "That Guy, Initech Ltd", 
          author_email = "that.guy@initech.com", 
          version = '1.0.5', 
          package_dir = {'Package3' : 'site-packages/Package3'}, 
          packages = ['Package3', 'Package3.Queries'], 
          data_files = [ 
                       ('/etc/Package3', ['etc/Package3/ExternalResources.conf']) 
          ])

#2


6  

apt-get install python-stdeb

apt-get install python-stdeb

Python to Debian source package conversion utility

Python到Debian源包转换实用程序

This package provides some tools to produce Debian packages from Python packages via a new distutils command, sdist_dsc. Automatic defaults are provided for the Debian package, but many aspects of the resulting package can be customized via a configuration file.

该软件包提供了一些工具,可以通过新的distutils命令sdist_dsc从Python包生成Debian软件包。为Debian软件包提供了自动默认值,但是可以通过配置文件自定义生成的软件包的许多方面。

  • pypi-install will query the Python Package Index (PyPI) for a package, download it, create a .deb from it, and then install the .deb.
  • pypi-install将查询包的Python包索引(PyPI),下载它,从中创建.deb,然后安装.deb。
  • py2dsc will convert a distutils-built source tarball into a Debian source package.
  • py2dsc会将distutils构建的源代码tarball转换为Debian源代码包。

#3


2  

Most Python programs will use distutils. Django is a one - see http://code.djangoproject.com/svn/django/trunk/setup.py

大多数Python程序都会使用distutils。 Django是一个 - 见http://code.djangoproject.com/svn/django/trunk/setup.py

You should also read the documentation, as it's very comprehensive and has some good examples.

您还应该阅读文档,因为它非常全面并且有一些很好的示例。

#4


2  

I found the following tutorial to be very helpful. It's shorter than the distutils documentation and explains how to setup a typical project step by step.

我发现以下教程非常有用。它比distutils文档更短,并解释了如何逐步设置典型项目。

#5


1  

distutils really isn't all that difficult once you get the hang of it. It's really just a matter of putting in some meta-information (program name, author, version, etc) and then selecting what files you want to include. For example, here's a sample distutils setup.py module from a decently complex python library:

一旦你掌握了它,distutils真的不是那么困难。这只是放入一些元信息(程序名称,作者,版本等),然后选择要包含的文件。例如,这是一个来自一个相当复杂的python库的distutils setup.py模块示例:

Kamaelia setup.py

Kamaelia setup.py

Note that this doesn't deal with any data files or or whatnot, so YMMV.

请注意,这不处理任何数据文件或什么,所以YMMV。

On another note, I agree that the distutils documentation is probably some of python's worst documentation. It is extremely inclusive in some areas, but neglects some really important information in others.

另外,我同意distutils文档可能是python最糟糕的文档。它在某些领域极具包容性,但忽略了其他领域的一些非常重要的信息。