Search code examples
pythonsetuptoolsdistutils

How to perform custom build steps in setup.py?


The distutils module allows to include and install resource files together with Python modules. How to properly include them if resource files should be generated during a building process?

For example, the project is a web application which contains CoffeeScript sources that should be compiled into JavaScript and included in a Python package then. Is there a way to integrate this into a normal sdist/bdist process?


Solution

  • The best way would be to write a custom build_coffeescript command and make it a subcommand of build. More details are given in other replies to similar/duplicate questions, for example this one:

    https://stackoverflow.com/a/1321345/150999