Clean way to generate data file from setup.py stored at the root of the package #4835
Unanswered
VincentDary
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
My
setup.py
generates data files during the build of a package (viapython -m build
orpip install -e
), and store these files at the root of the package in a directory namedthird_party
.To achieve this result, the project uses a
MANIFEST.in
withinclude
directives which references all the future built files. And, the generation code is located in thesetup.py
in a subclasse ofsetuptools.command.egg_info.egg_info
in the override methodrun()
, the command is register via thecmdclass
argument ofsetuptools.setup
. I put my generation function in this method because this is the cleanest way I found to have my generated data file produced before theMANIFEST.in
is analysed.This work perfectly but there is a side effect,
setuptools.command.egg_info.egg_info.run
is called four times in: 1) sdist build dependency, 2) sdist build, 3) wheel build dependency and 4) wheel build. To avoid the data file generation to be relaunched the generation function check if a file artifact is present on the filesystem.I think my hack is bit dirty, there is a better way to achieve my goal in order to have a generation step call only one time before
MANIFEST.in
analysis ? Any code sample ?Of course, I have read the following discussions carefully before publishing my answer.
Beta Was this translation helpful? Give feedback.
All reactions