Running the .py file before building setup.py

I create setup.py with easyinstall and I need to execute a specific py file in the same project before the build is complete. I tried setup_requires and ext_modules, but both of them can't seem to call the python file in the same project.

+4
source share
1 answer

The following code creates a new build command that calls your own custom function before passing it to the original build command. RunYourOtherScript() forward RunYourOtherScript() means you want to run before build happens. This can be an execfile('src/something.py') call execfile('src/something.py') or preferably a relative import and function call.

 from distutils.command import build as build_module class build(build_module.build): def run(self): RunYourOtherScript() build_module.build.run(self) setup( ... cmdclass = { 'build': build, }, ) 
+5
source

Source: https://habr.com/ru/post/1390551/


All Articles