2017-10-24 6 views
0

sdist/wheelで作成したパッケージにファイルを生成してインクルードする方法を探しています。sdistのファイルを生成する

ビルド中にピックアップされる新しいファイルを作成するプロセスにフックする方法はありますか?

答えて

1

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.pypackage_dataと記載してください。 https://docs.python.org/3/distutils/setupscript.html#installing-package-data

setup(..., 
     packages=['mypkg'], 
     package_data={'mypkg': ['*.dat']}, 
    ) 
関連する問題