如何在python项目包装中包含一个单独的子目录?

问题描述

我有一个组织如下的Python项目:

foo -
    |
    |--foo/
    |    |
    |    |--first.py
    |    |--second.py
    |    |--...
    |--README
    |--requirements.txt
    |--scripts/
    |        |
    |        |-script1.sh
    |        |-script2.py
    |--docker/
    |       |
    |       |--compose_files/
    |       |              |
    |       |              |-first.yml
    |       |              |-second.yml
    |       |              |-files/
    |       |                    |
    |       |                    |-some text files...
    |       |-dockerfiles/
    |                   |
    |                   |-some other files...
    |--service.py
    |--setup.py

打包需要此处的所有文件包括docker/中的文件。但是认情况下,运行setup.py仅打包foo/scripts/。为了包括docker/,我在这里提出了建议:yaml file not getting copied when installing from setup.pyHow to include docs directory in python distribution。我做了recursive-include docker *,可以在python setup.py sdist输出中看到docker子目录。

但是我将其上传到testPyPi并通过pip重新安装后,docker/中没有venv/lib/python3.6/site-packages。由于docker是要求之一,因此我认为可以通过在其中安装docker来覆盖它。

然后,我将docker/重命名docker-internal/,并验证它是否显示python setup.py sdist输出中。但是,再次将其上传到testPyPi并重新安装后,docker-internal/丢失了。

有人知道这里发生了什么吗?如何使这些文件显示venv/lib/python3.6/site-packages中?

setup.py的外观如下:

setup(
    name='foo',version=VERSION_NUM,description='some text',long_description=(
        'some longer text'
    ),url='our website url',author='yibol',author_email='',license='Apache License 2.0',keywords='',packages=find_packages(exclude=["tests*"]),classifiers=[
        "Programming Language :: Python :: 3 :: Only","Programming Language :: Python :: 3.6","License :: OSI Approved :: Apache Software License",],py_modules=['service'],python_requires='~=3.6',cmdclass={'install': Install},include_package_data=True,install_requires=get_requirements('requirements.txt'),entry_points={
        'console_scripts': [
            'a list of commands and corresponding modules',]
    },zip_safe=False,)

setup.cfg不包含任何相关信息。我注意到有一个pyvenv.cfg,其中包含以下内容

home = /Library/Frameworks/Python.framework/Versions/3.6/bin
include-system-site-packages = false
version = 3.6.0

非常感谢您!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)