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

git repo with hypthens fails with error #4678

Closed
michael-c-hoffman opened this issue Oct 27, 2021 · 12 comments · Fixed by #5428
Closed

git repo with hypthens fails with error #4678

michael-c-hoffman opened this issue Oct 27, 2021 · 12 comments · Fixed by #5428
Labels
kind/bug Something isn't working as expected

Comments

@michael-c-hoffman
Copy link

michael-c-hoffman commented Oct 27, 2021

  • [ x] I am on the latest Poetry version.

  • [x ] I have searched the issues of this repo and believe that this is not a duplicate.

  • [ x] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

  • OS version and name: Fedora 34

  • Poetry version: 1.1.5

  • **Link of a Gist

Issue

When adding a git repo that includes a hyphen in the org/path poetry fails to add with an error:

TypeError

  expected string or bytes-like object

  at ~/.local/lib/python3.9/site-packages/poetry/core/utils/helpers.py:27 in canonicalize_name
       23│ _canonicalize_regex = re.compile(r"[-_]+")
       24│ 
       25│ 
       26│ def canonicalize_name(name):  # type: (str) -> str
    →  27│     return _canonicalize_regex.sub("-", name).lower()
       28│ 
       29│ 
       30│ def module_name(name):  # type: (str) -> str
       31│     return canonicalize_name(name).replace(".", "_").replace("-", "_")
@michael-c-hoffman michael-c-hoffman added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Oct 27, 2021
@gabrielbdsantos
Copy link

gabrielbdsantos commented Nov 2, 2021

I'm having the same issue on poetry 1.1.11.

poetry add --help gives poetry add git+https://github.com/python-poetry/poetry.git as an example, which is indeed a valid one. I have just tried it. However, when I try poetry add git+https://github.com/tpaviot/pythonocc-core.git, poetry throws that issue.

So, it seems that the problem is not with hyphens in general, but only in package names, right?

@michael-c-hoffman
Copy link
Author

michael-c-hoffman commented Nov 3, 2021 via email

@srikanthravipati
Copy link

package = PackageInfo.from_directory(path=directory).to_package(
root_dir=directory
)

to

    package = PackageInfo.from_directory(path=directory).to_package(
        name=name, root_dir=directory
    ) 

? so that name gets propagated correctly...

@michael-c-hoffman
Copy link
Author

michael-c-hoffman commented Nov 10, 2021

yes, I can confirm that this change fixes my issue.

@michael-c-hoffman
Copy link
Author

can this get merged into the next release?

@neersighted
Copy link
Member

can this get merged into the next release?

Hi @michael-c-hoffman -- I'm not aware of any outstanding PRs with this fix. A PR with the fix and a regression test would be welcomed, and I'd love to be pointed to an already-extant one if I missed it.

@michael-c-hoffman
Copy link
Author

@neersighted I did not have a PR or code, this was just from comment that @srikanthravipati provided in the comments above. I am not familiar enough with this code base to write the tests.

@nathan-kairon
Copy link

I got the same issue

@abn
Copy link
Member

abn commented May 11, 2022

I suspect the reported issue has been resolved with #5428 as the vay we create the directory was changed. This might also be a duplicate of #3392.

Can someone verify using poetry@master?

@neersighted
Copy link
Member

@skairunner Could you please test your failing repo against current master?

@skairunner
Copy link

I am happy to confirm that poetry@master resolves this particular issue.

@abn abn closed this as completed May 13, 2022
@mkniewallner mkniewallner removed the status/triage This issue needs to be triaged label Jun 11, 2022
Copy link

github-actions bot commented Mar 1, 2024

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 Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
8 participants