admin管理员组文章数量:1398804
I'm developing two Python projects:
- xxx: A Python library I maintain, hosted on GitHub.
- yyy: An open-source project that depends on xxx.
In yyy's pyproject.toml, I declare the dependency as:
[tool.uv.sources]
xxx = { git = "git+.git" }
This works well for others who clone yyy — they get the correct version of xxx from GitHub. However during development, I want to use a local copy of xxx (e.g., ~/xxx) so I can test changes in yyy without pushing to GitHub each time.
I'd like a solution that:
- Lets me use a local path for xxx during development.
- Doesn’t require me to change pyproject.toml before every commit.
- Keeps yyy portable and installable via GitHub for others.
Is there a clean way to override the Git-based dependency locally (perhaps with a .gitignored file or config), while keeping pyproject.toml untouched?
I'm using uv as my Python package manager.
Any best practices or workflows for this setup?
I'm developing two Python projects:
- xxx: A Python library I maintain, hosted on GitHub.
- yyy: An open-source project that depends on xxx.
In yyy's pyproject.toml, I declare the dependency as:
[tool.uv.sources]
xxx = { git = "git+https://github/myuser/xxx.git" }
This works well for others who clone yyy — they get the correct version of xxx from GitHub. However during development, I want to use a local copy of xxx (e.g., ~/xxx) so I can test changes in yyy without pushing to GitHub each time.
I'd like a solution that:
- Lets me use a local path for xxx during development.
- Doesn’t require me to change pyproject.toml before every commit.
- Keeps yyy portable and installable via GitHub for others.
Is there a clean way to override the Git-based dependency locally (perhaps with a .gitignored file or config), while keeping pyproject.toml untouched?
I'm using uv as my Python package manager.
Any best practices or workflows for this setup?
Share Improve this question asked Mar 27 at 13:19 Daniel ChinDaniel Chin 3361 gold badge5 silver badges15 bronze badges1 Answer
Reset to default 0When developing a framework or any library/pypi package, you, of course, want to have a separate project to test it on.
Let say your library project is in ~dev/mylibrary
And your project using it is in ~dev/myapp
From ~dev/myapp
you can simply:
uv pip install -e ../mylibrary
Then you will be able to import mylibrary into myapp without the need to always build it and push to git or pypi, and pulling it every time you update the code.
You also will be able to work on your code in the VS Code or other IDE in 2 projects simultaneously, and quickly changing the code in the library, will immediately work in the app project, so you do not need to run uv again.
However, sometimes, you might face the cache issues. In that case, delete .venv folder, delete all the pycache folders and run uv sync and uv pip install -e ../folder again.
Highly recommend the Project Manager extension for the VS Code. Here are extensions, I am using while developing my own framework and testing it locally.
https://arkalos/docs/installation/#install-extensions
本文标签:
版权声明:本文标题:How can I use a local Python package during development while keeping a Git dependency in pyproject.toml? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744086075a2588543.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论