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 autosync(and --sync/--no-sync ) to rye run #886

Open
rtaycher opened this issue Mar 14, 2024 · 4 comments · May be fixed by #1005 or #1006
Open

Add autosync(and --sync/--no-sync ) to rye run #886

rtaycher opened this issue Mar 14, 2024 · 4 comments · May be fixed by #1005 or #1006

Comments

@rtaycher
Copy link

These have already been added for rye add/rye remove when using uv as a backend.

It's really useful to be able to install all the dependencies when running python via rye run python or rye run ipython/an app/etc. And thanks to uv it will be super fast.

Basically I'd like for it to be possible for everyone working on the project to git pull/git checkout $branch and then
rye run python script.py/ rye run uvicorn main:app --reload/etc and have everything install from the latest/appropriate checked in lock files(probably no need to regenerate the lock file cause you're not modifying them with the run command).

I'm also not quite certain how the python shim at $HOME/.rye/shims/python works. It's not the python binary right? I think it calls
shims.rs
execute_shim/get_shim_target right? If so it would be even nicer to add autosync to the shim so that before running a script "directly"/ as python script.py you'd still get the automatically sync-ed environment.

I maintain the python "environment" for our team at work and this would be really helpful.

@rtaycher
Copy link
Author

rtaycher commented Mar 14, 2024

Possibly it could be use a separate autosync_run setting if people prefer to have it for add/remove but not run (or vice versa).

@khvn26
Copy link

khvn26 commented Apr 9, 2024

It's worth mentioning that rye test already integrates autosync, but it does regenerate the lock, which is not the desirable behaviour.

@khvn26
Copy link

khvn26 commented Apr 9, 2024

it does regenerate the lock, which is not the desirable behaviour

After some research, I found that autosync invokes sync with update_all == false, which prompts both pip-sync and uv to avoid updating the locked dependencies. This does look like a good option for command-specific autosync.

However, for rye run and run test, I'd prefer to only invoke the locking backend if the lock file is not present, and otherwise skip to simply installing the dependencies.

A special SyncMode could be added to accommodate for this.

@khvn26
Copy link

khvn26 commented Jul 18, 2024

@mitsuhiko @charliermarsh Let me know if you want me to rebase my PR(s) so we can close 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
2 participants