This is a comment on this post that does not fit into the space allotted for comments.
Note that a package use case may arise inside setup.py . For example, generating ply parser ply and saving them to disk. These tables must be generated before running setuptools.setup , as they must be copied to site_packages along with the installed package.
There is the setup_requires option setuptools.setup , however this does not install packages.
Thus, the dependency that is required for both the installation process and the installed package will not be installed in this way.
Placing such a dependency inside install_requires does not always work as expected . Even if this worked, you would need to pass some setuptools.setup function, which should be performed between installing dependencies in setup_requires and installing the package itself. This approach is nested and therefore against PEP 20 .
So, the remaining two flat approaches:
run setup.py twice, either automatically (preferably) or manually (by notifying the user that the tables could not be created before setuptools.setup .
first call pip (or other equivalent solution) to install the necessary dependencies. Then proceed to create the tables (or whatever the task before installation is necessary) and call setuptools.setup last.
Personally, I prefer No.2 because No.2 can mislead the user watching the console exit during installation if they no longer know the intention to call setuptools.setup twice.
In addition, any rights necessary for installation (for example, root, if necessary) are always present when running setup.py (and just then). Thus, setup.py can be seen as a βcanonicalβ use case for this type of action.
source share