Skip to content

Adding github dependency #313

Closed
Closed

Description

@karantan

In the docs (https://poetry.eustace.io/docs/cli/#add) I see that you can add git dependency but when I tried this I got an error.

I've run this command poetry add --git https://github.com/karantan/ansible@v2.6.0.1 ansible and I got the following error:

Updating dependencies
Resolving dependencies... (47.5s)
                                                                                                                                                 
[CalledProcessError]                                                                                                              
Command '['git', '--git-dir', '/var/folders/fk/39r4_x312jnb1qz_pv27jg280000gn/T/pypoetry-git-ansibletxy4by9n/.git', '--work-tree', '/var/fold  
ers/fk/39r4_x312jnb1qz_pv27jg280000gn/T/pypoetry-git-ansibletxy4by9n', 'checkout', 'master']' returned non-zero exit status 1.                 
                                                                                                                                                 
add [-D|--dev] [--git GIT] [--path PATH] [-E|--extras EXTRAS] [--optional] [--python PYTHON] [--platform PLATFORM] [--allow-prereleases] [--dry-run] [--] <name> (<name>)...

So how can I install my ansible package that is tagged with v2.6.0.1?

Activity

  1. perobertson commented on Oct 25, 2018

    @perobertson

    Seems like the syntax is actually supposed to be poetry add ansible --git https://github.com/karantan/ansible. Im still trying to figure out how to specify the tag or a sha.

  2. nariman commented on Oct 25, 2018

    @nariman

    Seems like the syntax is actually supposed to be poetry add ansible --git https://github.com/karantan/ansible.

    There no difference.

    Im still trying to figure out how to specify the tag or a sha.

    Unfortunately, there's no way to do it via CLI, but you can manually add an entry into your pyproject.toml like this:

    [tool.poetry.dependencies]
    python = "^3.6"
    ansible = { git = "https://github.com/ansible/ansible.git", branch = "devel" }
    # or
    ansible = { git = "https://github.com/ansible/ansible.git", tag = "v2.6.6" }
    # or
    ansible = { git = "https://github.com/ansible/ansible.git", rev = "e5664c4" }

    It should work.

  3. senpos commented on Jan 14, 2019

    @senpos

    Do you have plans to improve adding git dependencies via CLI?
    Like poetry add --git https://github.com/Rapptz/discord.py.git --branch rewrite or poetry add --git https://github.com/Rapptz/discord.py.git@rewrite?

    Solution by @narimanizett works perfectly fine, but better CLI would be great. :)

  4. added this to the 1.0 milestone on Mar 2, 2019
  5. whisller commented on Apr 8, 2019

    @whisller

    @nariman @sdispater Is it possible to add dependency to git with category being set to dev?

    We have a library that is our dev dependency i.e.

    [tool.poetry.dev-dependencies]
    moto = { git = "https://github.com/spulec/moto.git", branch = "master" }
    

    now plugin which we use to deploy project to aws lambda uses export function.

    Problem is that when you have dependency to git branch added manually, default category in poetry.lock is being set to main.

    And when serverless-python-requirements plugin uses export command it includes also dev dependency, because locker includes packages with main category.

    I've tried to set category manually as well with:

    moto = { git = "https://github.com/spulec/moto.git", branch = "master", category="dev" }
    

    But that didn't help, category is still being set to main. Any suggestions? Or maybe I am just looking at it from wrong angle?

  6. sdispater commented on Jul 13, 2019

    @sdispater
    Member

    The add command will be improved in the next 1.0.0 release (see #1221). For instance, to use the original example, it will now be possible with the following syntax:

    poetry add git+https://github.com/karantan/ansible.git@v2.6.0.1
    
  7. whisller commented on Jul 17, 2019

    @whisller

    @sdispater will it also work with setting git repository URL as dev dependency?
    I've mentioned about it in #313 (comment)

  8. Granitosaurus commented on Nov 26, 2019

    @Granitosaurus

    Has this been silently removed in 1.0.0b7?

    [RuntimeError]
    The Poetry configuration is invalid:
      - [dependencies.myproject] {'git': 'ssh://git@mygitlab.com/myproject.gi', 'tags': '0.47.0'} is not valid under any of the given schemas
    
  9. finswimmer commented on Nov 26, 2019

    @finswimmer
    Member

    Hello @Granitosaurus,

    I see two issues:

    1. The section must be named [tool.poetry.dependencies] and not [dependencies.myproject]
    2. tags must be renamed to tag

    fin swimmer

  10. Granitosaurus commented on Nov 26, 2019

    @Granitosaurus

    @finswimmer Thanks, tags instead of tag was indeed a typo of mine, no idea how it got there though. That being said it would be nice if the error message would be more verbose as debugging this was quite a journey.

  11. laike9m commented on May 2, 2020

    @laike9m
    Contributor

    It seems that the .git prefix can be safely ignored. So

    poetry add git+https://github.com/karantan/ansible@v2.6.0.1
    

    works as well. Please correct me if I'm wrong.

  12. P403n1x87 commented on Jun 12, 2020

    @P403n1x87

    My first attempts with ssh failed with the same error. It worked once I switched to https.

  13. carlos-lm commented on Sep 4, 2021

    @carlos-lm

    Hi guys, sorry to post this in a closed issue, not know if I need open a new issue for this...

    we're working with a private repo, when I add the package in the cli, using https protocol this work fine, but it's asking me user and password and because we'll deploy the code with CI/CD I'd prefer use ssh and use the stored ssh keys...

    when I replace this

    poetry add git+https.....
    

    for this

    poetry add git+git@gitlab....
    

    or

    poetry add git@gitlab.....
    

    this doesn't work

     Could not find a matching version of package git+git
    
      at ~/.local/pipx/venvs/poetry/lib/python3.9/site-packages/poetry/console/commands/init.py:367 in _find_best_version_for_package
          363│         )
          364│ 
          365│         if not package:
          366│             # TODO: find similar
        → 367│             raise ValueError(
          368│                 "Could not find a matching version of package {}".format(name)
          369│             )
          370│ 
          371│         return package.pretty_name, selector.find_recommended_require_version(package)
    
    

    I've also tried add my package in the pyproject.toml

    [tool.poetry.dependencies]
    python = "^3.9"
    ccxt = "^1.55.69"
    xyzidb = { git = "git@gitlab.com:avanti-sf/public/xyzi-team/xyzi/utils/xyzi", branch = "dev" }
    

    here the error is this

    at ~/.local/pipx/venvs/poetry/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("-", "_")
    

    what would be the best way to include my private git repo here? thank you guys, best regards.

  14. perobertson commented on Sep 4, 2021

    @perobertson

    In your GitLab CI job you could try something like this

    build:
      before_script:
        - git config --global url."https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com".insteadOf "ssh://git@ssh.gitlab.com"
      script:
        - poetry install

    That way you can keep the ssh config and then the CI job would use a temporary token to access the repo with the same permissions as whoever runs the job.

    You may need to try different values for ssh://git@ssh.gitlab.com depending on how you added it to pyproject.toml

  15. phuong commented on Dec 14, 2021

    @phuong

    In my case
    Tried: poetry add git+https://github.com/karantan/ansible.git@v2.6.0.1
    Got: Command '['git', 'config', '-l']' returned non-zero exit status 128.

    My directory

    ls -l
    -rw-rw-r--  1 1000 1000   45 Nov  3 01:37 .git
    drwxrwxr-x  4 1000 1000 4.0K Nov  3 01:37 .github
    -rw-rw-r--  1 1000 1000  809 Nov  3 01:37 .gitignore
    ...
    

    My git is a submodule, i need to move .git to other name to make it work.
    Any idea for git submodule issue?

  16. github-actions commented on Mar 2, 2024

    @github-actions

    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.

  17. locked as resolved and limited conversation to collaborators on Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/cliRelated to the command linekind/featureFeature requests/implementations

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions