-
Notifications
You must be signed in to change notification settings - Fork 950
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
note an alternative for running src packages locally. #1661
base: main
Are you sure you want to change the base?
Conversation
I don't think we should have this in the guide. The whole point of the If we want to have this, it should be a small foot note hidden somewhere no one looks. Well maybe not that bad, but it definitely should not be the first suggestion. The first suggestion should be to install (as editable). |
Ah thank you, I see your point. I have updated to address that. |
To run a command-line interface directly, you can install the package in | ||
:doc:`Development Mode <setuptools:userguide/development_mode>` for testing purposes. | ||
|
||
Since this can be unpractical in some situations, you can also either: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this can be unpractical in some situations, you can also either: | |
Since this can be impractical in some situations, you can also either: |
cd src/ | ||
python -m awesome_package | ||
|
||
Or prepend the package folder to Python's :py:data:`sys.path` when called via its |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If these are options, they should probably be bullet points. It's weird to have two consequent paragraphs ending with a colon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly, I share @sinoroc's sentiment on including dark sorcery into this document. Runpy scripts usually need dependencies, that are declared in the packaging metadata. So it doesn't really make sense to showcase an execution method that is broken half the time, forcing the reader to track down what they have to install. OTOH, |
Upon converting a package to src structure, a user is left unable to run their code via the normal python command,
python src/awesome_project/__main__.py
This PR adds an alternative approach that doesn't require an in file workaround.
📚 Documentation preview 📚: https://python-packaging-user-guide--1661.org.readthedocs.build/en/1661/discussions/src-layout-vs-flat-layout/#running-a-command-line-interface-from-source-with-src-layout