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

Poetry 2.0 requires a "project.name" config even if "package-mode" is set #9988

Closed
franknarf8 opened this issue Jan 7, 2025 · 4 comments · Fixed by #9989
Closed

Poetry 2.0 requires a "project.name" config even if "package-mode" is set #9988

franknarf8 opened this issue Jan 7, 2025 · 4 comments · Fixed by #9989
Labels
kind/bug Something isn't working as expected status/triage This issue needs to be triaged

Comments

@franknarf8
Copy link
Contributor

franknarf8 commented Jan 7, 2025

Description

I would expect the project.name config to be optional when the tool.poetry.package-mode is false.

[project]
requires-python = ">=3.10,<3.13"
name = "stuff"

[tool.poetry]
package-mode = false

Workarounds

Not specifying anything in the [project] section

Poetry Installation Method

pipx

Operating System

macos

Poetry Version

2.0.0

Example pyproject.toml

[project]
requires-python = ">=3.10,<3.13"

[tool.poetry]
package-mode = false

Poetry Runtime Logs

(non-package-mode-py3.12) ➜  AUR-aurora git:(feature/pyproject-toml) ✗ poetry@2 -vvv check 

  Stack trace:

  11  ~/.local/pipx/venvs/poetry@2/lib/python3.12/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

  10  ~/.local/pipx/venvs/poetry@2/lib/python3.12/site-packages/poetry/console/application.py:236 in _run
       234│ 
       235│         with directory(self._working_directory):
     → 236│             exit_code: int = super()._run(io)
       237│ 
       238│         return exit_code

   9  ~/.local/pipx/venvs/poetry@2/lib/python3.12/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│ 

   8  ~/.local/pipx/venvs/poetry@2/lib/python3.12/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

   7  ~/.local/pipx/venvs/poetry@2/lib/python3.12/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

   6  ~/.local/pipx/venvs/poetry@2/lib/python3.12/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:

   5  ~/.local/pipx/venvs/poetry@2/lib/python3.12/site-packages/cleo/commands/command.py:61 in execute
        59│ 
        60│         try:
     →  61│             return self.handle()
        62│         except KeyboardInterrupt:
        63│             return 1

   4  ~/.local/pipx/venvs/poetry@2/lib/python3.12/site-packages/poetry/console/commands/check.py:132 in handle
       130│ 
       131│         # Load poetry config and display errors, if any
     → 132│         poetry_file = self.poetry.file.path
       133│         toml_data = PyProjectTOML(poetry_file).data
       134│         check_result = Factory.validate(toml_data, strict=True)

   3  ~/.local/pipx/venvs/poetry@2/lib/python3.12/site-packages/poetry/console/commands/command.py:24 in poetry
        22│     def poetry(self) -> Poetry:
        23│         if self._poetry is None:
     →  24│             return self.get_application().poetry
        25│ 
        26│         return self._poetry

   2  ~/.local/pipx/venvs/poetry@2/lib/python3.12/site-packages/poetry/console/application.py:181 in poetry
       179│             return self._poetry
       180│ 
     → 181│         self._poetry = Factory().create_poetry(
       182│             cwd=self._project_directory,
       183│             io=self._io,

   1  ~/.local/pipx/venvs/poetry@2/lib/python3.12/site-packages/poetry/factory.py:60 in create_poetry
        58│             io = NullIO()
        59│ 
     →  60│         base_poetry = super().create_poetry(cwd=cwd, with_groups=with_groups)
        61│ 
        62│         if version_str := base_poetry.local_config.get("requires-poetry"):

  RuntimeError

  The Poetry configuration is invalid:
    - project must contain ['name'] properties
  

  at ~/.local/pipx/venvs/poetry@2/lib/python3.12/site-packages/poetry/core/factory.py:58 in create_poetry
       54│             message = ""
       55│             for error in check_result["errors"]:
       56│                 message += f"  - {error}\n"
       57│ 
    →  58│             raise RuntimeError("The Poetry configuration is invalid:\n" + message)
       59│ 
       60│         for warning in check_result["warnings"]:
       61│             logger.warning(warning)
@franknarf8 franknarf8 added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Jan 7, 2025
@dimbleby
Copy link
Contributor

dimbleby commented Jan 7, 2025

package-mode is a poetry special. The [project] table is defined by PEP621 and if you use that table then there is nothing that poetry can do to make the project name not mandatory. It is mandatory because the spec requires it to be mandatory.

@franknarf8
Copy link
Contributor Author

franknarf8 commented Jan 7, 2025

In that case, maybe the documentation here should be revised : https://python-poetry.org/docs/pyproject/#name

To remove Required in package mode

What do you think?

@dimbleby
Copy link
Contributor

dimbleby commented Jan 7, 2025

sure, go for it!

@franknarf8
Copy link
Contributor Author

Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working as expected status/triage This issue needs to be triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants