如何使用Python distutils? [英] How to use Python distutils?

查看:136
本文介绍了如何使用Python distutils?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用python编写了一个快速程序,将gtk GUI添加到cli程序.我想知道如何使用distutils创建安装程序.由于它只是命令行应用程序的GUI前端,因此无论如何都只能在* nix中使用,因此我不必担心它是跨平台的.

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.

我的主要目标是为debian/ubuntu用户创建一个.deb软件包,但是我不了解make/configure文件.到目前为止,我主要还是一名Web开发人员.

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.

编辑:有谁知道使用distutils的项目,以便我可以看到它在运行中,并且知道实际上尝试构建它吗?

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

该指南非常有用 .我不知道在最初的咕咕声中我是怎么想念它的.它甚至会引导您打包现有的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

Ubuntu MOTU项目

这是ubuntu上的官方软件包维护项目.任何人都可以加入,并且有很多关于创建包的教程和各种类型的信息,其中包括上面的"python打包指南".

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'.

"Python distutils可以进行调试吗? " -Ars Technica论坛讨论

根据此对话,您不能只使用distutils.它不遵循debian打包格式(或类似的格式).我想这就是为什么您需要dh_make的原因,如《 Ubuntu包装指南》中所述

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的bdist_deb命令

这个问题有一些有趣的讨论(也是我找到ubuntu指南的方法),关于串联一个zip文件和一个shell脚本以创建某种通用可执行文件(包括python和bash的任何东西).奇怪的.让我知道是否有人因为我从未听说过这种做法而获得更多信息.

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.

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

推荐答案

请参见 distutils简单的例子.基本上就是这样,只是实际的安装脚本通常包含更多信息.不过,我还没有看到任何根本上更复杂的东西.本质上,您只需要给它列出需要安装的内容.有时您需要给它一些映射命令,因为源树和安装的树可能不相同.

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.

这是一个真实的例子(匿名):

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']) 
          ])

这篇关于如何使用Python distutils?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