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

Unable to retrieve the package version for git on preview 1.1.0b2 #2761

Closed
2 of 3 tasks
serjflint opened this issue Aug 1, 2020 · 10 comments · Fixed by #2957
Closed
2 of 3 tasks

Unable to retrieve the package version for git on preview 1.1.0b2 #2761

serjflint opened this issue Aug 1, 2020 · 10 comments · Fixed by #2957
Labels
kind/bug Something isn't working as expected

Comments

@serjflint
Copy link

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

Issue

I need the preview build for solving another bug. But now git packages are not working.
Works as intended on the latest release 1.0.10.

  Stack trace:

  9  ~/.poetry/lib/poetry/_vendor/py3.8/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

  8  ~/.poetry/lib/poetry/_vendor/py3.8/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():

  7  ~/.poetry/lib/poetry/_vendor/py3.8/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

  6  ~/.poetry/lib/poetry/_vendor/py3.8/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]

  5  ~/.poetry/lib/poetry/console/commands/add.py:101 in handle
       99│                     raise ValueError("Package {} is already present".format(name))
      100│ 
    → 101│         requirements = self._determine_requirements(
      102│             packages,
      103│             allow_prereleases=self.option("allow-prereleases"),

  4  ~/.poetry/lib/poetry/console/commands/init.py:296 in _determine_requirements
      294│             return requires
      295│ 
    → 296│         requires = self._parse_requirements(requires)
      297│         result = []
      298│         for requirement in requires:

  3  ~/.poetry/lib/poetry/console/commands/init.py:386 in _parse_requirements
      384│                         pair["extras"] = extras
      385│ 
    → 386│                     package = Provider.get_package_from_vcs(
      387│                         "git", url.url, reference=pair.get("rev")
      388│                     )

  2  ~/.poetry/lib/poetry/puzzle/provider.py:209 in get_package_from_vcs
      207│             revision = git.rev_parse(reference, tmp_dir).strip()
      208│ 
    → 209│             package = cls.get_package_from_directory(tmp_dir, name=name)
      210│ 
      211│             package.source_type = "git"

  1  ~/.poetry/lib/poetry/puzzle/provider.py:311 in get_package_from_directory
      309│         cls, directory, name=None
      310│     ):  # type: (Path, Optional[str]) -> Package
    → 311│         package = PackageInfo.from_directory(
      312│             path=directory, allow_build=True
      313│         ).to_package(root_dir=directory)

  RuntimeError

  Unable to retrieve the package version for triopg

  at ~/.poetry/lib/poetry/inspection/info.py:135 in to_package
      131│         name = name or self.name
      132│ 
      133│         if not self.version:
      134│             # The version could not be determined, so we raise an error since it is mandatory.
    → 135│             raise RuntimeError(
      136│                 "Unable to retrieve the package version for {}".format(name)
      137│             )
      138│ 
      139│         package = Package(name=name, version=self.version)

@serjflint serjflint added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Aug 1, 2020
@abn
Copy link
Member

abn commented Aug 1, 2020

@serjflint the issue here is caused by:

https://github.com/python-trio/triopg/blob/19343c5012d43219999e983d03f31e9bdd9415f1/setup.py#L3

Since the version is determined dynamically, we are unable to inspect the version from the file.

Can you try poetry from the master branch? We have an improvement that might address this issue.

@serjflint
Copy link
Author

@abn How to install poetry from source? I didn't find it in the docs

@abn
Copy link
Member

abn commented Aug 1, 2020

If you used the installation script, then you'd want to uninstall before this.

Otherwise, pip install --user git+https://github.com/python-poetry/poetry.git should do the trick.

@serjflint
Copy link
Author

@abn master branch didn't solve the problem and added new messages:

