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

Add new tool.pdm field for editable dependencies #1083

Closed
agoose77 opened this issue May 13, 2022 · 2 comments
Closed

Add new tool.pdm field for editable dependencies #1083

agoose77 opened this issue May 13, 2022 · 2 comments
Labels
⭐ enhancement Improvements for existing features
Milestone

Comments

@agoose77
Copy link
Contributor

agoose77 commented May 13, 2022

Is your feature request related to a problem? Please describe.

Right now PDM supports the specification of editable dependencies with an -e prefix. This is useful, but means that the resulting pyproject.toml file is no longer PEP 508 compliant. If you use a different build backend e.g. hatch, it will fail because of this incompatibility. Besides build backends, there are a myriad of other tools that could try to read this section.

$ pyproject-build -w
* Creating venv isolated environment...
* Installing packages in isolated environment... (hatchling)
* Getting dependencies for wheel...
* Building wheel...
Traceback (most recent call last):
  File "/tmp/build-env-7c0nfg0j/lib/python3.10/site-packages/packaging/requirements.py", line 102, in __init__
    req = REQUIREMENT.parseString(requirement_string)
  File "/tmp/build-env-7c0nfg0j/lib/python3.10/site-packages/pyparsing/core.py", line 1141, in parse_string
    raise exc.with_traceback(None)
pyparsing.exceptions.ParseException: Expected W:(0-9A-Za-z), found '-'  (at char 0), (line:1, col:1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/build-env-7c0nfg0j/lib/python3.10/site-packages/hatchling/metadata/core.py", line 997, in dependencies_complex
    requirement = Requirement(entry)
  File "/tmp/build-env-7c0nfg0j/lib/python3.10/site-packages/packaging/requirements.py", line 104, in __init__
    raise InvalidRequirement(
packaging.requirements.InvalidRequirement: Parse error at "'-e file:'": Expected W:(0-9A-Za-z)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/angus/.local/pipx/venvs/build/lib/python3.10/site-packages/pep517/in_process/_in_process.py", line 363, in <module>
    main()
  File "/home/angus/.local/pipx/venvs/build/lib/python3.10/site-packages/pep517/in_process/_in_process.py", line 345, in main
    json_out['return_val'] = hook(**hook_input['kwargs'])
  File "/home/angus/.local/pipx/venvs/build/lib/python3.10/site-packages/pep517/in_process/_in_process.py", line 261, in build_wheel
    return _build_backend().build_wheel(wheel_directory, config_settings,
  File "/tmp/build-env-7c0nfg0j/lib/python3.10/site-packages/hatchling/build.py", line 41, in build_wheel
    return os.path.basename(next(builder.build(wheel_directory, ['standard'])))
  File "/tmp/build-env-7c0nfg0j/lib/python3.10/site-packages/hatchling/builders/plugin/interface.py", line 77, in build
    self.metadata.core.validate_fields()
  File "/tmp/build-env-7c0nfg0j/lib/python3.10/site-packages/hatchling/metadata/core.py", line 1119, in validate_fields
    getattr(self, attribute)
  File "/tmp/build-env-7c0nfg0j/lib/python3.10/site-packages/hatchling/metadata/core.py", line 1018, in dependencies
    self._dependencies = sorted(self.dependencies_complex)
  File "/tmp/build-env-7c0nfg0j/lib/python3.10/site-packages/hatchling/metadata/core.py", line 999, in dependencies_complex
    raise ValueError('Dependency #{} of field `project.dependencies` is invalid: {}'.format(i, e))
ValueError: Dependency #1 of field `project.dependencies` is invalid: Parse error at "'-e file:'": Expected W:(0-9A-Za-z)

ERROR Backend subproccess exited when trying to invoke build_wheel

Describe the solution you'd like

Remove this "extra" syntax, and add a new tool.pdm field to enumerate the editable packages.

By adding PDM-only metadata to indicate that these are editable packages, we can avoid breaking other tools. At the moment, editable packages are an implementation detail rather than something described by a packaging standard. This would mean that e.g. other build backends would end up using the non-editable version of the package. This seems to me to be the only good option unless a new

[project]
dependencies = [
    "my-local-package>=1.0.0"
]
[tool.pdm]
editable = [
    "my-local-package"
]

I'm sorry that I'm not submitting a PR alongside this. Right now, I just don't have any time to work on OS. I thought I'd create this issue as a TODO-item :)

@agoose77 agoose77 added the ⭐ enhancement Improvements for existing features label May 13, 2022
@frostming frostming added this to the Release 2.0 milestone May 13, 2022
@frostming
Copy link
Collaborator

Hi, I am going to forbid adding editable packages to the [project] table, but they are still allowed in the dev-dependencies table.

This will be a breaking change so I will make it in PDM 2.0, thanks.

@frostming
Copy link
Collaborator

Closed by #1140, please test it on 2.0.0a1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⭐ enhancement Improvements for existing features
Projects
None yet
Development

No branches or pull requests

2 participants