Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/359.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 为sdist生成文件_Python_Setuptools - Fatal编程技术网

Python 为sdist生成文件

Python 为sdist生成文件,python,setuptools,Python,Setuptools,我正在寻找一种方法来生成一个文件,并将其包含到由sdist/wheel创建的包中 是否有某种方法可以连接到创建新文件的过程中,该文件将在生成过程中拾取。在生成过程中生成文件阶段覆盖cmdclass。见: 将非代码文件包括在MANIFEST或MANIFEST.in中的sdist列表中。看 要将非代码文件包括在控制盘中请在setup.py中将其列为package\u data。见: import distutils.command.build # Override build command cl

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


是否有某种方法可以连接到创建新文件的过程中,该文件将在生成过程中拾取。

生成过程中生成文件
阶段覆盖
cmdclass
。见:

将非代码文件包括在
MANIFEST
MANIFEST.in
中的
sdist
列表中。看

要将非代码文件包括在
控制盘中
请在
setup.py
中将其列为
package\u data
。见:

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})
setup(...,
      packages=['mypkg'],
      package_data={'mypkg': ['*.dat']},
      )