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

sync not using flags informations from the lock file #825

Closed
FelipeCybis opened this issue Mar 3, 2024 · 5 comments · Fixed by #830
Closed

sync not using flags informations from the lock file #825

FelipeCybis opened this issue Mar 3, 2024 · 5 comments · Fixed by #830

Comments

@FelipeCybis
Copy link

FelipeCybis commented Mar 3, 2024

Hey!

I saw this #677, that closed this #676, but my issue is with the fact that the autosync does not remember the --all-features flag.

Is there a specific reason for this? When developping a package with extra features, and you want to add a new dependency doing rye add package, rye will sync and remove the optional dependencies, so you have to do rye sync --all-features again, for example.

My suggestion would be to have some sort of configuration option to configure sync flags, ideally a per-project option, where I can put something like this:

[tool.rye]
# sync_flag = ["--features docs", "--features plotting"]
sync_flag = ["--all-features"]

Actually I misread the content from the mentioned PR, but this issue still stands for the fact the sync command is not using the flags from the previous sync stored in the lock file.

Thanks for the tool, btw :)

EDIT

Apparently you can have a workaround using what is discussed in #818 by doing

[tool.rye]
dev-dependencies = [
  "-e file:.[docs]"
]

but #818 (comment) says it works more or less by accident and that is why it is not documented, but maybe it would be good to have a nicer way to do it?

@mitsuhiko
Copy link
Collaborator

If it does not remember --all-features then that is a bug. I will look into it. The requirements lock file has a comment specifically to remember that flag.

@FelipeCybis
Copy link
Author

FelipeCybis commented Mar 3, 2024

Ok, since rye sync was not remembering --all-features I misread your text on #676 and thought you were saying pre, features, all-features and with-source needed to be reused every rye sync...

I now understood it well and looked at the .lock files. Indeed, there is some bug when reading the lock files.
Here is what I did:

rye init test
cd test
rye add numpy
# add and sync numpy
rye add --optional=plotting matplotlib
# add matplotlib, normal because sync had no flags when created the lock file
rye sync --features=plotting
# correctly sync matplotlib and writes features: ["plotting"] in the lock file
rye remove numpy
# removes everything including matplotlib

But then I wanted to test some more and

rye add numpy
rye add --optional=plotting matplotlib
# this should sync matplotlib directly because lock file still has features: ["plotting"] on it but it does not
rye sync --all-features
# correctly installs matplotlib and now lock file has features: [], all-features: true
rye sync --features=plotting
# correctly does nothing, but lock file does not change and still has features: [], all-features: true
rye remove numpy
# removes everything again

I also tried a little bit with use-uv: false and it seems to me the results are the same.

@cnpryer
Copy link
Contributor

cnpryer commented Mar 3, 2024

Potentially related comment #811 (comment)

@FelipeCybis FelipeCybis changed the title sync configuration option for remembering synced features sync not using flags informations from the lock file Mar 3, 2024
@FelipeCybis
Copy link
Author

I edited a little bit my issue so it now points to the real issue, sorry for that

@mitsuhiko
Copy link
Collaborator

Found the issue. It's because the lock options are restored too late. I will fix this.

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

Successfully merging a pull request may close this issue.

3 participants