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 create package with no name" #9191

Closed
jakewins opened this issue Mar 21, 2024 · 7 comments
Closed

"Unable to create package with no name" #9191

jakewins opened this issue Mar 21, 2024 · 7 comments
Labels
kind/bug Something isn't working as expected status/triage This issue needs to be triaged

Comments

@jakewins
Copy link

Description

I'm not sure about the exact steps to reproduce this - it's consistently happening on my machine now and I've done some debugging, but I'm not sure how I ended up in this state. I thought it'd be good to open a ticket on case anyone else runs into this error, because googling it turns up nothing.

Briefly:

  • I have a poetry project, which depends on a library project with a PEP517 pyproject.toml file
  • The library lives in git, so is a git dependency
  • When I do poetry lock, it crashes with an error saying Unable to create package with no name

Debugging:

The immediate cause of this is that, when poetry runs get_pep517_metadata, it builds my little library and generates a METADATA file that looks like this:

$ cat METADATA 
Metadata-Version: 2.3
Name: my-library
Version: 1.0.0
Requires-Dist: aiokafka
Requires-Dist: googleapis-common-protos
Requires-Dist: protobuf

And when poetry asks pkginfo to load this, it says "ok boss" and ignores all the contents, because it doesn't support Metadata-Version: 2.3

I'm trying to work out, now:

  • Why is the metadata version 2.3, when the highest supported version on my 3.11.2 python system seems to be 2.2?
  • Should I try to get it to generate a 2.2 file instead, or somehow try to upgrade pkginfo to get one that handles 2.3?

Workarounds

Haven't found one yet

Poetry Installation Method

pipx

Operating System

Arch

Poetry Version

Poetry (version 1.8.2)

Poetry Configuration

cache-dir = "/home/jake/.cache/pypoetry"
experimental.system-git-client = false
installer.max-workers = null
installer.modern-installation = true
installer.no-binary = null
installer.parallel = true
keyring.enabled = true
solver.lazy-wheel = true
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.no-setuptools = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}/virtualenvs"  # /home/jake/.cache/pypoetry/virtualenvs
virtualenvs.prefer-active-python = false
virtualenvs.prompt = "{project_name}-py{python_version}"
warnings.export = true

Python Sysconfig

No response

Example pyproject.toml

No response

Poetry Runtime Logs

