Skip to content
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

Fix src module name (src -> pythonturtle) #106

Closed
bittner opened this issue Sep 17, 2018 · 9 comments
Closed

Fix src module name (src -> pythonturtle) #106

bittner opened this issue Sep 17, 2018 · 9 comments

Comments

@bittner
Copy link
Member

bittner commented Sep 17, 2018

As 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).

@cool-RR
Copy link
Member

cool-RR commented 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
Copy link
Member Author

bittner commented Sep 18, 2018

Let me know if you need any guidance.

If you want to tackle that ... that would be cool. 👍

@cool-RR
Copy link
Member

cool-RR commented 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:

  1. 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.

  2. 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
Copy link
Member

cool-RR commented 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
Copy link
Member Author

bittner commented 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
Copy link
Member Author

bittner commented 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
Copy link
Member

cool-RR commented Sep 19, 2018 via email

@cool-RR
Copy link
Member

cool-RR commented 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
Copy link
Member Author

bittner commented Sep 29, 2018

Fixed by PR #115.

@bittner bittner closed this as completed Sep 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants