Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I run a Makefile in setup.py?

I need to compile ICU using it's own build mechanism. Therefore the question:

How can I run a Makefile from setup.py? Obviously, I only want it to run during the build process, not while installing.

like image 881
Georg Schölly Avatar asked Nov 18 '09 10:11

Georg Schölly


People also ask

Can we use MakeFile for Python?

Even though Python is regarded as an interpreted language and the files need not be compiled separately, many developers are unaware that you can still use make to automate different parts of developing a Python project, like running tests, cleaning builds, and installing dependencies.

Is setup py outdated?

py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. I found a very detailed write-up explaining this issue: "Why you shouldn't invoke setup.py directly" (October 2021).


1 Answers

The method I normally use is to override the command in question:

from distutils.command.install import install as DistutilsInstall  class MyInstall(DistutilsInstall):     def run(self):         do_pre_install_stuff()         DistutilsInstall.run(self)         do_post_install_stuff()  ...  setup(..., cmdclass={'install': MyInstall}, ...) 

This took me quite a while to figure out from the distutils documentation and source, so I hope it saves you the pain.

Note: you can also use this cmdclass parameter to add new commands.

like image 105
Walter Avatar answered Oct 02 '22 15:10

Walter