[virtualenv] generated console scripts pip3 pip pip-3.11 pip3.11
[virtualenv] add activators for Bash, CShell, Fish, Nushell, PowerShell, Python
[virtualenv] write /tmp/tmp0kdgi2x8/.venv/pyvenv.cfg
[virtualenv] 	home = /home/jake/.pyenv/versions/3.11.2/bin
[virtualenv] 	implementation = CPython
[virtualenv] 	version_info = 3.11.2.final.0
[virtualenv] 	virtualenv = 20.24.3
[virtualenv] 	include-system-site-packages = false
[virtualenv] 	base-prefix = /home/jake/.pyenv/versions/3.11.2
[virtualenv] 	base-exec-prefix = /home/jake/.pyenv/versions/3.11.2
[virtualenv] 	base-executable = /home/jake/.pyenv/versions/3.11.2/bin/python3.11
/tmp/tmp0kdgi2x8/dist
Falling back to parsed setup.py file for /home/jake/.cache/pypoetry/virtualenvs/grid-rewards-XFIntc4Q-py3.11/src/mygitrepo/foo/bar-lib
   1: Version solving took 4.819 seconds.
   1: Tried 1 solutions.

  Stack trace:

  21  ~/.pyenv/versions/3.11.2/lib/python3.11/site-packages/cleo/application.py:327 in run
       325│ 
       326│             try:
     → 327│                 exit_code = self._run(io)
       328│             except BrokenPipeError:
       329│                 # If we are piped to another process, it may close early and send a

  20  ~/.pyenv/versions/3.11.2/lib/python3.11/site-packages/poetry/console/application.py:190 in _run
       188│         self._load_plugins(io)
       189│ 
     → 190│         exit_code: int = super()._run(io)
       191│         return exit_code
       192│ 

  19  ~/.pyenv/versions/3.11.2/lib/python3.11/site-packages/cleo/application.py:431 in _run
       429│             io.input.interactive(interactive)
       430│ 
     → 431│         exit_code = self._run_command(command, io)
       432│         self._running_command = None
       433│ 

  18  ~/.pyenv/versions/3.11.2/lib/python3.11/site-packages/cleo/application.py:473 in _run_command
       471│ 
       472│         if error is not None:
     → 473│             raise error
       474│ 
       475│         return terminate_event.exit_code

  17  ~/.pyenv/versions/3.11.2/lib/python3.11/site-packages/cleo/application.py:457 in _run_command
       455│ 
       456│             if command_event.command_should_run():
     → 457│                 exit_code = command.run(io)
       458│             else:
       459│                 exit_code = ConsoleCommandEvent.RETURN_CODE_DISABLED

  16  ~/.pyenv/versions/3.11.2/lib/python3.11/site-packages/cleo/commands/base_command.py:117 in run
       115│         io.input.validate()
       116│ 
     → 117│         return self.execute(io) or 0
       118│ 
       119│     def merge_application_definition(self, merge_args: bool = True) -> None:

  15  ~/.pyenv/versions/3.11.2/lib/python3.11/site-packages/cleo/commands/command.py:61 in execute
        59│ 
        60│         try:
     →  61│             return self.handle()
        62│         except KeyboardInterrupt:
        63│             return 1

  14  ~/.pyenv/versions/3.11.2/lib/python3.11/site-packages/poetry/console/commands/lock.py:55 in handle
        53│         self.installer.lock(update=not self.option("no-update"))
        54│ 
     →  55│         return self.installer.run()
        56│ 

  13  ~/.pyenv/versions/3.11.2/lib/python3.11/site-packages/poetry/installation/installer.py:104 in run
       102│             self.verbose(True)
       103│ 
     → 104│         return self._do_install()
       105│ 
       106│     def dry_run(self, dry_run: bool = True) -> Installer:

  12  ~/.pyenv/versions/3.11.2/lib/python3.11/site-packages/poetry/installation/installer.py:241 in _do_install
       239│                 source_root=self._env.path.joinpath("src")
       240│             ):
     → 241│                 ops = solver.solve(use_latest=self._whitelist).calculate_operations()
       242│         else:
       243│             self._io.write_line("Installing dependencies from lock file")

  11  ~/.pyenv/versions/3.11.2/lib/python3.11/site-packages/poetry/puzzle/solver.py:71 in solve
        69│         with self._progress(), self._provider.use_latest_for(use_latest or []):
        70│             start = time.time()
     →  71│             packages, depths = self._solve()
        72│             end = time.time()
        73│ 

  10  ~/.pyenv/versions/3.11.2/lib/python3.11/site-packages/poetry/puzzle/solver.py:154 in _solve
       152│ 
       153│         try:
     → 154│             result = resolve_version(self._package, self._provider)
       155│ 
       156│             packages = result.packages

   9  ~/.pyenv/versions/3.11.2/lib/python3.11/site-packages/poetry/mixology/__init__.py:18 in resolve_version
        16│     solver = VersionSolver(root, provider)
        17│ 
     →  18│     return solver.solve()
        19│ 

   8  ~/.pyenv/versions/3.11.2/lib/python3.11/site-packages/poetry/mixology/version_solver.py:175 in solve
       173│             while next is not None:
       174│                 self._propagate(next)
     → 175│                 next = self._choose_package_version()
       176│ 
       177│             return self._result()

   7  ~/.pyenv/versions/3.11.2/lib/python3.11/site-packages/poetry/mixology/version_solver.py:514 in _choose_package_version
       512│             package = locked
       513│ 
     → 514│         package = self._provider.complete_package(package)
       515│ 
       516│         conflict = False

   6  ~/.pyenv/versions/3.11.2/lib/python3.11/site-packages/poetry/puzzle/provider.py:568 in complete_package
       566│                     if locked is not None and locked.package.is_same_package_as(dep):
       567│                         continue
     → 568│                     self.search_for_direct_origin_dependency(dep)
       569│ 
       570│         dependencies = self._get_dependencies_with_overrides(_dependencies, package)

   5  ~/.pyenv/versions/3.11.2/lib/python3.11/site-packages/poetry/puzzle/provider.py:245 in search_for_direct_origin_dependency
       243│         elif dependency.is_vcs():
       244│             dependency = cast("VCSDependency", dependency)
     → 245│             package = self._search_for_vcs(dependency)
       246│ 
       247│         elif dependency.is_file():

   4  ~/.pyenv/versions/3.11.2/lib/python3.11/site-packages/poetry/puzzle/provider.py:323 in _search_for_vcs
       321│         and get the information we need by checking out the specified reference.
       322│         """
     → 323│         package = self._direct_origin.get_package_from_vcs(
       324│             dependency.vcs,
       325│             dependency.source,

   3  ~/.pyenv/versions/3.11.2/lib/python3.11/site-packages/poetry/packages/direct_origin.py:106 in get_package_from_vcs
       104│             raise ValueError(f"Unsupported VCS dependency {vcs}")
       105│ 
     → 106│         return _get_package_from_git(
       107│             url=url,
       108│             branch=branch,

   2  ~/.pyenv/versions/3.11.2/lib/python3.11/site-packages/poetry/packages/direct_origin.py:46 in _get_package_from_git
        44│         path = path.joinpath(subdirectory)
        45│ 
     →  46│     package = DirectOrigin.get_package_from_directory(path)
        47│     package._source_type = "git"
        48│     package._source_url = url

   1  ~/.pyenv/versions/3.11.2/lib/python3.11/site-packages/poetry/packages/direct_origin.py:75 in get_package_from_directory
        73│     @classmethod
        74│     def get_package_from_directory(cls, directory: Path) -> Package:
     →  75│         return PackageInfo.from_directory(path=directory).to_package(root_dir=directory)
        76│ 
        77│     def get_package_from_url(self, url: str) -> Package:

  RuntimeError

  Unable to create package with no name

  at ~/.pyenv/versions/3.11.2/lib/python3.11/site-packages/poetry/inspection/info.py:152 in to_package
      148│         """
      149│         name = name or self.name
      150│ 
      151│         if not name:
    → 152│             raise RuntimeError("Unable to create package with no name")
      153│ 
      154│         if not self.version:
      155│             # The version could not be determined, so we raise an error since it is
      156│             # mandatory.
