[Qt-creator] Dealing with python projects
Jason H
jhihn at gmx.com
Thu Apr 25 16:59:58 CEST 2019
> Thanks for your feedback Chris, and Jason,
> hopefully you can help QtCreator to improve on the Python support.
> I will be more than happy to review your patches.
I'm not sure if you saw my previous suggestions, but for thoroughness:
1. I need something that either uses a conventional entry point or allows me to specify it. (like -e for c compiler)
2. Something that uses Python 3. Yes I know Mac only ships with Python 2, but Python 2 is coming to an end in 7 months.
3. Something that allows me to use the shebang #!/... to specify an interpreter. In particular, /usr/bin/env is good at picking one, i.e. /usr/bin/env python3, which sidesteps the hard-coding of the binary to a specific path and picks it up from the user's environment.
4. Unfortunately all python projects will be called "main" in the project explorer. Maybe the entry point should be $1.py where $1 is the name of the project and/or directory?
There is lack of clarity on what the proper python project file format is. I wonder why the existing C++ infrastructure can't be re-used? The differences (as I currently understand them):
1. No compiler - this is just a no-op.
2. The C convention entrypoint of main() is not present, therefore we need to specify it. (i.e. either use -e main like for clang or PYTHON_ENTRYPOINT=main.py) Python scripts often also have a library/main test:
if __name__== '__main__':
pass # I am the entry script, parse sys.argv, etc. (great for testing)
else:
pass # I am invoked as a library providing functions
Also entry points usually executable and have a shebang, though this is not needed.
3. SOURCES should be .py files and merged with DISTFILES for copy into the build dir. HEADERS can be ignored?
Questions:
1. Maybe there can be a pythtondeployqt?
2. Could we have a mixed-mode project where some C/C++ is built along with the python? Python Extending is a thing (https://docs.python.org/3/extending/index.html) Not sure if Qt provides Python helpers like Qt Android JNI helpers for calling functions and workin with Java Objects?
More information about the Qt-creator
mailing list