Closed whi-tw closed 1 year ago
After manually adding the dependency to pyproject.toml
:
[project]
dependencies = [
...
"django_discord_py @ git+https://github.com/MrSage/django_discord.py.git@main",
]
rye sync
fails. Adding:
[tool.hatch.metadata]
allow-direct-references = true
resolves the problem (https://hatch.pypa.io/latest/config/metadata/#allowing-direct-references)
The main reason for the error is that the PackageFinder
method in unearth
returns version None for direct references, which causes the final failure. I'm not sure if mitsuhiko has any other ideas, but I can try to fix this bug if it needsthis.
@ischaojie would be super happy to get a PR for this. Probably will take a bit until I get to it otherwise.
Thank you @ischaojie!
This issue still seems to persist.
$ rye --version
rye 0.8.0
commit: 0.8.0 (a6d6c7935 2023-06-18)
platform: windows (x86_64)
self-python: cpython@3.10
symlink support: false
$ rye add validators --git https://github.com/python-validators/validators --tag latest
$ rye sync
Reusing already existing virtualenv
Generating production lockfile: $HOME/Documents/DevSpace/Projects/linkeeper/requirements.lock
error: subprocess-exited-with-error
× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [24 lines of output]
Traceback (most recent call last):
File "$HOME/.rye/pip-tools/cpython@3.11/Lib/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
main()
File "$HOME/.rye/pip-tools/cpython@3.11/Lib/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "$HOME/.rye/pip-tools/cpython@3.11/Lib/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 152, in prepare_metadata_for_build_wheel
whl_basename = backend.build_wheel(metadata_directory, config_settings)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "$HOME/AppData/Local/Temp/pip-build-env-2sgjz9ry/overlay/Lib/site-packages/hatchling/build.py", line 56, in build_wheel
return os.path.basename(next(builder.build(wheel_directory, ['standard'])))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "$HOME/AppData/Local/Temp/pip-build-env-2sgjz9ry/overlay/Lib/site-packages/hatchling/builders/plugin/interface.py", line 93, in build
self.metadata.validate_fields()
File "$HOME/AppData/Local/Temp/pip-build-env-2sgjz9ry/overlay/Lib/site-packages/hatchling/metadata/core.py", line 244, in validate_fields
self.core.validate_fields()
File "$HOME/AppData/Local/Temp/pip-build-env-2sgjz9ry/overlay/Lib/site-packages/hatchling/metadata/core.py", line 1325, in validate_fields
getattr(self, attribute)
File "$HOME/AppData/Local/Temp/pip-build-env-2sgjz9ry/overlay/Lib/site-packages/hatchling/metadata/core.py", line 1200, in dependencies
self._dependencies = list(self.dependencies_complex)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "$HOME/AppData/Local/Temp/pip-build-env-2sgjz9ry/overlay/Lib/site-packages/hatchling/metadata/core.py", line 1186, in dependencies_complex
raise ValueError(message)
ValueError: Dependency #4 of field `project.dependencies` cannot be a direct reference unless field `tool.hatch.metadata.allow-direct-references` is set to `true`
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
Traceback (most recent call last):
File "$HOME/.rye/pip-tools/cpython@3.11/Lib/site-packages/pip/_internal/operations/build/metadata.py", line
35, in generate_metadata
distinfo_dir = backend.prepare_metadata_for_build_wheel(metadata_dir)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "$HOME/.rye/pip-tools/cpython@3.11/Lib/site-packages/pip/_internal/utils/misc.py", line 713, in prepare_metadata_for_build_wheel
return super().prepare_metadata_for_build_wheel(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "$HOME/.rye/pip-tools/cpython@3.11/Lib/site-packages/pip/_vendor/pyproject_hooks/_impl.py", line 186, in prepare_metadata_for_build_wheel
return self._call_hook('prepare_metadata_for_build_wheel', {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "$HOME/.rye/pip-tools/cpython@3.11/Lib/site-packages/pip/_vendor/pyproject_hooks/_impl.py", line 311, in _call_hook
self._subprocess_runner(
File "$HOME/.rye/pip-tools/cpython@3.11/Lib/site-packages/pip/_internal/utils/subprocess.py", line 252, in runner
call_subprocess(
File "$HOME/.rye/pip-tools/cpython@3.11/Lib/site-packages/pip/_internal/utils/subprocess.py", line 224, in call_subprocess
raise error
pip._internal.exceptions.InstallationSubprocessError: Preparing metadata (pyproject.toml) exited with 1
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "$HOME/.rye/pip-tools/cpython@3.11/Scripts/pip-compile.exe/__main__.py", line 7, in <module>
File "$HOME/.rye/pip-tools/cpython@3.11/Lib/site-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "$HOME/.rye/pip-tools/cpython@3.11/Lib/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "$HOME/.rye/pip-tools/cpython@3.11/Lib/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "$HOME/.rye/pip-tools/cpython@3.11/Lib/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "$HOME/.rye/pip-tools/cpython@3.11/Lib/site-packages/click/decorators.py", line 26, in new_func
return f(get_current_context(), *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "$HOME/.rye/pip-tools/cpython@3.11/Lib/site-packages/piptools/scripts/compile.py", line 592, in cli
results = resolver.resolve(max_rounds=max_rounds)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "$HOME/.rye/pip-tools/cpython@3.11/Lib/site-packages/piptools/resolver.py", line 593, in resolve
is_resolved = self._do_resolve(
^^^^^^^^^^^^^^^^^
File "$HOME/.rye/pip-tools/cpython@3.11/Lib/site-packages/piptools/resolver.py", line 625, in _do_resolve
resolver.resolve(
File "$HOME/.rye/pip-tools/cpython@3.11/Lib/site-packages/pip/_internal/resolution/resolvelib/resolver.py",
line 73, in resolve
collected = self.factory.collect_root_requirements(root_reqs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "$HOME/.rye/pip-tools/cpython@3.11/Lib/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 491, in collect_root_requirements
req = self._make_requirement_from_install_req(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "$HOME/.rye/pip-tools/cpython@3.11/Lib/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 453, in _make_requirement_from_install_req
cand = self._make_candidate_from_link(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "$HOME/.rye/pip-tools/cpython@3.11/Lib/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 185, in _make_candidate_from_link
self._editable_candidate_cache[link] = EditableCandidate(
^^^^^^^^^^^^^^^^^^
File "$HOME/.rye/pip-tools/cpython@3.11/Lib/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 318, in __init__
super().__init__(
File "$HOME/.rye/pip-tools/cpython@3.11/Lib/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 156, in __init__
self.dist = self._prepare()
^^^^^^^^^^^^^^^
File "$HOME/.rye/pip-tools/cpython@3.11/Lib/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 225, in _prepare
dist = self._prepare_distribution()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "$HOME/.rye/pip-tools/cpython@3.11/Lib/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 328, in _prepare_distribution
return self._factory.preparer.prepare_editable_requirement(self._ireq)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "$HOME/.rye/pip-tools/cpython@3.11/Lib/site-packages/pip/_internal/operations/prepare.py", line 687, in prepare_editable_requirement
dist = _get_prepared_distribution(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "$HOME/.rye/pip-tools/cpython@3.11/Lib/site-packages/pip/_internal/operations/prepare.py", line 69, in
_get_prepared_distribution
abstract_dist.prepare_distribution_metadata(
File "$HOME/.rye/pip-tools/cpython@3.11/Lib/site-packages/pip/_internal/distributions/sdist.py", line 61, in prepare_distribution_metadata
self.req.prepare_metadata()
File "$HOME/.rye/pip-tools/cpython@3.11/Lib/site-packages/pip/_internal/req/req_install.py", line 555, in prepare_metadata
self.metadata_directory = generate_metadata(
^^^^^^^^^^^^^^^^^^
File "$HOME/.rye/pip-tools/cpython@3.11/Lib/site-packages/pip/_internal/operations/build/metadata.py", line
37, in generate_metadata
raise MetadataGenerationFailed(package_details=details) from error
pip._internal.exceptions.MetadataGenerationFailed: metadata generation failed
Error: could not write production lockfile for project
Caused by:
failed to generate lockfile
Current workaround (should it be documented?) is to add the following in pyproject.toml
:
[tool.hatch.metadata]
allow-direct-references = true
Steps to Reproduce
Expected Result
adds
django_discord_py @ git+https://github.com/MrSage/django_discord.py.git@main
topyproject.toml
project.dependencies
Actual Result
Version Info
Stacktrace