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

Trouble with git link dependency rooted in subfolder #4380

Closed
ashnair1 opened this issue Aug 13, 2021 · 2 comments
Closed

Trouble with git link dependency rooted in subfolder #4380

ashnair1 opened this issue Aug 13, 2021 · 2 comments

Comments

@ashnair1
Copy link
Contributor

ashnair1 commented Aug 13, 2021

My goal is to add this forked library as a dependency to my project. Previously with pip I was able to install the library via

pip install "git+https://github.com/ashnair1/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"

Essentially I would like to do the same with poetry. #1221 added a feature to add git links as dependencies so I did try the following:

poetry add -vvv git+https://github.com/ashnair1/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI

But this didn't work and resulted in the following stack trace.

✦ ➜ Using virtualenv: /home/ashwin/anaconda3/envs/coco

  Stack trace:

  11  ~/anaconda3/envs/coco/lib/python3.7/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  ~/anaconda3/envs/coco/lib/python3.7/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  ~/anaconda3/envs/coco/lib/python3.7/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  ~/anaconda3/envs/coco/lib/python3.7/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  ~/anaconda3/envs/coco/lib/python3.7/site-packages/poetry/console/commands/add.py:109 in handle
       107│             packages,
       108│             allow_prereleases=self.option("allow-prereleases"),
     → 109│             source=self.option("source"),
       110│         )
       111│ 

   6  ~/anaconda3/envs/coco/lib/python3.7/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  ~/anaconda3/envs/coco/lib/python3.7/site-packages/poetry/console/commands/init.py:411 in _parse_requirements
       409│ 
       410│                     package = Provider.get_package_from_vcs(
     → 411│                         "git", url.url, rev=pair.get("rev")
       412│                     )
       413│                     pair["name"] = package.name

   4  ~/anaconda3/envs/coco/lib/python3.7/site-packages/poetry/puzzle/provider.py:196 in get_package_from_vcs
       194│             reference = branch or tag or rev
       195│             if reference is not None:
     → 196│                 git.checkout(reference, tmp_dir)
       197│             else:
       198│                 reference = "HEAD"

   3  ~/anaconda3/envs/coco/lib/python3.7/site-packages/poetry/core/vcs/git.py:229 in checkout
       227│         args += ["checkout", rev]
       228│ 
     → 229│         return self.run(*args)
       230│ 
       231│     def rev_parse(self, rev, folder=None):  # type: (str, Optional[Path]) -> str

   2  ~/anaconda3/envs/coco/lib/python3.7/site-packages/poetry/core/vcs/git.py:302 in run
       300│ 
       301│         return decode(
     → 302│             subprocess.check_output(["git"] + list(args), stderr=subprocess.STDOUT)
       303│         ).strip()
       304│ 

   1  ~/anaconda3/envs/coco/lib/python3.7/subprocess.py:411 in check_output
        409│ 
        410│     return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
     →  411│                **kwargs).stdout
        412│ 
        413│ 

  CalledProcessError

  Command '['git', '--git-dir', '/tmp/pypoetry-git-cocoapi3d1g76i/.git', '--work-tree', '/tmp/pypoetry-git-cocoapi3d1g76i', 'checkout', 'egg=pycocotools']' returned non-zero exit status 1.

  at ~/anaconda3/envs/coco/lib/python3.7/site-packages/poetry/utils/_compat.py:218 in run
      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.
      222│             process.__exit__(None, None, None)
^C^C
[1]+  Exit 1                  poetry add -vvv git+https://github.com/ashnair1/cocoapi.git#egg=pycocotools

So how can I add the library as a project dependency?

@finswimmer
Copy link
Member

Hello @ashnair1 ,

what you try is to install a package from a subfolder within a git repository. This is not supported at the moment by poetry. Some links you can follow:

fin swimmer

@ashnair1 ashnair1 changed the title Trouble with git link dependency Trouble with git link dependency rooted in subfolder Jan 11, 2022
Copy link

github-actions bot commented Mar 2, 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 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants