首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为sdist生成文件

为sdist生成文件
EN

Stack Overflow用户
提问于 2017-10-24 18:41:33
回答 1查看 233关注 0票数 1

我正在寻找一种方法来生成一个文件并将其包含到由sdist/wheel创建的包中。

有没有什么方法可以连接到这个过程来创建一个新的文件,这个文件将在构建过程中被拾取。

EN

回答 1

Stack Overflow用户

发布于 2017-10-24 19:44:58

build阶段覆盖cmdclass期间构建文件。请参阅https://stackoverflow.com/a/43728788/7976758

代码语言:javascript
复制
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})

MANIFESTMANIFEST.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

代码语言:javascript
复制
setup(...,
      packages=['mypkg'],
      package_data={'mypkg': ['*.dat']},
      )
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46908392

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档