question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

create_package_from_pep610 breaks without "requested_revision"

See original GitHub issue
  • [ 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: macOS 10.15
  • Poetry version: 1.2.0a1

Issue

Any poetry command which hits create_package_from_pep610 when a URL installed package is installed, and the direct_url.json lacks β€œrequested_revision”, causes a KeyError. This is not PEP610 compliant:

https://github.com/python-poetry/poetry/blob/527882380fd7aecd7c34922a7bc888226a5737ff/poetry/repositories/installed_repository.py#L206

A requested_revision key (type string) MAY be present naming a branch/tag/ref/commit/revision/etc (in a format compatible with the VCS) to install.

https://www.python.org/dev/peps/pep-0610/#:~:text=a requested_revision key (type string) may be present naming a branch%2Ftag%2Fref%2Fcommit%2Frevision%2Fetc (in a format compatible with the vcs) to install.

The offending direct_url.json:

{"url": "https://github.com/encode/uvicorn.git", "vcs_info": {"commit_id": "62825d3c1c2897e414b72318a079d0d8657ade34", "vcs": "git"}}

Steps to reproduce

docker run -it python:3.9.6 bash  # or some other fresh env
pip install poetry-version-plugin  # install a plugin and poetry 1.2.0a1
poetry plugin show
# works
pip install 'git+https://github.com/encode/uvicorn.git'  # install offending package
poetry plugin show 

Trace:

  KeyError

  'requested_revision'

  at /usr/local/lib/python3.9/site-packages/poetry/repositories/installed_repository.py:201 in create_package_from_pep610
      197β”‚         elif "vcs_info" in url_reference:
      198β”‚             # VCS distribution
      199β”‚             source_type = url_reference["vcs_info"]["vcs"]
      200β”‚             source_url = url_reference["url"]
    β†’ 201β”‚             source_reference = url_reference["vcs_info"]["requested_revision"]
      202β”‚             source_resolved_reference = url_reference["vcs_info"]["commit_id"]
      203β”‚
      204β”‚         package = Package(
      205β”‚             distribution.metadata["name"],
root@d98543c446e4:/# poetry plugin show -vvv

  Stack trace:

  10  /usr/local/lib/python3.9/site-packages/cleo/application.py:314 in run
       312β”‚
       313β”‚             try:
     β†’ 314β”‚                 exit_code = self._run(io)
       315β”‚             except Exception as e:
       316β”‚                 if not self._catch_exceptions:

   9  /usr/local/lib/python3.9/site-packages/poetry/console/application.py:167 in _run
       165β”‚         self._load_plugins(io)
       166β”‚
     β†’ 167β”‚         return super()._run(io)
       168β”‚
       169β”‚     def _configure_io(self, io: IO) -> None:

   8  /usr/local/lib/python3.9/site-packages/cleo/application.py:409 in _run
       407β”‚                 io.set_input(ArgvInput(argv))
       408β”‚
     β†’ 409β”‚         exit_code = self._run_command(command, io)
       410β”‚         self._running_command = None
       411β”‚

   7  /usr/local/lib/python3.9/site-packages/cleo/application.py:451 in _run_command
       449β”‚
       450β”‚         if error is not None:
     β†’ 451β”‚             raise error
       452β”‚
       453β”‚         return event.exit_code

   6  /usr/local/lib/python3.9/site-packages/cleo/application.py:435 in _run_command
       433β”‚
       434β”‚             if event.command_should_run():
     β†’ 435β”‚                 exit_code = command.run(io)
       436β”‚             else:
       437β”‚                 exit_code = ConsoleCommandEvent.RETURN_CODE_DISABLED

   5  /usr/local/lib/python3.9/site-packages/cleo/commands/base_command.py:118 in run
       116β”‚         io.input.validate()
       117β”‚
     β†’ 118β”‚         status_code = self.execute(io)
       119β”‚
       120β”‚         if status_code is None:

   4  /usr/local/lib/python3.9/site-packages/cleo/commands/command.py:85 in execute
        83β”‚
        84β”‚         try:
     β†’  85β”‚             return self.handle()
        86β”‚         except KeyboardInterrupt:
        87β”‚             return 1

   3  /usr/local/lib/python3.9/site-packages/poetry/console/commands/plugin/show.py:42 in handle
        40β”‚
        41β”‚         system_env = EnvManager.get_system_env(naive=True)
     β†’  42β”‚         installed_repository = InstalledRepository.load(
        43β”‚             system_env, with_dependencies=True
        44β”‚         )

   2  /usr/local/lib/python3.9/site-packages/poetry/repositories/installed_repository.py:247 in load
       245β”‚                     continue
       246β”‚
     β†’ 247β”‚                 package = cls.create_package_from_distribution(distribution, env)
       248β”‚
       249β”‚                 if with_dependencies:

   1  /usr/local/lib/python3.9/site-packages/poetry/repositories/installed_repository.py:111 in create_package_from_distribution
       109β”‚             and path.joinpath("direct_url.json").exists()
       110β”‚         ):
     β†’ 111β”‚             return cls.create_package_from_pep610(distribution)
       112β”‚
       113β”‚         is_standard_package = env.is_path_relative_to_lib(path)

  KeyError

  'requested_revision'

  at /usr/local/lib/python3.9/site-packages/poetry/repositories/installed_repository.py:201 in create_package_from_pep610
      197β”‚         elif "vcs_info" in url_reference:
      198β”‚             # VCS distribution
      199β”‚             source_type = url_reference["vcs_info"]["vcs"]
      200β”‚             source_url = url_reference["url"]
    β†’ 201β”‚             source_reference = url_reference["vcs_info"]["requested_revision"]
      202β”‚             source_resolved_reference = url_reference["vcs_info"]["commit_id"]
      203β”‚
      204β”‚         package = Package(
      205β”‚             distribution.metadata["name"],

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:4
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
hwalingacommented, Aug 16, 2021

This is not present in 1.1.7, but is in the preview release 1.2.0a2.

0reactions
dimblebycommented, Nov 6, 2022

fixed at #5274

Read more comments on GitHub >

github_iconTop Results From Across the Web

PEP 610 – Recording the Direct URL Origin of installed ...
If no revision was provided in the requested URL, resolved_revision MAY contain the default branch that was installed, andΒ ...
Read more >
FEDERAL REGISTER
The FEDERAL REGISTER (ISSN 0097–6326) is published daily,. Monday through Friday, except official holidays, by the Office.
Read more >
Minnesota CDL Manual
In Minnesota, the following drivers are not required to hold a CDL: ... Make a counterfeit driver's license or Minnesota identification card.
Read more >
NHRA Accepted Products Table of Contents
Assembly consists of rod, piston, pin, complete ring package, ... Highlighted items designate recently added since last revision.
Read more >
Getting to Grips with Aircraft Performance
P.E.P FOR WINDOWS ... deploying speed brakes) to stop the aeroplane during ... that was not required to meet the latest standards.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found