New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pip-compile fails if setup.py contains the if __name__ == __main__ #1278
Comments
Couldn't reproduce it locally: # setup.py
from setuptools import setup
if __name__ == "__main__":
print('main')
setup(name='foo', version='0.1', install_requires=['six']) $ pip-compile setup.py
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile setup.py
#
six==1.15.0
# via foo (setup.py) |
IIUC, I believe the scenario would be more like: # setup.py
from setuptools import setup
if __name__ == "__main__":
setup(name='foo', version='0.1', install_requires=['six']) Which makes sense that Perhaps it would make sense to document this gotcha, but I don't think a code change in pip-tools is required. |
Considering that the if not possible, pip-tools should fail with a clear message that includes a hint that explains that removing the construct should make it work. |
Agreed, asking the users to dump the best practice sounds wrong. As for the trick, it should be possible to do the same sort of eval setuptools do. Also, there's https://github.com/jaraco/jaraco.packaging that may have some useful recipes. |
Fixed in #1311. Thanks for the issue! |
pip-compile will display an tracedump if setup.py contains the code such:
That may be problematic as this construct is quite popular: https://github.com/search?q=%22if+__name__%22+filename%3Asetup.py+path%3A%2F&type=Code&ref=advsearch&l=&l=
The text was updated successfully, but these errors were encountered: