I need my setup.py
to call a function in another file. I know this can be done by settings a cmdclass
such as:
import my_module
class Install(_install):
def run(self):
_install.run(self)
my_module.do_stuff()
setup(name='foo',
cmdclass={'install': Install},
)
But I'm using tox, which doesn't seem to accept imports from setup.py
(it just says module can't be found).
To make tox run, I could just put this in the tox.ini
instead:
commands = path_to_my_module.py
and it will run it just fine.
Problem
How can I make my setup.py
call my function without tox complaining about it?
tox
creates a virtualenv and installs your module into it. Because dependencies are listed in setup.py
, they will not be installed until after setup.py
is called to determine what they are. So at the time that setup.py
first executes, nothing is installed in your shiny new virtualenv.
Look into using the deps
configuration option in tox.ini
as those packages will be installed before the one under test, according to the docs https://testrun.org/tox/latest/config.html