-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Add support for app/library type to poetry new
and poetry init
#9668
Comments
For more on the issues this causes, see: |
In my opinion this distinction between app and lib is flawed for Python projects. (There are many apps that are packaged, e.g. Poetry itself, pipx, pre-commit, ...) Setting package mode as in #9622 and maybe doing more based on this makes more sense to me, because:
I have not thought about that but we could consider to do this when creating a project in non-package mode, too. |
Thank you for the reply! :-)
Yeah I definitely agree that there are types of projects where it's a grey area between "app" and "library" (eg CLI tools, Poetry itself etc). Naming is hard and all that...but by "app" I was instead meaning ~"end-user" projects that are typically not distributed for the world to use, but are used directly by the person or team maintaining them for a very specific purpose. Think Django webapps that people are deploying to production, or data analysis projects shared by a team of data scientists etc, rather than an open source project that's shared for consumption by others. I would argue these types of "app" projects:
Given (1), I think it would be really beneficial for Poetry to support these types of projects better out of the box. (Plus, I would argue that the authors of libraries or of tools like pipx are much more capable of overriding defaults than most end users, so it makes sense to pick the defaults for the more-common and more-beginner-heavy app project type instead.) The current default I would also posit a big reason these types of projects use a package manager like Poetry (instead of using pip and requirements files), is because they want the determinism of a lockfile. However, without also ~"locking" the Python version to at least a major version (eg As-is, all of the options for us (Heroku) adding support for reading the Python version from In contrast, uv's behaviour is already a lot more suitable out of the box for these app type projects: The |
Issue Kind
Brand new capability
Description
Currently if I use
poetry new
orpoetry init
, I end up with apyproject.toml
configuration that is more oriented towards a library than an app, with no way to tell thenew
/init
commands otherwise (beyond--python
, but that's only one of several things that would need overriding).For example they generate:
...whereas for an app:
package-mode = false
from Introduce non-package-mode #8650, and don't want the name/version/description/authors/readme fields)[build-system]
)3.12.*
) rather than allowing an unsafe range (such as>=3.12
) - so prod vs staging vs each developer's machine is at least using the same major Python version.And therefore for apps, a config like the following is more appropriate:
As such, it would be helpful if the
poetry new
andpoetry init
commands accepted something like a--type
argument (and corresponding question prompt when using those commands in interactive mode), that accepted options like"app"
or"library"
, that then generated config more appropriate for the specified use-case. The interactive prompts and/or existing CLI args would still allow users to mix and match if needed (for example, the user could select "app" mode, but when prompted for thepython
value, could override the app mode's suggested default of "3.N.*" to a wider range if they prefer.Such a type option would be similar to:
uv init
's--app
vs--lib
: https://docs.astral.sh/uv/reference/cli/#uv-initcargo new
's--bin
/--lib
: https://doc.rust-lang.org/cargo/commands/cargo-new.htmlPossible arg/option names:
--type {app,lib}
(or--type {app,library}
--app
/--lib
(or--app
/--library
)Note: I intentionally didn't include
--package-mode {true,false}
in the list, since this feature request is about more than justpackage-mode = false
and about several other defaults that make less sense when using Poetry with an app.Impact
Workarounds
Users either:
poetry new
/poetry init
at all, and create theirpyproject.toml
from scratch using the docspoetry new
/poetry init
and fill out questions that aren't relevant, but then have to change the defaults afterwards...but both of these rely upon the user knowing that the default configs generated by new/init are not ideal for app use-cases, and what they should change to make them more suitable.
The text was updated successfully, but these errors were encountered: