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
--script and --lib flags #738
Conversation
9ea1d72
to
0bcad87
Compare
Adding this as a draft to get feedback, while I am working to add tests. |
I think this looks good, I'm however not sure if |
My reasoning here is that these options determine the template used. The intuition here is that I likely know the kind of project i want, but leave the specifics of build system choice, etc to rye to choose. This means that rye has "sane default' switch for a template. For instance --lib and --bin implying hatchling and --lib-rs implying maturin. If in the future some new build system comes out and rye chooses this, we can flip the switch to have --lib-rs imply something else. |
The counter argument btw is that we want to implment a PyO3/Maturin template for So our choices are effectively:
Notable I am not happy with |
I would go with |
5ad1eaf
to
02290ec
Compare
This adds support for three new flags which determine the templates we generate: 1. We adding --lib, which will generate the standard python library We no longer generate `[project.scripts]` section and updated the template. 2. We added --script, which will generate a package with a __main__.py, __init__.py and an entry to `[project.scripts]`. `__main__.py` follows semantics found in Python packages such as `ensurepip` and `pip.
02290ec
to
e8a561c
Compare
|
e8a561c
to
c29a2e8
Compare
@@ -0,0 +1,4 @@ | |||
import {{ name_safe }} |
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.
I know people love __main__
but do we think it's a good idea? At least personally I really try to avoid it. Not sure how others feel about it.
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.
I looked into common Python packages like ensurepip, pip, etc. They all provide __main__.py
so that you can do python -m pip
for example. I think it is good to provide a way so people can run python -m my-package
from a rye project. That's why i included it as a thin wrapper around init
We make init.rs a bit more readable by moving the templates to a new folder templates/ which we organise by template type (lib, script) and build system.
10c3463
to
51887db
Compare
This looks good! |
fix missing space in init --build-system flag description
init: add support for --bin
--lib and --lib-rs,This adds support for three new flags which determine the templates
we generate:
We no longer generate
[project.scripts]
section and updatedthe template.
init.py and an entry to
[project.scripts]
.__main__.py
followssemantics found in Python packages such as
ensurepip
and `pip.--lib
and--build-system=maturin
.templates
folder and useinclude_str!()
.