Hello folks who know about the python script construction :) The pattern used in all of the python scripts under swig/python/gdal-utils is foreign to me. Can someone explain what's going on and why it's used? (or point to where this has been explored already).
if __name__ == '__main__': sys.exit(main(sys.argv)) Gdal utils .py all end with the block above. Everything else I've used to this point are more like: if __name__ == '__main__': main(sys.argv) The motivation for asking (besides just being curious about something new!) is that I'm trying to figure out how we can use pip to create standard launch wrappers in PYTHONHOME\Scripts instead of manual post-install setup of the batch files we use now. When I change setup.py to do this via console_scripts the resulting wrappers fail on this main construct. So I need to understand what the original intent is to try and come up with a remedy. ``` ยป gdal_edit fooo Traceback (most recent call last): File "C:\Users\Matt\.conda\envs\gdal\Scripts\gdal_edit-script.py", line 33, in <module> sys.exit(load_entry_point('gdal-utils', 'console_scripts', 'gdal_edit')()) TypeError: main() missing 1 required positional argument: 'argv' ``` Thanks! Matt
_______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev