I'm looking for a way to generate and include a file into the package created by sdist
/wheel
.
Is there some way to hook into the process to create a new file that will be picked up during the build.
I'm looking for a way to generate and include a file into the package created by sdist
/wheel
.
Is there some way to hook into the process to create a new file that will be picked up during the build.
To build a file during build
phase override cmdclass
. See 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})
To include a non-code file in a sdist
list in in MANIFEST
or MANIFEST.in
. See https://docs.python.org/3/distutils/sourcedist.html#specifying-the-files-to-distribute
To include a non-code file in a wheel
list it as package_data
in your setup.py
. See https://docs.python.org/3/distutils/setupscript.html#installing-package-data:
setup(...,
packages=['mypkg'],
package_data={'mypkg': ['*.dat']},
)