GeezerVison is showing github.com — Fix `src` module name (`src` -> `pythonturtle`) · Issue #106 · PythonTurtle/PythonTurtle
Fix src module name (src -> pythonturtle) #106DescriptionAs explained in PR #105, the module name of this software is regarded to be src from Python's point of view.
It probably makes sense to make it be pythonturtle or similar. We shall introduce a standard layout for stand-alone applications (e.g. a __main__ module in the module root, or so -- see related StackOverflow answer).
This might also play into packaging a Windows installer (not sure what the current build process for Windows depends on). There was an interesting talk on the current state of building self-contained installers with Python at this year's Python Italy (FYI, related question on SlackOverflow). Activitycool-RR commented on Sep 18, 2018 I looked into the homedirectory module. I haven't looked at that code in around a decade so I had no memory of it. It's terrible. There's no reason to do that. There should just be a package python_turtle and then relative imports inside of it. Let me know if you need any guidance. bittner commented on Sep 18, 2018
Let me know if you need any guidance.
If you want to tackle that ... that would be cool. 👍 cool-RR commented on Sep 19, 2018 I experimented a little with __main__ now. It's a good idea, but there are a couple of things I don't like:
-
You can't use imports in a sane way from within it. I tried both relative imports and importing the package by name, and neither work. I'm not sure what's the rationale behind this. I looked for a PEP and couldn't find one.
-
There isn't a Python file you could just put a shebang on and run directly instead of invoking python pythonturtle.
So my preference is this: Change the src directory to be python_turtle, and add a file run_python_turtle.py that imports python_turtle and runs a function start() in it that starts the GUI. cool-RR commented on Sep 19, 2018 Okay, so I just loaded PythonTurtle into my IDE after almost a decade of not running it... And now I realize how much work it's going to take to get it running normally. I never tried running it under Python 3. I don't want to spend time on it. I can help you with words but I don't want to be coding.
If you'd like to do a __main__.py file despite of my opinion, you can go ahead and do that. bittner commented on Sep 19, 2018 Totally fine. 😄
At least you can truly appreciate my efforts! 😆
And yes, __main__ is awesome! You can run python -m python_turtle with it. You can run it as a ZIP file with python python_turtle.zip. You can run it as python python_turtle/. And it's a natural starting point to jump in when you see a __main__.py file in a directory of a Python project.
We'll get the relative efforts fixed in a sane way soon. I'm not a fan of using the full module path, but we'll see. It would have been all easier with zero complaints fromflake8 and pylint, but that doesn't look feasible at the moment. bittner commented on Sep 19, 2018 ... ah, and we'll get a /usr/local/bin/python_turtle script (with a shebang line) installed on target systems, so we're all set. 😃 cool-RR commented on Sep 19, 2018 cool-RR commented on Sep 19, 2018 I did a few more experiments with __main__.py. Once you use python -m python_turtle, you can import the package by name from __main__.py, and then from any package files you can do both relative imports and importing by full name (e.g. import python_turtle.whatever)
So I'm happy with using __main__.py :) bittner commented on Sep 29, 2018
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|