We are having problems with excluded libraries when generate hashes is enabled.
Create a new project with rye init
Add jinja2 as a dependency rye add jinja2.
Add exclusion rye add --excluded markupsafe
Set generate-hashes = true on pyproject.toml
Run rye sync to update the environment
Check if markupsafe is installed with rye run python -c "import markupsafe; print(markupsafe.__version__)"
In this minimal example I'm using jinja2 only for testing purposes because this has only one dependency. Similarly, since it's just an example, it's not that we want to exclude markupsafe for jinja2 in a real life example. On the project we are working on we are trying to exclude many dependencies for torch.
Also, if I set generate-hashes = false this works as expected.
We expect that the lockfile looks something like this:
# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
# pre: false
# features: []
# all-features: false
# with-sources: false
# generate-hashes: false
# universal: true
-e file:.
jinja2==3.1.4
--hash=sha256:4a3aee7acbbe7303aede8e9648d13b8bf88a429282aa6122a993f0ac800cb369 \
--hash=sha256:bc5dd2abb727a5319567b7a813e6a2e7318c39f4f487cfe6c89c6f9c7d25197d
# via exclude-rye-test
# markupsafe==2.1.5 (excluded)
# via jinja2
And we expect that MarkupSafe won't be installed.
$ rye run python -c "import markupsafe; print(markupsafe.__version__)"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'markupsafe'
Oh, I think Rye tries to parse each line in the requirements file to compare against the user-provided list, and fails to parse the name out of markupsafe==2.1.5 \ (which is followed by hashes).
Steps to Reproduce
We are having problems with excluded libraries when generate hashes is enabled.
rye init
rye add jinja2
.rye add --excluded markupsafe
generate-hashes = true
onpyproject.toml
rye sync
to update the environmentrye run python -c "import markupsafe; print(markupsafe.__version__)"
In this minimal example I'm using jinja2 only for testing purposes because this has only one dependency. Similarly, since it's just an example, it's not that we want to exclude markupsafe for jinja2 in a real life example. On the project we are working on we are trying to exclude many dependencies for
torch
.Also, if I set
generate-hashes = false
this works as expected.The final
pyproject.toml
looks like thisExpected Result
We expect that the lockfile looks something like this:
And we expect that MarkupSafe won't be installed.
Actual Result
The lockfile in this example looks like this
And the library is installed
Version Info
rye 0.39.0 commit: 0.39.0 (bf3ccf818 2024-08-21) platform: linux (x86_64) self-python: cpython@3.12.4 symlink support: true uv enabled: true
Stacktrace
No response