Skip to content

✨ Allow patching third-party packages via new command uv patch <pkg_name> #7454

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

Open
jd-solanki opened this issue Sep 17, 2024 · 8 comments
Labels
question Asking for clarification or support

Comments

@jd-solanki
Copy link

Hi πŸ‘‹πŸ»

When working on node based project there's pnpm package manager that allows patching third-party packages installed in node_modules if we want to fix something for all the contributors of the project.

pnpm allows this via patch

I came across similar situation where I want to patch the package "fastapi-users" until I get response on my PR/discussion. I noticed UV don't have such feature.

Thanks for the UV it's superfast πŸš€

@charliermarsh
Copy link
Member

charliermarsh commented Sep 17, 2024

You can patch third-party dependencies via tool.uv.sources. Like, you could clone anyio locally, and then add:

[tool.uv.sources]
anyio = { path = "/path/to/anyio" }

Assuming you make anyio a direct dependency. Is this different than the patch workflow?

@charliermarsh charliermarsh added the question Asking for clarification or support label Sep 17, 2024
@jd-solanki
Copy link
Author

Hi Charlie,

Glad to see you. Unfortunetly, this is not patch workflow. In our case with above solution everyone has to either go through steps you mentioned to start working on project or else we have to commit third-package along with source code with is really bad.

Assume I want to do minor fix in some unmaintained library but we don't prefer forking and making a seperate package just for that minor change. So, in pnpm we run pnpm patch <that-lib> and it'll copy that dep somewhere in temp location where we can edit the dependency however we want for example adding print in python or console.log in node. Once we are done with editing we run pnpm patch-commit <temp-path-where-pnpm-gen-clone> this generates patch (git diff) in our source code as you can see here. Now, whenever someone clone our repo and run pnpm install these patch inside patches directory get applied to node_modules automatically for everyone without any additional steps.

Checkout this pnpm video


Usecases:

  • Making minor fixes in unmaintained libs
  • Continue working on project as a team until lib author merges the PR or addes feature
  • Tweak third party package without extra hassle of maintaining it

@aretrace
Copy link

✨ YES YES YES ✨
uv patch <pkg_name> will be insurmountably useful!

@JonathanPlasse
Copy link

JonathanPlasse commented Jan 3, 2025

That is exactly what I am looking for to allow using fake-bpy-module with custom properties for Blender add-on development.
The patch workflow is especially need here as the fake-bpy-module package is auto-generated and would need every person using it with custom properties to maintain a separate git repository mirroring it with their additional changes for every add-on project.
With the patch workflow, the add-on custom properties would not need to be in to separate repo.

@Avasam
Copy link
Contributor

Avasam commented Mar 7, 2025

Here's some prior art in the npm ecosystem: https://www.npmjs.com/package/patch-package

that package has saved my ass too many times. Also allowed us to enforce better type safety by patching unsafe types directly in the source !

@jd-solanki
Copy link
Author

Hi @charliermarsh We should update the label now from question to something else

@simplegr33n
Copy link

would really appreciate ability to patch 3rd party packages as well, ideally via configuring in pyproject.toml

@calebpitan
Copy link

I feared there was no way to patch packages with uv becuase I can say for sure I've seen every corner of the documentation and I don't remember ever seeing any such thing as "patch package"; now I run to the internet to find out if I can patch a package and my fear wins.

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

No branches or pull requests

7 participants