-
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
Introduce non-package-mode #8650
Conversation
4fb6e23
to
d5dd3cc
Compare
This comment was marked as resolved.
This comment was marked as resolved.
Thanks for working on this! I tested it locally and everything worked as expected. I know you left a TODO for docs, but it might be nice to update the help text in places like: poetry/src/poetry/console/commands/install.py Lines 75 to 79 in 5e0ff80
|
d5dd3cc
to
db4f944
Compare
Deploy preview for website ready! ✅ Preview Built with commit 5f15049. |
I wonder if we actually need to introduce that "mode" part. We could just have placeholder values for when the config is missing |
What you're saying might make sense for when those things aren't set, but it's not very explicit and relies on the user knowing implicitly that 'omitting name and version will activate non-package mode'. Personally, I do use 'name' and 'version' even when I'm not building a package - and I feel like an explicit boolean setting of 'package=false' would be clearer. |
Ok, so what use would you have for that mode if you are setting the name and version anyway? |
It's the name and version of the thing I'm building, but it's not a package, it's a web service |
Ok, but as you can see in PR description, other than removing the requirement for name and version, what that mode introduces is lock on building and publishing (which I would say is on the user to decide, no real need to hardlock it) and installation of the project is using |
I'm here because poetry kept asking me to specify 'no-root'. It's a nuisance to have to specify that every time I run install and also has no obvious semantic link to the concept of 'I'm actually not building a package, thanks'. I was merely providing an answer to your question 'Do we really need the mode part?' and I'm explaining why I think we do. I can appreciate that blocking the publishing/building if there is no name/version would be sufficient to stop web services being published as packages, but as someone who uses poetry to build web services it would be nice for there to be an obvious way to configure poetry to not expect me to jump through hoops designed for package development. I think |
I tend to say, it's good to have an explicit way because naming and versioning your project even if you don't intend to build is a legit use case (especially if we support PEP 621 in the future so that name and version are not poetry specific keys). So yes, at the moment it's only about However, we can think about making it a tri-state with the default (not explicitly set): package mode if name and version is defined, otherwise non-package mode. I'm just not sure if the little bit of comfort is worth making it more complicated (not only to implement but also to understand as a normal user)?
I'm not sure if The option in |
It's a fair concern to worry about collisions on the names, but whilst looking at how the
I mean, even if we just went with
I really would be curious what the lowest friction default choice would be for first-time setup? Either way, I've never contributed to an open source project before but |
I would advise against inferring the mode from the presence or non-presence of certain fields. Not only is it against Python's motto of "explicit is better than implicit", it can also lead to hard-to-debug problems. Assume someone wants to build a package, but forgets or misspells one of the required fields: Things will not work as expected or be broken in subtle ways. But until you try to publish the package, poetry will pretend everything is fine, because from its standpoint it is. |
I'm quite convinced now that this should be an explicit option. This leaves naming as an open topic. Let's try to get a picture of the general mood. (I have no idea how well this will work, but it's worth a try. 😅) Please react with the respective emoji if you have an opinion:
If you have two favorites and dislike the third option, just vote for your two favorites. Disclaimer: This vote does not result in a binding decision. We may choose another name if we think there is a good reason. |
I'll offer one more option 😅 : It re-uses the existing field, avoids the possibility of conflicting settings like |
One thing to consider: |
I too would prefer to just re-use the existing Imho, this non-package mode should also be the default when |
I think this would break simple projects that only have a single package that is implicitly discovered. For example, the following repo builds a package, but it is implicitly found in |
Is there a reason you'd default to putting it in |
To avoid a breaking change.
I do not think there is any reliable data thats tells us what percentage of users uses Poetry only for dependency management and not for packaging. This means we don't even know if a breaking change would make sense for the majority of users. |
5f09476
to
81f0504
Compare
FYI: I switched the PR from |
A nice side effect of this change will be that for non-packages, we will also get a clean solution for private-ness as well 🚀 |
Thanks for all the work on this all, I'm really excited to see this get merged. 😁 It looks like this is scheduled to be part of the 1.8 release. Reviewing the 1.8 issue it seems like the related PRs are mostly ready to go, I was curious about likely timeline to the release or if there is anything we can do to help? |
That's right. They are mainly waiting for the poetry-core release. I'm just waiting for some reviews before creating the release PR. After the poetry-core release we can do the final adjustments in the open PRs mentioned in #8770. |
```toml | ||
[tool.poetry] | ||
package-mode = false | ||
``` |
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.
Will the setting work in poetry.toml
as well? If so, I would add an example for that as well.
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 don't think so. Actually, I don't think it would be a good idea to put it in poetry.toml
because it's clearly a project setting and not a user setting. (It's not like user A wants to have this setting for project X while user B does not want this setting for project X.)
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 meant poetry.toml
inside a project directory, which is meant to hold project-specific poetry configuration as per docs:
Your local configuration of Poetry application is stored in the poetry.toml file, which is separate from pyproject.toml.
In any case, both variants are fine to me, and I guess this setting will only work in the tool.poetry
section then. It even seems that tool.poetry
is kind of a mislabeled thing because it does not configure poetry.
81f0504
to
a32cc4d
Compare
a32cc4d
to
e36daed
Compare
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.
LGTM
- metadata like `name` and `version` is not required - the root package is never installed (same as `--no-root`) - building and publishing is not possible
… `package-mode` (`true`/`false`)
e36daed
to
5f15049
Compare
Thanks for this update. |
@armanjal It's generally best to open a new issue to report a problem like this. You can still reference this MR using |
Sure , thanks! |
Can we add a new parameter in |
Please open a feature request issue -- merged PRs are not a good venue for discussion, as both initial comments and any follow-up are easy to lose track of in the noise. Creating a new issue, with a descriptive title and body both makes clear what the current (and ideally only) topic of discussion is, and makes returning to the conversation in the future easier. |
Pull Request Check List
Resolves: #1132
Requires: python-poetry/poetry-core#661
Introduce non-package mode
mode
package-mode
intool.poetry
mode
can be eitherpackage
(default) ornon-package
package-mode
can be eithertrue
(default) orfalse
name
andversion
is not required--no-root
)Docs preview
Example Config:
You can install this branch with pipx as follows:
This will install poetry with the suffix "_npm" so that you have to call
poetry_npm
instead ofpoetry
. (The suffix is arbitrary, I chose "npm" as an abbreviation for non-package-mode. 😉)