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

poetry add of a GitHub repo with subdirectory fails #5521

Closed
3 tasks done
rht opened this issue Apr 30, 2022 · 5 comments
Closed
3 tasks done

poetry add of a GitHub repo with subdirectory fails #5521

rht opened this issue Apr 30, 2022 · 5 comments
Labels
kind/bug Something isn't working as expected

Comments

@rht
Copy link

rht commented Apr 30, 2022

  • I am on the latest Poetry version.

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

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

  • OS version and name: NixOS unstable

  • Poetry version: latest master as of 6721ebe

Issue

I am aware that the Git subdirectory feature was merged in #192. I have also read #755. My goal is to install this repo.
This is the syntax that works in requirements.txt (but I want to convert it to Poetry):

https://github.com/zulip/talon/archive/1711705c952806d4a704c7dbf58f21db8e11756a.zip#egg=talon-core==1.4.8.zulip1&subdirectory=talon-core

I have tried adding this to my pyproject.toml:

talon-core = {git = "https://github.com/zulip/talon.git", rev = "1711705c952806d4a704c7dbf58f21db8e11756a", subdirectory = "talon-core" }

then ran poetry lock --no-update but this fails with

  PackageInfoError

  Unable to determine package info for path: /tmp/pypoetry-git-talonlh1f69va
  
  Command ['/tmp/tmp9vi34lbc/.venv/bin/python', '-'] errored with the following return code 1, and output: 
  Traceback (most recent call last):
    File "<stdin>", line 9, in <module>
    File "/tmp/tmp9vi34lbc/.venv/lib/python3.10/site-packages/build/__init__.py", line 208, in __init__
      _validate_source_directory(srcdir)
    File "/tmp/tmp9vi34lbc/.venv/lib/python3.10/site-packages/build/__init__.py", line 109, in _validate_source_directory
      raise BuildException(f'Source {srcdir} does not appear to be a Python project: no pyproject.toml or setup.py')
  build.BuildException: Source /tmp/pypoetry-git-talonlh1f69va does not appear to be a Python project: no pyproject.toml or setup.py

This is because it looks like the subdirectory is not passed to build.ProjectBuilder. I checked the content of /tmp/pypoetry-git-talonlh1f69va, and it actually the root of the repo, not the subdirectory (the one that actually has setup.py).

Then, I tried poetry add -v 'git+https://github.com/zulip/talon.git#1711705c952806d4a704c7dbf58f21db8e11756a&subdirectory=talon-core'. I got an identical error message.

@rht rht added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Apr 30, 2022
@rht
Copy link
Author

rht commented May 3, 2022

I think this is the cause of the problem: in

package = Provider.get_package_from_vcs(
"git", url=url.url, rev=pair.get("rev"), source_root=source_root
)
, the subdirectory is not parsed and passed to get_package_from_vcs.

This is the stack trace after running poetry lock --no-update:


  Stack trace:

  13  ~/.local/pipx/venvs/poetry/lib/python3.10/site-packages/cleo/application.py:330 in run
        exit_code = self._run(io)

  12  ~/.local/pipx/venvs/poetry/lib/python3.10/site-packages/poetry/console/application.py:174 in _run
        return super()._run(io)

  11  ~/.local/pipx/venvs/poetry/lib/python3.10/site-packages/cleo/application.py:425 in _run
        exit_code = self._run_command(command, io)

  10  ~/.local/pipx/venvs/poetry/lib/python3.10/site-packages/cleo/application.py:467 in _run_command
        raise error

   9  ~/.local/pipx/venvs/poetry/lib/python3.10/site-packages/cleo/application.py:451 in _run_command
        exit_code = command.run(io)

   8  ~/.local/pipx/venvs/poetry/lib/python3.10/site-packages/cleo/commands/base_command.py:118 in run
        status_code = self.execute(io)

   7  ~/.local/pipx/venvs/poetry/lib/python3.10/site-packages/cleo/commands/command.py:85 in execute
        return self.handle()

   6  ~/.local/pipx/venvs/poetry/lib/python3.10/site-packages/poetry/console/commands/add.py:154 in handle
        requirements = self._determine_requirements(

   5  ~/.local/pipx/venvs/poetry/lib/python3.10/site-packages/poetry/console/commands/init.py:349 in _determine_requirements
        requires = self._parse_requirements(requires)

   4  ~/.local/pipx/venvs/poetry/lib/python3.10/site-packages/poetry/console/commands/init.py:439 in _parse_requirements
        package = Provider.get_package_from_vcs(

   3  ~/.local/pipx/venvs/poetry/lib/python3.10/site-packages/poetry/puzzle/provider.py:206 in get_package_from_vcs
        package = cls.get_package_from_directory(tmp_dir, name=name)

   2  ~/.local/pipx/venvs/poetry/lib/python3.10/site-packages/poetry/puzzle/provider.py:286 in get_package_from_directory
        package = PackageInfo.from_directory(path=directory).to_package(

   1  ~/.local/pipx/venvs/poetry/lib/python3.10/site-packages/poetry/inspection/info.py:545 in from_directory
        info = cls._pep517_metadata(path)

rht added a commit to rht/poetry that referenced this issue May 3, 2022
Fixes python-poetry#5521.
With this commit, one can finally add a Git dependency with a
subdirectory, e.g.

```
talon-core = {git = "https://github.com/zulip/talon.git", rev = "1711705c952806d4a704c7dbf58f21db8e11756a", subdirectory = "talon-core" }
```
rht added a commit to rht/poetry that referenced this issue May 3, 2022
Fixes python-poetry#5521.
With this commit, one can finally add a Git dependency with a
subdirectory, e.g.

```
talon-core = {git = "https://github.com/zulip/talon.git", rev = "1711705c952806d4a704c7dbf58f21db8e11756a", subdirectory = "talon-core" }
```
@dimbleby
Copy link
Contributor

duplicate #755

@rht
Copy link
Author

rht commented Jul 31, 2022

I opened this issue because #755 was closed at the time.

@dimbleby
Copy link
Contributor

I think #755 has been (re)opened since January 2020. But that's not important, what matters is that we currently have two issues tracking the same thing.

#755 is active, can you close this one please?

@mkniewallner mkniewallner closed this as not planned Won't fix, can't repro, duplicate, stale Jul 31, 2022
@mkniewallner mkniewallner removed the status/triage This issue needs to be triaged label Jul 31, 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
Development

Successfully merging a pull request may close this issue.

3 participants