分发Python软件包时bdist vs sdist的行为不一致 [英] Inconsistent behaviour of bdist vs sdist when distributing a Python package

查看:125
本文介绍了分发Python软件包时bdist vs sdist的行为不一致的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有以下结构的大项目。 实用程序是小模块的集合,这些小模块可在不同地方被 big_project project1 ,2等的不同组件重用。

I have a big project with the following structure. utilities is a collections of small modules that are reused in various places by the different components of the big_project, project1, 2, etc.

big_project/
|-- __init__.py
|-- utilities/        
    |-- mod1.py
    |-- mod2.py
|-- project1/
    |-- setup.py
    |-- __init__.py
    |-- src/
        |-- __init__.py
        |-- mod1.py
        |-- mod2.py
    |-- examples/
        |-- __init__.py
        |-- mod.py
|-- project2/
   |-- ...
|-- project3/
   |-- ...

我想分发 project1 ,包括公用事业(因为我不想单独分发实用程序)。分布式软件包将具有以下结构:

I want to distribute project1, including utilities (because I don't want to distribute utilities separately). The distributed package would have the following structures:

project1/
    |-- utilities/
    |-- src/
    |-- examples/

project1 / setup.py 看起来像这样:

setup(
    name = 'project1',
    packages = ['project1.utilities', 'project1.src', 'project1.examples'],
    package_dir = {'project1.utilities': '../utilities/',
                   'project1.src': 'src',
                   'project1.examples': 'examples'}
     )

问题: python setup.py bdist 生成具有正确结构的分布,但是 python setup.py sdist 不会:

The problem: python setup.py bdist produces a distribution with the right structure, but python setup.py sdist doesn't:

bdist project1-0.1.linux-x86_64的内容.tar.gz

    /./usr/local/lib/python2.7/site-packages/
        |-- project1/
            |-- utilities
            |-- src
            |-- examples

sdist project1-0.1.tar.gz的内容

    project1/
        |-- src/
        |-- examples/

因此sdist忽略了实用程序模块,而bdist将其包含在正确的位置。为什么?

So sdist left out the utilities module, whereas bdist included it at the correct location. Why?

如果有人想看看真实的项目: https://testpypi.python.org/pypi/microscopy ,其中bsdist和sdist存档均可用。

If anyone wants to look at the real project: https://testpypi.python.org/pypi/microscopy where both the bsdist and sdist archives are available.

setuptools和distutils都产生同样的结果。因为该项目是纯Python,所以我宁愿使用sdist ...

Both setuptools and distutils produce the same result. Because the project is pure Python, I'd rather use sdist...

推荐答案

我建议更新您的MANIFEST.in文件包括实用程序文件夹

例如递归包括../utilities *

I suggest to update your MANIFEST.in file to include utilities folder
e.g. recursive-include ../utilities *

这篇关于分发Python软件包时bdist vs sdist的行为不一致的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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