-
Notifications
You must be signed in to change notification settings - Fork 698
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
--directory
should resolve relative paths relative to current working directory
#5613
Comments
Uv run's external command is opaque (in meaning), so it's not possible to translate those arguments. One part of the solution for uv run could be either to never change current directory, or set cwd back to the original for the child process. |
I was thinking that we’d remove the current set_directory call, and then pass around a project directory as dictated by the directory flag. |
Do you have any timeline for this change by any chance? I'm currently using the hidden One example where paths relative to the current directory are necessary is when running uv commands from pre-commit local hooks, paths of the files staged for commit are automatically passed to the hook entry (uv command in this case) and the user cannot control this behavior. Thanks for uv it is looking great! |
per #6733 (comment) our existing behavior matches the Git and Cargo CLIs so we're very unlikely to change it. The pre-commit example is great though. How do people work around this in other tools? Why do you need to use |
Thanks for the quick reply. my-project/ We also have a local hook for mypy something like:
We want to run the mypy command from the virtual environment that has all the python dependencies so that mypy can resolve and follow all the imports when running the type checks. Because of the behavior of However, when the commit hook is triggered by pre-commit, we have less control. And since the paths are resolved relative to the In our case, we managed to get around it by moving the |
Btw, I'm not sure if it helps, but we are in the process of migrating from poetry to uv. I can confirm that in the case of poetry, the behavior is not similar to cargo or git. It resolves paths based on the working directory. For example, this is the same hook I mentioned in my previous comment, before the migration to uv:
Notice how despite the |
@zanieb Unlikely to implement this issue? What do you think about adding a separate flag to uv run with the behaviour intended by this issue? |
If we again look at git it has git -C x --git-dir y and maybe this could be a good model. Uv can have one flag that changes directory, like -C and one flag that points out which project or pyproject.toml to discover and use as starting point. For convenience, this second project flag should also take a directory value. Of course in the normal case these are linked and can be used for similar tasks. |
Expanding on the comment from bluss -- What about adding |
One more idea: if For example:
I would use both of these forms for adding |
I am open to a dedicated |
We are also very interested in a (Another solution for us would be if |
When I take a first look at this, I think Lines 103 to 129 in e36cc99
|
I'm also willing to have |
I think project is pretty straightforward since it’s limited in scope as to what it affects. I assume it affects project discovery and maybe python-version? |
I'll do it. |
Epic. Sounds good to me. The |
Thanks for implementing this! It works perfectly for our needs :) |
That's great to hear :) |
No description provided.
The text was updated successfully, but these errors were encountered: