【问题标题】:Python packaging: exclude directory from bdist_wheelPython 打包:从 bdist_wheel 中排除目录
【发布时间】:2017-09-08 00:29:34
【问题描述】:

我的项目结构如下:

.
├── docs
├── examples
├── MANIFEST.in
├── README.rst
├── setup.cfg
├── setup.py
└── myproject

我想将我的项目捆绑到一个轮子中。为此,我使用以下setup.py

#!/usr/bin/env python

from setuptools import setup, find_packages

setup(name='myproject',
      version='1.0',
      description='Great project'
      long_description=open('README.rst').read(),
      author='Myself'
      packages=find_packages(exclude=['tests','test','examples'])
     )

运行python setup.py bdist_wheel 时,examples 目录包含在轮子中。如何防止这种情况发生?

根据

Excluding a top-level directory from a setuptools package

我希望examples 被排除在外。

【问题讨论】:

  • 尝试将examples/ 添加到.gitignore。也许你应该添加setup(..., include_package_data=True, ...)
  • 我不想从存储库中排除示例/。另外,我为什么要包含_package_data?这和我的问题有关吗?

标签: python setuptools python-wheel


【解决方案1】:

我通过使用后缀星号examples* 解决了这个问题,即:

find_packages(exclude=['*tests','examples*'])

(请注意,我在写'*tests' 时带有一个前导星,因为我在每个代码包中都有测试包,如myproject.mypackage.tests。不知何故,如果已经有前缀星号,则后缀星号似乎是不必要的)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-11-03
    • 2021-03-05
    • 2015-07-30
    • 2010-10-11
    • 2021-11-22
    • 2014-09-29
    • 2020-03-05
    • 1970-01-01
    相关资源
    最近更新 更多