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

查看:22
本文介绍了如何使用 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 文件.到目前为止,我主要是一名网络开发人员.

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?

本指南非常很有帮助.我不知道在最初的 gooling 浪潮中我是怎么错过的.它甚至会引导您打包现有的 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 到 deb?"- 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 simple示例.基本上就是这样,除了真正的安装脚本通常包含更多信息.不过,我还没有看到任何从根本上更复杂的东西.本质上,你只是给它一个需要安装的列表.有时你需要给它一些映射字典,因为源树和安装的树可能不一样.

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