1

In the Python package I'm putting together I'm using the following setup.cfg file:

[egg_info]
tag_build = dev
tag_date = 1
tag_svn_revision = 1

However when I run python setup.py sdist the SVN revision appears as -r0. This is likely because there is no .svn directory where I run the setup script; in fact my tree is

 main_dir/
   .svn/
   branches/
   trunk/
     setup.py
     setup.cfg

How can I tell setuptools to go find the SVN revision number in a parent directory? I still want to keep using my package version number.

lorenzog
  • 3,483
  • 4
  • 29
  • 50

2 Answers2

2

You can solve the -r0 problem in a different way if you're willing to install another package. Setuptools does not support the SVN metadata since version 10. The functionality has been moved to the setuptools_svn package.

RjOllos
  • 2,900
  • 1
  • 19
  • 29
  • Brilliant, thanks. That should be somewhere in the documentation! Cheers – lorenzog May 11 '16 at 15:09
  • 1
    There's an entry in the [10.0 changelog](https://pythonhosted.org/setuptools/history.html#id85). It's probably not obvious though what the consequences of the change are. – RjOllos May 11 '16 at 17:36
  • Thanks @RjOllos for the solution! I removed the `tag_svn_revision` from my setup.cfg file, so now the -r0 does not get appended to my version, however, now it always appends a 0 to my post release tag. My version becomes `zuko-0.1dev0-py2.7.egg`. I don't want the 0 appended after dev. Any idea why this is happening? I am using setuptools version 28.8.0. – Yahya Jan 17 '17 at 05:11
  • I don't know that it's possible to have `dev` rather than `dev0`, but the reason for appending the `0` is described in [PEP-440](https://www.python.org/dev/peps/pep-0440/#implicit-development-release-number). – RjOllos Jan 18 '17 at 01:15
1

My solution at the moment is to combine this answer and build the version manually like this (minus the shell=True option):

# Hat tip: https://stackoverflow.com/a/1501219/204634
import subprocess

def svnversion():
    p = subprocess.Popen("svnversion", stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    (stdout, stderr) = p.communicate()
    return stdout

_version = '{}-{}'.format(my_pkg_version, svnversion())

Whilst the setup.cfg file contains:

[egg_info]
tag_build = dev
tag_date = 1
Community
  • 1
  • 1
lorenzog
  • 3,483
  • 4
  • 29
  • 50