parse version number from package init, avoid package import

This commit is contained in:
Thomas Waldmann
2015-01-29 14:58:20 +01:00
parent 9c98e1e7e5
commit 219b25cd98
3 changed files with 15 additions and 12 deletions
+1 -8
View File
@@ -1,10 +1,3 @@
"""Let's Encrypt.""" """Let's Encrypt."""
# do not import stuff here. this file is used by setup.py, thus importing __version__ = "0.1"
# stuff here might break setup.py as dependencies are not installed yet.
VERSION_TUPLE = 0, 1, 0, "a0"
"""version tuple: major, minor, micro, {a|b|rc}N - see PEP440"""
VERSION = "%d.%d.%d%s" % VERSION_TUPLE
"""version as str"""
+2 -2
View File
@@ -8,7 +8,7 @@ import sys
import zope.component import zope.component
import zope.interface import zope.interface
from letsencrypt import VERSION import letsencrypt
from letsencrypt.client import CONFIG from letsencrypt.client import CONFIG
from letsencrypt.client import client from letsencrypt.client import client
from letsencrypt.client import display from letsencrypt.client import display
@@ -20,7 +20,7 @@ from letsencrypt.client import log
def main(): # pylint: disable=too-many-statements,too-many-branches def main(): # pylint: disable=too-many-statements,too-many-branches
"""Command line argument parsing and main script execution.""" """Command line argument parsing and main script execution."""
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description="letsencrypt client %s" % VERSION) description="letsencrypt client %s" % letsencrypt.__version__)
parser.add_argument("-d", "--domains", dest="domains", metavar="DOMAIN", parser.add_argument("-d", "--domains", dest="domains", metavar="DOMAIN",
nargs="+") nargs="+")
+12 -2
View File
@@ -1,7 +1,17 @@
#!/usr/bin/env python #!/usr/bin/env python
import os
import re
import codecs
from setuptools import setup from setuptools import setup
from letsencrypt import VERSION here = os.path.abspath(os.path.dirname(__file__))
# read version number (and other metadata) from package init
init_fn = os.path.join(here, 'letsencrypt', '__init__.py')
with codecs.open(init_fn, encoding='utf8') as meta_file:
content = meta_file.read()
meta = dict(re.findall(r"""__([a-z]+)__ = "([^"]+)""", content))
install_requires = [ install_requires = [
'argparse', 'argparse',
@@ -32,7 +42,7 @@ testing_extras = [
setup( setup(
name="letsencrypt", name="letsencrypt",
version=VERSION, version=meta['version'],
description="Let's Encrypt", description="Let's Encrypt",
author="Let's Encrypt Project", author="Let's Encrypt Project",
license="", license="",