Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Specify dependency version >= for git repository in pyproject.toml

I have a python project with all dependencies and versions managed by pyproject.toml file.
One of these dependencies is a git reference:

[project]
name = 'my_package'
version = '1.0.0'
dependencies = [
    'my_dependency @ git+https://github.com/some_user/some_repo.git'
]

In order to improve version management after some time I started to use tags to specify exact "version". Like this:

dependencies = [
    'my_dependency @ git+https://github.com/some_user/some_repo.git@v.1.2.0'
]

But this is still not enough. Ideally I want something flexible, open for minor or patch version increase.
Like this:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

dependencies = [
    'my_dependency >= 1.2 @ git+https://github.com/some_user/some_repo.git'
]

To be clear: I want pip to look for different versions in the entire repo history and take one’s that match the condition. According to semver.

In this particular case with >= 1.2 it should take 1.2.1, 1.2.2, 1.3, 1.157.256 or any other commit with version in pyproject.toml (or at least git tag) greater or equal to 1.2.

Is this possible?
Can pip manage versions so well for git repositories?

>Solution :

Unfortunately it’s not possible. As specified here https://peps.python.org/pep-0508/ or here https://pip.pypa.io/en/stable/reference/requirement-specifiers/, you can’t use of version requirements with url based dependencies. Your second approach about using tags is the one you need.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading