如何将原始Python包上传到PyPI? [英] How to upload a pristine Python package to PyPI?

查看:88
本文介绍了如何将原始Python包上传到PyPI?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将包上传到PyPI的神奇"python setup.py some_incantation_here"命令是什么,可以下载该包以将其原始格式保存为原始包?

What's the magic "python setup.py some_incantation_here" command to upload a package to PyPI, in a form that can be downloaded to get the original package in its original form?

我有一个带有一些源和一些图像文件的软件包(作为package_data).如果我执行"setup.py sdist register upload",则.tar.gz排除了图像文件.如果我执行"setup.py bdist_egg register upload",则该鸡蛋包含图像,但不包含setup.py文件.我希望能够上传的文件只是我的整个项目,也就是"setup.py the_whole_freaking_thing register upload".

I have a package with some source and a few image files (as package_data). If I do "setup.py sdist register upload", the .tar.gz has the image files excluded. If I do "setup.py bdist_egg register upload", the egg contains the images but excludes the setup.py file. I want to be able to get a file uploaded that is just the entirety of my project -- aka "setup.py the_whole_freaking_thing register upload".

也许最好的方法是手动tar.gz我的项目目录并使用PyPI Web界面上载它?

Perhaps the best way to do this is to manually tar.gz my project directory and upload it using the PyPI web interface?

注意:我试图避免将我刚刚创建的简单项目存储在SVN存储库以及PyPI中-在两个地方跟踪其历史记录和文件似乎很浪费工作.

Caveat: I'm trying to avoid having to store a simple project I just created in my SVN repo as well as on PyPI -- it seems like a waste of work to keep track of its history and files in two places.

推荐答案

执行"sdist"命令时,控制包含文件列表的是位于"setup.py"旁边的"MANIFEST.in"文件,而不是您在"package_data"中列出的任何内容.这与当今的Python打包解决方案的精神分裂性有关. "sdist"由标准库中的 distutils 提供支持,而"bdist_egg"由 setuptools 模块控制.

When you perform an "sdist" command, then what controls the list of included files is your "MANIFEST.in" file sitting next to "setup.py", not whatever you have listed in "package_data". This has something to do with the schizophrenic nature of the Python packaging solutions today; "sdist" is powered by the distutils in the standard library, while "bdist_egg" is controlled by the setuptools module.

要解决此问题,请尝试在setup.py文件旁边创建一个MANIFEST.in,并为其提供以下内容:

To solve the problem, try creating a MANIFEST.in next to your setup.py file, and give it contents like this:

include *.jpg

当然,我想像的是,您的图像文件"是实际的图片,而不是磁盘映像或ISO映像等;如果我猜错了,您可能需要调整上面的行!但是请查看指定要分发的文件 distutils文档部分,查看是否无法在.tar.gz源代码发行版中显示这些文件!祝你好运.

Of course, I'm imaging that your "image files" are actual pictures rather than disk images or ISO images or something; you might have to adjust the above line if I've guessed wrong! But check out the Specifying which files to distribute section of the distutils docs, and see whether you can't get those files appearing in your .tar.gz source distribution! Good luck.

这篇关于如何将原始Python包上传到PyPI?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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