Python distutils - 有没有人知道如何使用它? [英] Python distutils - does anyone know how to use it?

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

问题描述

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



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



感谢您的帮助!



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



这是一个很少有用的链接




  • Ubuntu Python包装指南



    本指南是 非常 有帮助。我不知道在我初期的暴风雨中我怎么错过了。它甚至引导您打包一个现有的python应用程序


  • Ubuntu MOTU项目



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


  • Python distutils to deb? - Ars Technica论坛讨论



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


  • 用于distutils的bdist_deb命令



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


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



解决方案

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



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

 #!/ usr / bin / python 

from distutils.core import setup

setup(name ='Initech Package 3',
description =服务和库ABC,DEF,
author =那个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'])
])


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.

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.

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?

Here are a few useful links

  • Ubuntu Python Packaging Guide

    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

  • The Ubuntu MOTU Project

    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 to deb?" - Ars Technica Forum discussion

    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

  • "A bdist_deb command for distutils

    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.

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

解决方案

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天全站免登陆