<debug>PackageInfo:</debug> Invalid constraint (Sphinx (~=1.7.3) ; extra == 'dev') found in asyncpg-0.20.1 dependencies, skipping
<debug>PackageInfo:</debug> Invalid constraint (sphinxcontrib-asyncio (~=0.2.0) ; extra == 'dev') found in asyncpg-0.20.1 dependencies, skipping
<debug>PackageInfo:</debug> Invalid constraint (sphinx-rtd-theme (~=0.2.4) ; extra == 'dev') found in asyncpg-0.20.1 dependencies, skipping
<debug>PackageInfo:</debug> Invalid constraint (pycodestyle (~=2.5.0) ; extra == 'dev') found in asyncpg-0.20.1 dependencies, skipping
<debug>PackageInfo:</debug> Invalid constraint (flake8 (~=3.7.9) ; extra == 'dev') found in asyncpg-0.20.1 dependencies, skipping
<debug>PackageInfo:</debug> Invalid constraint (uvloop (~=0.14.0) ; (platform_system != "Windows") and extra == 'dev') found in asyncpg-0.20.1 dependencies, skipping
<debug>PackageInfo:</debug> Invalid constraint (Sphinx (~=1.7.3) ; extra == 'docs') found in asyncpg-0.20.1 dependencies, skipping
<debug>PackageInfo:</debug> Invalid constraint (sphinxcontrib-asyncio (~=0.2.0) ; extra == 'docs') found in asyncpg-0.20.1 dependencies, skipping
<debug>PackageInfo:</debug> Invalid constraint (sphinx-rtd-theme (~=0.2.4) ; extra == 'docs') found in asyncpg-0.20.1 dependencies, skipping
<debug>PackageInfo:</debug> Invalid constraint (pycodestyle (~=2.5.0) ; extra == 'test') found in asyncpg-0.20.1 dependencies, skipping
<debug>PackageInfo:</debug> Invalid constraint (flake8 (~=3.7.9) ; extra == 'test') found in asyncpg-0.20.1 dependencies, skipping
<debug>PackageInfo:</debug> Invalid constraint (uvloop (~=0.14.0) ; (platform_system != "Windows") and extra == 'test') found in asyncpg-0.20.1 dependencies, skipping

1.0.10 works with that repo though

@abn
Copy link
Member

abn commented Aug 1, 2020

@serjflint that one is due to a bug in the pre-release version with respect to parsing ~=. You can test the fix by also installing poetry-core from master too in the same site as poetry install.

@danihodovic
Copy link

I'm still facing the same problem with the install from git master.

@abn
Copy link
Member

abn commented Aug 16, 2020

@danihodovic this requires poetry-core from master. Just confirming you tested with that, not just poetry from master.

@rotu
Copy link
Contributor

rotu commented Sep 24, 2020

I'm having the same issue and it does not appear resolved by installing poetry-core from master:

https://gist.github.com/rotu/307020f80998bcb18f9236f4f79aeb87

$ pip3 list | grep poetry
poetry                     1.1.0b4
poetry-core                1.0.0b1

