问题
I want to force a script to be run with python -S, I'm defining the script using entry_points in the setup.py. Is there an option for this?
Thanks!
回答1:
I don't think there is such option in setuptools. You could create a stub script and specify it in the scripts
distutils option instead. Bases on Is it possible to set the python -O (optimize) flag within a script?:
#!/usr/bin/env python
from your_package.script import main
if __name__=="__main__":
import os, sys
sentinel_option = '--dont-add-no-site-option'
if sentinel_option not in sys.argv:
sys.argv.append(sentinel_option)
os.execl(sys.executable, sys.executable, '-S', *sys.argv)
else:
sys.argv.remove(sentinel_option)
main()
来源:https://stackoverflow.com/questions/12965426/force-options-to-python-interpretion-with-commands-defined-using-entry-points