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

Allow adding git ref as dependency #3240

Closed
2 tasks done
yajo opened this issue Oct 18, 2020 · 4 comments
Closed
2 tasks done

Allow adding git ref as dependency #3240

yajo opened this issue Oct 18, 2020 · 4 comments
Labels
kind/feature Feature requests/implementations

Comments

@yajo
Copy link

yajo commented Oct 18, 2020

  • 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.

Feature Request

#357 says that git refs are supported on poetry add, but it seems it's not the case. For example, I want to install a pull request using this method, that as you can see here is supported by pip:

/ # pip install git+https://github.com/samuelcolvin/pydantic.git@refs/pull/1844/merge
Collecting git+https://github.com/samuelcolvin/pydantic.git@refs/pull/1844/merge
  Cloning https://github.com/samuelcolvin/pydantic.git (to revision refs/pull/1844/merge) to /tmp/pip-req-build-e99oftjc
  Running command git clone -q https://github.com/samuelcolvin/pydantic.git /tmp/pip-req-build-e99oftjc
  WARNING: Did not find branch or tag 'refs/pull/1844/merge', assuming revision or ref.
  Running command git fetch -q https://github.com/samuelcolvin/pydantic.git refs/pull/1844/merge
  Running command git checkout -q 33340ebd4ab5820b8eb470a0720cb84da326b53e
Building wheels for collected packages: pydantic
  Building wheel for pydantic (setup.py) ... done
  Created wheel for pydantic: filename=pydantic-1.6.1-py36.py37.py38.py39-none-any.whl size=101194 sha256=cbfd31934cb5eb16893f97d9280b9a5d37577ae2f53cc550ae9e3d46e30fb8e8
  Stored in directory: /tmp/pip-ephem-wheel-cache-yii1vqsb/wheels/b0/ac/36/4f3bb3c94d407f0838d66f1556da5879b79c5be436c82bace1
Successfully built pydantic
Installing collected packages: pydantic
Successfully installed pydantic-1.6.1
WARNING: You are using pip version 20.1.1; however, version 20.2.4 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.

However, when doing the same thing with poetry, it fails:

➤ poetry add git+https://github.com/samuelcolvin/pydantic.git@refs/pull/1844/merge -vvv
Using virtualenv: /var/home/yajo/prodevel/copier/.venv

  Stack trace:

  11  ~/.local/pipx/venvs/poetry/lib64/python3.8/site-packages/clikit/console_application.py:131 in run
       129│             parsed_args = resolved_command.args
       130│ 
     → 131│             status_code = command.handle(parsed_args, io)
       132│         except KeyboardInterrupt:
       133│             status_code = 1

  10  ~/.local/pipx/venvs/poetry/lib64/python3.8/site-packages/clikit/api/command/command.py:120 in handle
       118│     def handle(self, args, io):  # type: (Args, IO) -> int
       119│         try:
     → 120│             status_code = self._do_handle(args, io)
       121│         except KeyboardInterrupt:
       122│             if io.is_debug():

   9  ~/.local/pipx/venvs/poetry/lib64/python3.8/site-packages/clikit/api/command/command.py:171 in _do_handle
       169│         handler_method = self._config.handler_method
       170│ 
     → 171│         return getattr(handler, handler_method)(args, io, self)
       172│ 
       173│     def __repr__(self):  # type: () -> str

   8  ~/.local/pipx/venvs/poetry/lib64/python3.8/site-packages/cleo/commands/command.py:92 in wrap_handle
        90│         self._command = command
        91│ 
     →  92│         return self.handle()
        93│ 
        94│     def handle(self):  # type: () -> Optional[int]

   7  ~/.local/pipx/venvs/poetry/lib64/python3.8/site-packages/poetry/console/commands/add.py:107 in handle
       105│             return 0
       106│ 
     → 107│         requirements = self._determine_requirements(
       108│             packages,
       109│             allow_prereleases=self.option("allow-prereleases"),

   6  ~/.local/pipx/venvs/poetry/lib64/python3.8/site-packages/poetry/console/commands/init.py:320 in _determine_requirements
       318│             return requires
       319│ 
     → 320│         requires = self._parse_requirements(requires)
       321│         result = []
       322│         for requirement in requires:

   5  ~/.local/pipx/venvs/poetry/lib64/python3.8/site-packages/poetry/console/commands/init.py:410 in _parse_requirements
       408│                         pair["extras"] = extras
       409│ 
     → 410│                     package = Provider.get_package_from_vcs(
       411│                         "git", url.url, rev=pair.get("rev")
       412│                     )

   4  ~/.local/pipx/venvs/poetry/lib64/python3.8/site-packages/poetry/puzzle/provider.py:195 in get_package_from_vcs
       193│             reference = branch or tag or rev
       194│             if reference is not None:
     → 195│                 git.checkout(reference, tmp_dir)
       196│             else:
       197│                 reference = "HEAD"

   3  ~/.local/pipx/venvs/poetry/lib64/python3.8/site-packages/poetry/core/vcs/git.py:217 in checkout
       215│         args += ["checkout", rev]
       216│ 
     → 217│         return self.run(*args)
       218│ 
       219│     def rev_parse(self, rev, folder=None):  # type: (...) -> str

   2  ~/.local/pipx/venvs/poetry/lib64/python3.8/site-packages/poetry/core/vcs/git.py:290 in run
       288│ 
       289│         return decode(
     → 290│             subprocess.check_output(["git"] + list(args), stderr=subprocess.STDOUT)
       291│         ).strip()
       292│ 

   1  /usr/lib64/python3.8/subprocess.py:411 in check_output
        409│         kwargs['input'] = '' if kwargs.get('universal_newlines', False) else b''
        410│ 
     →  411│     return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
        412│                **kwargs).stdout
        413│ 

  CalledProcessError

  Command '['git', '--git-dir', '/tmp/pypoetry-git-pydanticvro38484/.git', '--work-tree', '/tmp/pypoetry-git-pydanticvro38484', 'checkout', 'refs/pull/1844/merge']' returned non-zero exit status 1.

  at ~/.local/pipx/venvs/poetry/lib64/python3.8/site-packages/poetry/utils/_compat.py:217 in run
      213│                 process.wait()
      214│                 raise
      215│             retcode = process.poll()
      216│             if check and retcode:
    → 217│                 raise CalledProcessError(
      218│                     retcode, process.args, output=stdout, stderr=stderr
      219│                 )
      220│         finally:
      221│             # None because our context manager __exit__ does not use them.
@yajo yajo added kind/feature Feature requests/implementations status/triage This issue needs to be triaged labels Oct 18, 2020
@akeeman
Copy link
Contributor

akeeman commented Oct 19, 2020

I don't know the details, but you can add branches, tags and commit hashes. So doesn't work referencing the related branch for you?

@yajo
Copy link
Author

yajo commented Oct 20, 2020 via email

@mkniewallner
Copy link
Member

Just tried on latest version from master branch, and it seems that it now works:

$ curl -sSL https://install.python-poetry.org | python - --git https://github.com/python-poetry/poetry.git@master

$ poetry add git+https://github.com/samuelcolvin/pydantic.git@refs/pull/4102/merge -vvv
...
  • Installing pydantic (1.9.0 f0c432c): Pending...
  • Installing pydantic (1.9.0 f0c432c): Cloning...
  • Installing pydantic (1.9.0 f0c432c): Building...
  • Installing pydantic (1.9.0 f0c432c)

Closing this issue, but feel free to reopen if you still have troubles.

@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/feature Feature requests/implementations
Projects
None yet
Development

No branches or pull requests

3 participants