python - `setup.py sdist` 是如何工作的?

标签 python distutils

我正在尝试使用 setup.py sdist 对我的项目进行源代码分发。我已经有了可以安装的正常运行的 setup.py。但是当我执行 sdist 时,我得到的只是 my_project 文件夹中的另一个 my_project 文件夹,一个 MANIFEST 文件我对包含两个文本文件的 zip 文件不感兴趣,而不是我的项目。

我做错了什么? sdist 的文档在哪里?

更新:

这是我的setup.py:

#!/usr/bin/env python

import os
from distutils.core import setup
import distutils
from general_misc import package_finder

try:
    distutils.dir_util.remove_tree('build', verbose=True)
except:
    pass

my_long_description = \
'''\
GarlicSim is a platform for writing, running and analyzing simulations. It can
handle any kind of simulation: Physics, game theory, epidemic spread,
electronics, etc.
'''

my_packages = package_finder.get_packages('', include_self=True,
                                          recursive=True)

setup(
    name='GarlicSim',
    version='0.1',
    description='A Pythonic framework for working with simulations',
    author='Ram Rachum',
    author_email='cool-rr@cool-rr.com',
    url='http://garlicsim.org',
    packages=my_packages,
    package_dir={'': '..'},
    license= "LGPL 2.1 License",
    long_description = my_long_description,

)

try:
    distutils.dir_util.remove_tree('build', verbose=True)
except:
    pass

最佳答案

Tarek Ziade 在 this article 中解释了这一点以及相关的软件打包工具。 (已损坏 original link)称为用 Python 编写程序包。

基本上,它通过以下方式创建一个简单的包 创建一个发布树,其中复制运行包所需的一切。然后将这棵树归档在一个或多个归档文件中(通常,它只创建一个 tar 包)。存档基本上是源代码树的副本。

关于python - `setup.py sdist` 是如何工作的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1614086/

相关文章:

python - 将 lxml 安装到 virtualenv

python - Pandas Merge (pd.merge) 如何设置索引和join

python - 带有 setuptools 的 Python 包的名称格式

python - 在 setup.py 中包含 logging.conf?

python - 尝试构建基本的 python 扩展示例失败 (windows)

python - 用于安装 PyPi 的 Helm 图表?

python - 如何只导入python中的类方法

Python 没有正确更新

python - DistutilsOptionError : must supply either home or prefix/exec-prefix -- not both

python "setup.py develop": is it possible to create ".egg-info" folder not in source code folder?