2

How can I specify a version for private repos in my setup.py file so that only this version is used?

from setuptools import setup, find_packages
setup(
   name="my_module"
   version="1.0.4"
   install_requires=[
    "requests==2.20.0",
    "test @ git+ssh://git@xxxx/xxxxx/test.git",
   ],
   // etc. 
)

Does my test git project have to have any properties so that I can read out the version? At the moment I only use the version field in setup.py

from setuptools import find_packages, setup
setup(
  name="test",
  version="0.5.1",
  //etc.
)
user5580578
  • 1,134
  • 1
  • 12
  • 28
  • Let it point to a specific _git tag_. – sinoroc Mar 13 '20 at 14:41
  • you mean: git tag -a v$(python setup.py --version) -m '0.5.1' ? and how can I specify the tag in the setup.py? Moreover whats the purpose of the version field in the setup.py file? – user5580578 Mar 13 '20 at 15:08
  • The `version` argument to `setuptools.setup` is used to set the _version_ metadata field in the distributions (_sdist_, _wheel_) of the project. So it's meaningful if the distributions of the project are published on an index (such as _PyPI_) and the project is installed directly from there. When the project is installed from _git_, it's different, there are no distributions in the git repository, so there is no metadata immediately available, not until **after** the repository has been cloned at least. So point at a git _tag_ instead. – sinoroc Mar 13 '20 at 15:40

1 Answers1

0

Not entirely sure, but if I am not mistaken in install_requires you could have something like the following:

MyProject @ git://git.example.com/MyProject.git@v1.0

When the project has to be installed from a git repository (or other code versioning systems) you can't really point at a version number like you can when the project is hosted on an index (such as PyPI), but the next best thing is that you can point at a specific git tag (or a branch, or any other kind of similar reference, but tag is probably the best choice for this use case).

Also, I might be wrong, but this notation might not be supported by pure setuptools. This means you most likely won't be able to use python setup.py develop or python setup.py install, but should use python -m pip install -e . or python -m pip install . instead.

References:

sinoroc
  • 18,409
  • 2
  • 39
  • 70