@jakewins jakewins added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Mar 21, 2024
@dimbleby
Copy link
Contributor

you need to update pkg-info in your poetry installation: either by updating it directly in the appropriate virtual environment or by uninstalling and reinstalling poetry

@jakewins
Copy link
Author

@dimbleby ah! Just reinstalling poetry didn't help, but forcing pkginfo to the latest version seems to have fixed it, I did pip install pkginfo==1.10.0 and now it's rolling again.

I guess.. tracing this it seemed like it ended up, deep in the dungeons, picking a build backend based on what the library specified (hatchling, in this case), and that build backend wasn't compatible with the pkginfo that was installed locally. Man what a jungle this all is! Thanks for helping!

@xkabylgSICKAG
Copy link

xkabylgSICKAG commented Mar 21, 2024

To help make it easier for others who find this issue, if you've installed poetry using the installer script you can fix it with this command: poetry self add pkginfo==1.10.0

@dimbleby
Copy link
Contributor

you can fix this with this command: poetry self add pkginfo==1.10.0

depends how you installed poetry eg if you've done the recommened pipx install then that's not the right command

@phi-friday
Copy link

To help make it easier for others who find this issue, if you've installed poetry using the installer script you can fix it with this command: poetry self add pkginfo==1.10.0

poetry self add keyrings.cryptfile@latest
poetry self add pkginfo==1.10.0

Pinning pkginfo version is essential.

@skycaptain
Copy link

I just encountered this issue. I previously installed poetry through Homebrew, which caused the problem. However, installing poetry with pipx worked perfectly without needing the previously mentioned workarounds.

Copy link

github-actions bot commented May 4, 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 May 4, 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 status/triage This issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

5 participants