`setup.py install` uses get_version function from version.py, which makes use of `git describe`, to generate version string. While this works OK in development environment, this is not an option in my case, where I first fetch a certain commit, then archive it without the '.git' directory (to save space), and then use the archive to cross-compile packages for various ARCHs. If left this way, the version is always '0.0.0', since `git describe` obviously fails here. After I looked into the sourcecode, I found out that 'RELEASE-VERSION' file (if available) is supposed to be used when `git describe` fails. However, running this before packaging sourcecode doesn't work:
Code: Select all
python -c 'from version import get_version; print get_version(prefix="deluge-", suffix=".dev0")' > RELEASE-VERSION
Code: Select all
def call_git_describe(prefix="", suffix=""):
cmd = "git describe --tags --match %s[0-9]*" % prefix
try:
version = Popen(cmd.split(), stdout=PIPE).communicate()[0]
version = version.strip().replace(prefix, "")
if "-" in version:
version = ".dev".join(version.replace(suffix, "").split("-")[:2])
return version
except:
return None
Code: Select all
alex@Ubuntu:~/optware/buildroot-i686/builds/deluge-develop$ python -c 'from version import get_version; print get_version(prefix="deluge-", suffix=".dev0")'
fatal: Not a git repository (or any parent up to mount point /home/alex/optware/buildroot-i686)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
alex@Ubuntu:~/optware/buildroot-i686/builds/deluge-develop$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from version import get_version
>>> get_version(prefix="deluge-", suffix=".dev0")
fatal: Not a git repository (or any parent up to mount point /home/alex/optware/buildroot-i686)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
''
I'm not really familiar with Python, but obviously this line:
Code: Select all
version = Popen(cmd.split(), stdout=PIPE).communicate()[0]
For now I use a hack as a workaround:
Code: Select all
VERSION=`python -c 'from version import get_version; print get_version(prefix="deluge-", suffix=".dev0")'`; \
sed -i -e "/^ version=.*,$/s/=.*/=\"${VERSION}\",/" setup.py
Thanks