Consider a very simple setup.py:
from setuptools import setup, find_packages
print('WAAAAAAAAA') # executed twice!
setup(
    name="foo",
    version="190425",
    description="bar",
    author="Developers",
    author_email="[email protected]",
    install_requires=["pyzmq", "pybullet"],
    packages=find_packages(),
)
Why exactly is the module loaded twice when running pip install . -v and what can I do to guard the code so it runs only once per invocation of pip, just like setup()?
The answer turns out to be that pip install . executes setup.py twice (the verbose output actually says it) since it executes the egg_info subcommand and then the install subcommand. 
A possible solution is to check if sys.argv[1] == 'install' and only then execute whatever is desired.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With