我正在寻找一种方法来生成一个文件并将其包含到由sdist/wheel创建的包中。
有没有什么方法可以连接到这个过程来创建一个新的文件,这个文件将在构建过程中被拾取。
发布于 2017-10-24 19:44:58
在build阶段覆盖cmdclass期间构建文件。请参阅https://stackoverflow.com/a/43728788/7976758
import distutils.command.build
# Override build command
class BuildCommand(distutils.command.build.build):
def run(self):
# Run the original build command
distutils.command.build.build.run(self)
# Custom build stuff goes here
# Replace the build command with ours
setup(...,
cmdclass={"build": BuildCommand})在MANIFEST或MANIFEST.in中的sdist列表中包含非代码文件。请参阅https://docs.python.org/3/distutils/sourcedist.html#specifying-the-files-to-distribute
要在wheel中包含非代码文件,请在setup.py中将其列为package_data。请参阅https://docs.python.org/3/distutils/setupscript.html#installing-package-data
setup(...,
packages=['mypkg'],
package_data={'mypkg': ['*.dat']},
)https://stackoverflow.com/questions/46908392
复制相似问题