【问题标题】:Add other files in Python distribution在 Python 发行版中添加其他文件
【发布时间】:2021-07-17 13:52:06
【问题描述】:

我正在开发一个项目,我必须将其作为独立 SDK 与我的团队共享。由于某些原因,我的分发文件中没有添加 *.py 以外的文件

我的项目结构如下所示

我的Setup.py是这样的

import setuptools
from glob import glob
from os.path import basename
from os.path import splitext

with open("README.md", "r") as fh:
    long_description = fh.read()

with open('requirements.txt') as f:
    install_requires = f.read().splitlines()[2:]

with open('requirements-dev.txt') as f:
    tests_require = f.read().splitlines()[2:]

extras = {
    'test': tests_require,
}

setuptools.setup(
    name='eu-taxonomy-sdk',
    version='0.0.2',
    author='Bhushan Fegade',
    author_email='bhushan.fegade@morningtar.com',
    description='a calculation library for eu-taxonomy',
    long_description=long_description,
    long_description_content_type='text/markdown',
    url='https://msstash.morningstar.com/scm/dataapi/eu-taxonomy-sdk.git',
    packages=setuptools.find_packages(where='src'),
    package_dir={'': 'src'},
    package_data={'eu-taxonomy-sdk': [ 'config/*', 'category/config/*' ]},
    py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')],
    license='Apache Software License',
    classifiers=[
        'Programming Language :: Python :: 3',
        'License :: OSI Approved :: Apache Software License',
        'Operating System :: OS Independent',
    ],
    install_requires=install_requires,
    python_requires='~=3.8',
    tests_require=tests_require,
    extras_require=extras,
    test_suite='tests'
)

我正在使用以下命令生成可分发文件

python setup.py build
python setup.py sdist

我尝试在setup.py 文件中进行一些更改,但config 文件夹内的可分发文件始终为空,只有 init.py 文件,没有其他文件存在。

我想知道是否有办法将其他文件(CSV、parq)保留在最终的可分发文件中。

【问题讨论】:

    标签: python packaging python-packaging


    【解决方案1】:

    添加描述您需要包含的文件的a MANIFEST.in file

    例如

    recursive-include src *.csv *.parq
    

    【讨论】:

      猜你喜欢
      • 2021-04-15
      • 2015-02-23
      • 1970-01-01
      • 1970-01-01
      • 2018-07-27
      • 2015-12-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多