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

Adding automatic fetch of license file when calling init command #9178

Closed
2 tasks done
quentinhaenn opened this issue Mar 19, 2024 · 4 comments
Closed
2 tasks done

Adding automatic fetch of license file when calling init command #9178

quentinhaenn opened this issue Mar 19, 2024 · 4 comments
Labels
kind/feature Feature requests/implementations status/triage This issue needs to be triaged

Comments

@quentinhaenn
Copy link

Issue Kind

Brand new capability

Description

  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have searched the documentation and believe that my question is not covered.

I just started a python initializer project on my own and several colleagues told me your tool exist. After digging into it, it came out that Poetry is a wonderful tool for managing python project. However, I implemented a feature that load License content and fill the license file associated with the project. As I supposed a great part of project using poetry might either be open licensed or using a commonly used license, it would be great to implement this one in Poetry.

One may also think about another feature that woould be changing the license tag (eg from MIT to gpl-3.0) in pyproject.toml and using poetry update pulling the new license required.

Impact

I believe that this would be a great feature in Poetry as it pushed me to develop my own solution to create python projects from scratch using a simple CLI.
I would love to see a --license' option to pass to poetry new` command, choosing the "MIT" license as default behavior and pulling the license body and adding it into the LICENSE file directly at project creation. Not a great gain of time but I certainly support it as comfort gain.

Workarounds

Not really a workaround but my own implementation of this feature is accessible on Pypi as pyproject-init and on GitHub

I know several other tools already exists on PyPi doing same but submitting it to Poetry seemed the thing to do.

Also, I'd like to contribute by implementing it by myself and submitting a PR but the legacy codebase is pretty huge and I am facing difficulties to navigate in.

I know this seems a very tiny improvement but I'd really like to see it in a great tool like Poetry 😃

Please let me know if this feature may be of interest and if I can contribute in any way !
Thanks in advance 😄

@quentinhaenn quentinhaenn added kind/feature Feature requests/implementations status/triage This issue needs to be triaged labels Mar 19, 2024
@radoering
Copy link
Member

There is already a --license option for poetry init and since #9088 also for poetry new (just in the main branch, not yet released). It just fills the metadata field with the given text.

choosing the "MIT" license as default

Not sure if it makes sense to have a default.

pulling the license body

Some things to consider:

  • license is more or less free text so this will not always be possible
  • This probably requires access to some website?
    • Downloading a file will slow down the command a bit. (Will it be significant?)
    • Poetry might be used in an environment without internet access. It probably should not fail and should not waste time by running into a timeout in this case.
  • It might not always be as simple as downloading one file. For example, for LGPL you need two:

If you are releasing your program under the Lesser GPL, you should also include the text version of the LGPL, usually in a file called COPYING.LESSER. Please note that, since the LGPL is a set of additional permissions on top of the GPL, it's crucial to include both licenses so users have all the materials they need to understand their rights.

from https://www.gnu.org/licenses/gpl-howto.html.en

All in all, I think this might be better suited in a plugin with a new command to download the license. But let's see if there are other opinions.

@quentinhaenn
Copy link
Author

Thanks for replying.

There is already a --license option for poetry init and since #9088 also for poetry new (just in the main branch, not yet released). It just fills the metadata field with the given text.

Yes, I figured it out before submitting the issue, I should have precised it. I mainly focused on the tiny gain of time of automatic filling the LICENSE file.

Not sure if it makes sense to have a default.

Great point of yours, I considered the MIT license as default on my usage as it is the "most permissive" in open source projects, but that might not be effectively the case.

This probably requires access to some website?

In the cases I considered, I only pull license body of licenses listed on choosealicense.com. Fortunately, GitHub API provide an URI that can be used for pulling licenses : https://api.github.com/licenses/" + license_type

Downloading a file will slow down the command a bit. (Will it be significant?)

This depends on internet connection I guess. In my case, the project is initialized within a second with license text pull.

Poetry might be used in an environment without internet access. It probably should not fail and should not waste time by running into a timeout in this case.

That case might be easily handle with requests.ConnectionError I guess. Plus, setting a timeout parameter at 0.005 sec works fine in my case and only handle connection time to the GitHub API i.e. downloading time of the license may be longer but if connection time is less than timeout, it works.

It might not always be as simple as downloading one file. For example, for LGPL you need two

I did not know about that particular case, thanks for sharing. Might not be that hard to handle with an if statement.

All in all, I think this might be better suited in a plugin with a new command to download the license.

I wondered the same, but cannot figured it out by myself.

I'll take a look about plugin dev too then.

Thanks for your time 😄

@robertlagrant
Copy link

The gain of time probably is not sufficient vs the risk of mis-licencing someone's software. The safest is to have a blank licence field, or a proprietary licence as the default, and allow people to open up the licence.

@Secrus Secrus closed this as not planned Won't fix, can't repro, duplicate, stale Sep 26, 2024
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/feature Feature requests/implementations status/triage This issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

4 participants