-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Support for custom commands and functions #265
Description
Hello,
When using setup.py, it is possible to customize commands or use functions to get some results dynamically.
For instance, to run a post install script (that requires dependencies to be installed) one can write this:
class CustomInstallCommand(install):
def _post_install(self):
# Some stuff to do
def __init__(self, *args, **kwargs):
super(CustomInstallCommand, self).__init__(*args, **kwargs)
atexit.register(self._post_install)
and use this class as keyword argument value in the setup() call:
cmdclass={'install': CustomInstallCommand}
(other commands like clean, test, tox can be customized this way too).
Second example, in order to compile translation files (po files) into mo files at setup time:
def create_mo_files():
data_files = []
# do stuff
return data_files
and use the result as keyword argument value in the setup() call:
data_files=create_mo_files()
It looks quite obvious that it's not possible to do such things if one uses only a pyproject.toml file: how would it import a class or a function, or know about it, how to run it? (Or is there a way?)
From reading the code, I've seen that the keyword arguments list passed to setup() is hard coded (to build a sdist), so cmdclass and data_files are not usable at the moment (if I'm not wrong).
I guess this is not the easiest feature to implement. Is it planned or already discussed?