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

Urlspec dependency with environment markers within pyproject.toml dependencies section is reported as pep508 offending rule #13028

Open
1 task done
dre-hh opened this issue Oct 17, 2024 · 3 comments
Labels
S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior

Comments

@dre-hh
Copy link

dre-hh commented Oct 17, 2024

Description

An urlspec dependency with environment makers when used in a pyproject.toml dependecies section
is reported as a pep508 rule. When same dependency is used in a requirements.txt file it is installed correctly.
Regular pacakge dependecies with environment makers do not cause the error.

Example urlspec dependency with environment markers:
torch @ https://download.pytorch.org/whl/cpu/torch-2.3.1%2Bcpu-cp311-cp311-linux_x86_64.whl; platform_system == 'Linux' and platform_machine == 'x86_64'

Example pyproject.toml:

[build-system]
requires = ["setuptools>=68.0.0", "setuptools-scm", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "demo"
requires-python = ">=3.11"
dynamic = ["version"]
dependencies = [
    "torch @ https://download.pytorch.org/whl/cpu/torch-2.3.1%2Bcpu-cp311-cp311-linux_x86_64.whl; platform_system == 'Linux' and platform_machine == 'x86_64'",
    "torch >=2.2.2, <3.0.0; platform_system == 'Darwin' and platform_machine == 'arm64'",
]

[tool.setuptools]
packages = ["demo"]

[tool.black]
line-length = 100
pip install . --verbose

=> 
Running command Getting requirements to build wheel
  configuration error: `project.dependencies[13]` must be pep508
  DESCRIPTION:
      Project dependency specification according to PEP 508

  GIVEN VALUE:
      "torch @ https://download.pytorch.org/whl/cpu/torch-2.3.1%2Bcpu-cp311-cp311-linux_x86_64.whl#sha256=a272defe305dbd944aa28a91cc3db0f0149495b3ebec2e39723a7224fa05dc57; platform_system == 'Linux' and platform_machine == 'x86_64'"

  OFFENDING RULE: 'format'

  DEFINITION:
      {
          "$id": "#/definitions/dependency",
          "title": "Dependency",
          "type": "string",
          "format": "pep508"
      }

  For more details about `format` see
  https://validate-pyproject.readthedocs.io/en/latest/api/validate_pyproject.formats.html

Expected behavior

The urlspec dependency must be installed on the respective system specified by environment markers.

According to following grammar rule:
quoted_marker can optionally be added after urlspec

url_req       = (name:n wsp* extras?:e wsp* urlspec:v (wsp+ | end) quoted_marker?:m
                 -> (n, e or [], v, m))

pip version

24.2

Python version

3.11

OS

Mac OS arm64, linux x86_64

How to Reproduce

  1. Create a pyproject.toml example file submitted above.
  2. Run pip install -e . --verbose in the same directory

Output

Obtaining file:///Users/dre/src/pers_behaviour-cluster-ranking/pkg
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... error
  error: subprocess-exited-with-error

  × Getting requirements to build editable did not run successfully.
  │ exit code: 1
  ╰─> [56 lines of output]
      configuration error: `project.dependencies[13]` must be pep508
      DESCRIPTION:
          Project dependency specification according to PEP 508

      GIVEN VALUE:
          "torch @ https://download.pytorch.org/whl/cpu/torch-2.3.1%2Bcpu-cp311-cp311-linux_x86_64.whl; platform_system == 'Linux' and platform_machine == 'x86_64'"

      OFFENDING RULE: 'format'

      DEFINITION:
          {
              "$id": "#/definitions/dependency",
              "title": "Dependency",
              "type": "string",
              "format": "pep508"
          }

      For more details about `format` see
      https://validate-pyproject.readthedocs.io/en/latest/api/validate_pyproject.formats.html

      Traceback (most recent call last):
        File "/Users/dre/src/pers_behaviour-cluster-ranking/pkg/.direnv/python-3.11/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/Users/dre/src/pers_behaviour-cluster-ranking/pkg/.direnv/python-3.11/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/dre/src/pers_behaviour-cluster-ranking/pkg/.direnv/python-3.11/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 132, in get_requires_for_build_editable
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/hq/6tp22gmj3ss5j2dw42q6m0dc2wv_r8/T/pip-build-env-bp2kzi38/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 477, in get_requires_for_build_editable
          return self.get_requires_for_build_wheel(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/hq/6tp22gmj3ss5j2dw42q6m0dc2wv_r8/T/pip-build-env-bp2kzi38/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 332, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=[])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/hq/6tp22gmj3ss5j2dw42q6m0dc2wv_r8/T/pip-build-env-bp2kzi38/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 302, in _get_build_requires
          self.run_setup()
        File "/private/var/folders/hq/6tp22gmj3ss5j2dw42q6m0dc2wv_r8/T/pip-build-env-bp2kzi38/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 318, in run_setup
          exec(code, locals())
        File "<string>", line 1, in <module>
        File "/private/var/folders/hq/6tp22gmj3ss5j2dw42q6m0dc2wv_r8/T/pip-build-env-bp2kzi38/overlay/lib/python3.11/site-packages/setuptools/__init__.py", line 117, in setup
          return distutils.core.setup(**attrs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/hq/6tp22gmj3ss5j2dw42q6m0dc2wv_r8/T/pip-build-env-bp2kzi38/overlay/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 157, in setup
          dist.parse_config_files()
        File "/private/var/folders/hq/6tp22gmj3ss5j2dw42q6m0dc2wv_r8/T/pip-build-env-bp2kzi38/overlay/lib/python3.11/site-packages/setuptools/dist.py", line 647, in parse_config_files
          pyprojecttoml.apply_configuration(self, filename, ignore_option_errors)
        File "/private/var/folders/hq/6tp22gmj3ss5j2dw42q6m0dc2wv_r8/T/pip-build-env-bp2kzi38/overlay/lib/python3.11/site-packages/setuptools/config/pyprojecttoml.py", line 71, in apply_configuration
          config = read_configuration(filepath, True, ignore_option_errors, dist)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/hq/6tp22gmj3ss5j2dw42q6m0dc2wv_r8/T/pip-build-env-bp2kzi38/overlay/lib/python3.11/site-packages/setuptools/config/pyprojecttoml.py", line 139, in read_configuration
          validate(subset, filepath)
        File "/private/var/folders/hq/6tp22gmj3ss5j2dw42q6m0dc2wv_r8/T/pip-build-env-bp2kzi38/overlay/lib/python3.11/site-packages/setuptools/config/pyprojecttoml.py", line 60, in validate
          raise ValueError(f"{error}\n{summary}") from None
      ValueError: invalid pyproject.toml config: `project.dependencies[13]`.
      configuration error: `project.dependencies[13]` must be pep508
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build editable did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

Code of Conduct

@dre-hh dre-hh added S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels Oct 17, 2024
@dre-hh dre-hh changed the title Urlspec dependency with environment markers within pyproject.toml dependcies is reported as pep508 offending rule Urlspec dependency with environment markers within pyproject.toml dependencies section is reported as pep508 offending rule Oct 17, 2024
@pfmoore
Copy link
Member

pfmoore commented Oct 17, 2024

As the note in the output says, this error is not coming from pip, but from a subprocess - in this case, setuptools (your build backend). It looks like the problem is actually in validate-pyproject (a dependency of setuptools) so I'd start by reporting this issue to them.

@dre-hh
Copy link
Author

dre-hh commented Oct 17, 2024

Just figured also, thx.
Submitted in setuptools - pypa/setuptools#4690

@abravalheri
Copy link

Please try to add a space before the ; otherwise the parser thinks this character is part of the URL.

See pypa/setuptools#4690 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

No branches or pull requests

3 participants