首页 > 解决方案 > Python:如何将一个自定义包添加到另一个自定义包中?

问题描述

我有两个包,main_package 和 sub_package。两者都已打包到轮文件中。我想将 sub_package 捆绑到 main_package 中,以便在安装 main_package 时也安装 sub_package。

我的 setup.py 文件看起来像这样

import setuptools

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

setuptools.setup(
    name="main-package",
    version="0.0.1",
    author="author",
    author_email="author@example.com",
    description="Package 1",
    long_description=long_description,
    long_description_content_type="text/markdown",
    url="https://github.com/pypa/sampleproject",
    packages=setuptools.find_packages()
    install_requires=[
        'sub_package'
    ],
    include_package_data=True
)

如何将 sub_package 添加到 main_package 以便在执行 pip install main_package.whl 时也安装 sub_package?

标签: pythonpython-packaging

解决方案


推荐阅读