首页 > 解决方案 > 仅在开发模式下排除 setup.py 中的文件

问题描述

我想在运行时排除文件,pip install mypackage但在使用pip install -e mypackage.

我设法做到了,但不仅仅是为了开发安装。这是我的setup.py

import fnmatch
from setuptools import find_packages
from setuptools import setup
from setuptools.command.build_py import build_py as build_py_orig

excluded_files = ["myfiles.."]
class build_py(build_py_orig):
    def find_package_modules(self, package, package_dir):
        modules = super().find_package_modules(package, package_dir)
        return [
            (pkg, mod, file)
            for (pkg, mod, file) in modules
            if not any(fnmatch.fnmatchcase(file, pat=pattern) for pattern in excluded_files)
        ]

setup(
    name="tvmodels",
    packages=find_packages(),
    cmdclass={'build_py': build_py},
    install_requires=["myrequirements"],
    description="...",
)

知道我该怎么做吗?

标签: pythonsetuptools

解决方案


推荐阅读