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

name field required for package-mode false after migrating to [project] #10031

Closed
johnthagen opened this issue Jan 13, 2025 · 6 comments · Fixed by #10033
Closed

name field required for package-mode false after migrating to [project] #10031

johnthagen opened this issue Jan 13, 2025 · 6 comments · Fixed by #10033
Labels
kind/bug Something isn't working as expected status/triage This issue needs to be triaged

Comments

@johnthagen
Copy link
Contributor

johnthagen commented Jan 13, 2025

Description

I migrated this pyproject.toml file:

[tool.poetry]
package-mode = false

[tool.poetry.dependencies]
python = ">=3.10"
mkdocs = "*"

To the new equivalent [project] section:

[project]
requires-python = ">=3.10"
dependencies = [
    "mkdocs",
]

[tool.poetry]
package-mode = false

But are presented with an error trying to lock or sync the dependencies (poetry check also fails):

$ poetry sync

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

With package-mode = false, I would expect all package/wheel metadata to still remain optional.

Workarounds

Adding a boilerplate name section back

[project]
name = "a"
requires-python = ">=3.10"
dependencies = [
    "mkdocs",
]

[tool.poetry]
package-mode = false

Poetry Installation Method

pipx

Operating System

Windows 10

Poetry Version

Poetry (version 2.0.1)

Poetry Configuration

cache-dir = "C:\\Users\\User\\AppData\\Local\\pypoetry\\Cache"
installer.max-workers = null
installer.no-binary = null
installer.only-binary = null
installer.parallel = true
installer.re-resolve = true
keyring.enabled = true
requests.max-retries = 0
solver.lazy-wheel = true
system-git-client = false
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}\\virtualenvs"  # C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs
virtualenvs.prompt = "{project_name}-py{python_version}"
virtualenvs.use-poetry-python = false

Python Sysconfig

sysconfig.log
Platform: "win-amd64"
Python version: "3.10"
Current installation scheme: "nt"

Paths: 
      data = "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\poetry-test-CSqu6s7h-py3.10"
      include = "C:\Program Files\Python310\Include"
      platinclude = "C:\Program Files\Python310\Include"
      platlib = "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\poetry-test-CSqu6s7h-py3.10\Lib\site-packages"
      platstdlib = "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\poetry-test-CSqu6s7h-py3.10\Lib"
      purelib = "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\poetry-test-CSqu6s7h-py3.10\Lib\site-packages"
      scripts = "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\poetry-test-CSqu6s7h-py3.10\Scripts"
      stdlib = "C:\Program Files\Python310\Lib"

Variables: 
      BINDIR = "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\poetry-test-CSqu6s7h-py3.10\Scripts"
      BINLIBDEST = "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\poetry-test-CSqu6s7h-py3.10\Lib"
      EXE = ".exe"
      EXT_SUFFIX = ".cp310-win_amd64.pyd"
      INCLUDEPY = "C:\Program Files\Python310\Include"
      LIBDEST = "C:\Program Files\Python310\Lib"
      SO = ".cp310-win_amd64.pyd"
      TZPATH = ""
      VERSION = "310"
      abiflags = ""
      base = "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\poetry-test-CSqu6s7h-py3.10"    
      exec_prefix = "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\poetry-test-CSqu6s7h-py3.10"
      installed_base = "C:\Program Files\Python310"
      installed_platbase = "C:\Program Files\Python310"
      platbase = "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\poetry-test-CSqu6s7h-py3.10"
      platlibdir = "lib"
      prefix = "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\poetry-test-CSqu6s7h-py3.10"  
      projectbase = "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\poetry-test-CSqu6s7h-py3.10\Scripts"
      py_version = "3.10.11"
      py_version_nodot = "310"
      py_version_nodot_plat = "310"
      py_version_short = "3.10"
      srcdir = "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\poetry-test-CSqu6s7h-py3.10\Scripts"
      userbase = "C:\Users\User\AppData\Roaming\Python"

Poetry Runtime Logs

poetry-runtime.log
poetry check -vvv

Stack trace:

11  ~\.local\pipx\venvs\poetry\Lib\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\Lib\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\Lib\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\Lib\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\Lib\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\Lib\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\Lib\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\Lib\site-packages\poetry\console\commands\check.py:137 in handle      
     135│ 
     136│         # Load poetry config and display errors, if any
   → 137│         poetry_file = self.poetry.file.path
     138│         toml_data = PyProjectTOML(poetry_file).data
     139│         check_result = Factory.validate(toml_data, strict=True)

 3  ~\.local\pipx\venvs\poetry\Lib\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\Lib\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\Lib\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\Lib\site-packages\poetry\core\factory.py:59 in create_poetry
     55│             message = ""
     56│             for error in check_result["errors"]:
     57│                 message += f"  - {error}\n"
     58│
  →  59│             raise RuntimeError("The Poetry configuration is invalid:\n" + message)
     60│
     61│         for warning in check_result["warnings"]:
     62│             logger.warning(warning)
     63│

@johnthagen johnthagen added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Jan 13, 2025
@dimbleby
Copy link
Contributor

duplicate #9988 (comment)

@johnthagen
Copy link
Contributor Author

johnthagen commented Jan 13, 2025

@dimbleby The documentation at the top still says

In package mode, the only required fields are name and version (either in the project section or in the tool.poetry section). Other fields are optional. In non-package mode, all fields are optional.

Also, then why is the version field allowed to be omitted in package-mode = false? According to the spec:

The keys which are required but may be specified either statically or listed as dynamic are:

  • version

To me this indicates that version should always be required as well, it's just that it can be set to dynamic as a possible option.

(I'd personally would like if you didn't need name or version in this package-mode = false, but if we are going to follow the spec, I think Poetry should enforce having both).

@dimbleby
Copy link
Contributor

sure, that would seem like a better bug report - albeit not in the direction that you wanted.

If you don't want a package, then I guess you should not be using the project table - whose purpose and definition is packaging.

(else petition the PyPA to change the definition of that table to allow non-packaging use cases)

@johnthagen
Copy link
Contributor Author

johnthagen commented Jan 13, 2025

@dimbleby Sounds good. I'll make a new issue and also open a PR to fix the docs mentioned earlier to close this issue.

@johnthagen
Copy link
Contributor Author

@johnthagen
Copy link
Contributor Author

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
2 participants