Uses pkg_resources to figure out radicale's version

This commit is contained in:
Frank Sachsenheim 2018-01-14 18:29:37 +01:00 committed by Unrud
parent 0ea72368b0
commit 062e85366d
2 changed files with 9 additions and 11 deletions

View File

@ -33,6 +33,7 @@ import io
import itertools import itertools
import logging import logging
import os import os
import pkg_resources
import posixpath import posixpath
import pprint import pprint
import random import random
@ -52,7 +53,8 @@ import vobject
from . import auth, rights, storage, web, xmlutils from . import auth, rights, storage, web, xmlutils
VERSION = "2.1.8"
VERSION = pkg_resources.get_distribution('radicale').version
NOT_ALLOWED = ( NOT_ALLOWED = (
client.FORBIDDEN, (("Content-Type", "text/plain"),), client.FORBIDDEN, (("Content-Type", "text/plain"),),

View File

@ -35,35 +35,31 @@ For further information, please visit the `Radicale Website
""" """
import re
import sys import sys
from os import path
from setuptools import setup from setuptools import setup
# When the version is updated, a new section in the NEWS.md file must be
# added too.
VERSION = "2.1.8"
WEB_FILES = ["web/css/icon.png", "web/css/main.css", "web/fn.js", WEB_FILES = ["web/css/icon.png", "web/css/main.css", "web/fn.js",
"web/index.html"] "web/index.html"]
init_path = path.join(path.dirname(__file__), "radicale", "__init__.py")
with open(init_path, "r", encoding="utf-8") as fd:
version = re.search('VERSION = "([^"]+)"', fd.read().strip()).group(1)
needs_pytest = {'pytest', 'test', 'ptr'}.intersection(sys.argv) needs_pytest = {'pytest', 'test', 'ptr'}.intersection(sys.argv)
pytest_runner = ['pytest-runner'] if needs_pytest else [] pytest_runner = ['pytest-runner'] if needs_pytest else []
# When the version is updated, ``radicale.VERSION`` must be modified.
# A new section in the ``NEWS`` file must be added too.
setup( setup(
name="Radicale", name="Radicale",
version=version, version=VERSION,
description="CalDAV and CardDAV Server", description="CalDAV and CardDAV Server",
long_description=__doc__, long_description=__doc__,
author="Guillaume Ayoub", author="Guillaume Ayoub",
author_email="guillaume.ayoub@kozea.fr", author_email="guillaume.ayoub@kozea.fr",
url="http://www.radicale.org/", url="http://www.radicale.org/",
download_url=("http://pypi.python.org/packages/source/R/Radicale/" download_url=("http://pypi.python.org/packages/source/R/Radicale/"
"Radicale-%s.tar.gz" % version), "Radicale-%s.tar.gz" % VERSION),
license="GNU GPL v3", license="GNU GPL v3",
platforms="Any", platforms="Any",
packages=["radicale"], packages=["radicale"],