$ poetry install -vvv
Creating virtualenv colcon in /Users/dan/Documents/colcon_ws/.venv
Using virtualenv: /Users/dan/Documents/colcon_ws/.venv
Updating dependencies
Resolving dependencies...
   1: fact: colcon is 0.0.1
   1: derived: colcon
   1: Version solving took 0.824 seconds.
   1: Tried 1 solutions.

  Stack trace:

  18  ~/.poetry/lib/poetry/_vendor/py3.8/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

  17  ~/.poetry/lib/poetry/_vendor/py3.8/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():

  16  ~/.poetry/lib/poetry/_vendor/py3.8/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

  15  ~/.poetry/lib/poetry/_vendor/py3.8/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]

  14  ~/.poetry/lib/poetry/console/commands/install.py:71 in handle
        69│         self._installer.verbose(self._io.is_verbose())
        70│ 
     →  71│         return_code = self._installer.run()
        72│ 
        73│         if return_code != 0:

  13  ~/.poetry/lib/poetry/installation/installer.py:99 in run
        97│         local_repo = Repository()
        98│ 
     →  99│         return self._do_install(local_repo)
       100│ 
       101│     def dry_run(self, dry_run=True):  # type: (bool) -> Installer

  12  ~/.poetry/lib/poetry/installation/installer.py:205 in _do_install
       203│             )
       204│ 
     → 205│             ops = solver.solve(use_latest=self._whitelist)
       206│         else:
       207│             self._io.write_line("Installing dependencies from lock file")

  11  ~/.poetry/lib/poetry/puzzle/solver.py:65 in solve
        63│         with self._provider.progress():
        64│             start = time.time()
     →  65│             packages, depths = self._solve(use_latest=use_latest)
        66│             end = time.time()
        67│ 

  10  ~/.poetry/lib/poetry/puzzle/solver.py:233 in _solve
       231│ 
       232│         try:
     → 233│             result = resolve_version(
       234│                 self._package, self._provider, locked=locked, use_latest=use_latest
       235│             )

   9  ~/.poetry/lib/poetry/mixology/__init__.py:7 in resolve_version
       5│     solver = VersionSolver(root, provider, locked=locked, use_latest=use_latest)
       6│ 
     → 7│     return solver.solve()
       8│ 

   8  ~/.poetry/lib/poetry/mixology/version_solver.py:84 in solve
        82│             while next is not None:
        83│                 self._propagate(next)
     →  84│                 next = self._choose_package_version()
        85│ 
        86│             return self._result()

   7  ~/.poetry/lib/poetry/mixology/version_solver.py:392 in _choose_package_version
       390│             return dependency.complete_name
       391│ 
     → 392│         version = self._provider.complete_package(version)
       393│ 
       394│         conflict = False

   6  ~/.poetry/lib/poetry/puzzle/provider.py:446 in complete_package
       444│                 self.search_for_file(r)
       445│             elif r.is_vcs():
     → 446│                 self.search_for_vcs(r)
       447│             elif r.is_url():
       448│                 self.search_for_url(r)

   5  ~/.poetry/lib/poetry/puzzle/provider.py:159 in search_for_vcs
       157│             return [self._deferred_cache[dependency]]
       158│ 
     → 159│         package = self.get_package_from_vcs(
       160│             dependency.vcs,
       161│             dependency.source,

   4  ~/.poetry/lib/poetry/puzzle/provider.py:197 in get_package_from_vcs
       195│             revision = git.rev_parse(reference, tmp_dir).strip()
       196│ 
     → 197│             package = cls.get_package_from_directory(tmp_dir, name=name)
       198│             package._source_type = "git"
       199│             package._source_url = url

   3  ~/.poetry/lib/poetry/puzzle/provider.py:280 in get_package_from_directory
       278│         cls, directory, name=None
       279│     ):  # type: (Path, Optional[str]) -> Package
     → 280│         package = PackageInfo.from_directory(path=directory).to_package(
       281│             root_dir=directory
       282│         )

   2  ~/.poetry/lib/poetry/inspection/info.py:142 in to_package
       140│             )
       141│ 
     → 142│         package = Package(
       143│             name=name,
       144│             version=self.version,

   1  ~/.poetry/lib/poetry/_vendor/py3.8/poetry/core/packages/package.py:61 in __init__
        59│ 
        60│         if not isinstance(version, Version):
     →  61│             self._version = Version.parse(version)
        62│             self._pretty_version = pretty_version or version
        63│         else:

  ParseVersionError

  Unable to parse "attr: colcon_argcomplete.__version__".

  at ~/.poetry/lib/poetry/_vendor/py3.8/poetry/core/semver/version.py:206 in parse
      202│         except TypeError:
      203│             match = None
      204│ 
      205│         if match is None:
    → 206│             raise ParseVersionError('Unable to parse "{}".'.format(text))
      207│ 
      208│         text = text.rstrip(".")
      209│ 
      210│         major = int(match.group(1))

@abn abn closed this as completed in #2957 Sep 27, 2020
abn pushed a commit that referenced this issue Sep 27, 2020
This change ensures that invalid versions in setup files raises an 
error and gracefully fallsback to PEP 517 builds to discover package
metadata.

Resolves: #2761
@rotu
Copy link
Contributor

rotu commented Sep 28, 2020

Sweet! Can confirm my issue is resolved under Poetry master.

@abn abn removed the status/triage This issue needs to be triaged label Mar 3, 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
kind/bug Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants