Don't require setuptools_rust at runtime (#13952)

This commit is contained in:
David Robertson 2022-09-29 21:16:08 +01:00 committed by GitHub
parent 15754d720f
commit 6f0c3e669d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 3 deletions

View file

@ -66,6 +66,21 @@ def _is_dev_dependency(req: Requirement) -> bool:
)
def _should_ignore_runtime_requirement(req: Requirement) -> bool:
# This is a build-time dependency. Irritatingly, `poetry build` ignores the
# requirements listed in the [build-system] section of pyproject.toml, so in order
# to support `poetry install --no-dev` we have to mark it as a runtime dependency.
# See discussion on https://github.com/python-poetry/poetry/issues/6154 (it sounds
# like the poetry authors don't consider this a bug?)
#
# In any case, workaround this by ignoring setuptools_rust here. (It might be
# slightly cleaner to put `setuptools_rust` in a `build` extra or similar, but for
# now let's do something quick and dirty.
if req.name == "setuptools_rust":
return True
return False
class Dependency(NamedTuple):
requirement: Requirement
must_be_installed: bool
@ -77,7 +92,7 @@ def _generic_dependencies() -> Iterable[Dependency]:
assert requirements is not None
for raw_requirement in requirements:
req = Requirement(raw_requirement)
if _is_dev_dependency(req):
if _is_dev_dependency(req) or _should_ignore_runtime_requirement(req):
continue
# https://packaging.pypa.io/en/latest/markers.html#usage notes that