From 9c98e1e7e5608b2f6f0fcdf345d926fc306cba94 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Thu, 29 Jan 2015 01:20:45 +0100 Subject: [PATCH 1/5] have letsencrypt.VERSION, show it in letsencrypt --help, use it in setup.py note: we had some discussion about potential problems importing VERSION from main package. SO link: http://stackoverflow.com/questions/2058802/how-can-i-get-the-version-defined-in-setup-py-setuptools-in-my-package See also my comment in __init__.py - maybe we can add that "version detection from git tags" magic later. --- letsencrypt/__init__.py | 9 +++++++++ letsencrypt/scripts/main.py | 3 ++- setup.py | 3 ++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/letsencrypt/__init__.py b/letsencrypt/__init__.py index 9c0ff7662..0f56daa29 100644 --- a/letsencrypt/__init__.py +++ b/letsencrypt/__init__.py @@ -1 +1,10 @@ """Let's Encrypt.""" + +# do not import stuff here. this file is used by setup.py, thus importing +# 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""" diff --git a/letsencrypt/scripts/main.py b/letsencrypt/scripts/main.py index 4dfa70764..c30b455c3 100755 --- a/letsencrypt/scripts/main.py +++ b/letsencrypt/scripts/main.py @@ -8,6 +8,7 @@ import sys import zope.component import zope.interface +from letsencrypt import VERSION from letsencrypt.client import CONFIG from letsencrypt.client import client from letsencrypt.client import display @@ -19,7 +20,7 @@ from letsencrypt.client import log def main(): # pylint: disable=too-many-statements,too-many-branches """Command line argument parsing and main script execution.""" parser = argparse.ArgumentParser( - description="An ACME client that can update Apache configurations.") + description="letsencrypt client %s" % VERSION) parser.add_argument("-d", "--domains", dest="domains", metavar="DOMAIN", nargs="+") diff --git a/setup.py b/setup.py index 004388b5e..5737e83c3 100755 --- a/setup.py +++ b/setup.py @@ -1,6 +1,7 @@ #!/usr/bin/env python from setuptools import setup +from letsencrypt import VERSION install_requires = [ 'argparse', @@ -31,7 +32,7 @@ testing_extras = [ setup( name="letsencrypt", - version="0.1", + version=VERSION, description="Let's Encrypt", author="Let's Encrypt Project", license="", From 219b25cd9878144ca2b4a6c65d55d4bec72c822b Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Thu, 29 Jan 2015 14:58:20 +0100 Subject: [PATCH 2/5] parse version number from package init, avoid package import --- letsencrypt/__init__.py | 9 +-------- letsencrypt/scripts/main.py | 4 ++-- setup.py | 14 ++++++++++++-- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/letsencrypt/__init__.py b/letsencrypt/__init__.py index 0f56daa29..11f2f3f01 100644 --- a/letsencrypt/__init__.py +++ b/letsencrypt/__init__.py @@ -1,10 +1,3 @@ """Let's Encrypt.""" -# do not import stuff here. this file is used by setup.py, thus importing -# 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""" +__version__ = "0.1" diff --git a/letsencrypt/scripts/main.py b/letsencrypt/scripts/main.py index c30b455c3..81677058e 100755 --- a/letsencrypt/scripts/main.py +++ b/letsencrypt/scripts/main.py @@ -8,7 +8,7 @@ import sys import zope.component import zope.interface -from letsencrypt import VERSION +import letsencrypt from letsencrypt.client import CONFIG from letsencrypt.client import client from letsencrypt.client import display @@ -20,7 +20,7 @@ from letsencrypt.client import log def main(): # pylint: disable=too-many-statements,too-many-branches """Command line argument parsing and main script execution.""" parser = argparse.ArgumentParser( - description="letsencrypt client %s" % VERSION) + description="letsencrypt client %s" % letsencrypt.__version__) parser.add_argument("-d", "--domains", dest="domains", metavar="DOMAIN", nargs="+") diff --git a/setup.py b/setup.py index 5737e83c3..a6038db56 100755 --- a/setup.py +++ b/setup.py @@ -1,7 +1,17 @@ #!/usr/bin/env python +import os +import re +import codecs + 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 = [ 'argparse', @@ -32,7 +42,7 @@ testing_extras = [ setup( name="letsencrypt", - version=VERSION, + version=meta['version'], description="Let's Encrypt", author="Let's Encrypt Project", license="", From af8edbc21c0d637ab80d0b8a9b7208be585feba2 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Thu, 29 Jan 2015 15:25:28 +0100 Subject: [PATCH 3/5] put file reading into function, we'll soon need that for more stuff like e.g. reading long_description from README.rst + CHANGES.rst. --- letsencrypt/__init__.py | 1 - setup.py | 10 +++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/letsencrypt/__init__.py b/letsencrypt/__init__.py index 11f2f3f01..9fe93c4db 100644 --- a/letsencrypt/__init__.py +++ b/letsencrypt/__init__.py @@ -1,3 +1,2 @@ """Let's Encrypt.""" - __version__ = "0.1" diff --git a/setup.py b/setup.py index a6038db56..6c30593c0 100755 --- a/setup.py +++ b/setup.py @@ -5,13 +5,17 @@ import codecs from setuptools import setup + +def read_file(filename, encoding='utf8'): + """read unicode from given file""" + with codecs.open(filename, encoding=encoding) as fd: + return fd.read() + 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)) +meta = dict(re.findall(r"""__([a-z]+)__ = "([^"]+)""", read_file(init_fn))) install_requires = [ 'argparse', From 47e49215c3f896199e8e9300d6177308a1be5e3b Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Thu, 29 Jan 2015 15:38:20 +0100 Subject: [PATCH 4/5] long_description = README.rst (+ CHANGES.rst later) --- MANIFEST.in | 1 + setup.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/MANIFEST.in b/MANIFEST.in index 24da8604e..0c082ea32 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,4 @@ +include README.rst CHANGES.rst recursive-include letsencrypt *.json recursive-include letsencrypt *.sh recursive-include letsencrypt *.conf diff --git a/setup.py b/setup.py index 6c30593c0..0cdbdefe4 100755 --- a/setup.py +++ b/setup.py @@ -11,12 +11,16 @@ def read_file(filename, encoding='utf8'): with codecs.open(filename, encoding=encoding) as fd: return fd.read() + 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') meta = dict(re.findall(r"""__([a-z]+)__ = "([^"]+)""", read_file(init_fn))) +readme = read_file(os.path.join(here, 'README.rst')) +changes = read_file(os.path.join(here, 'CHANGES.rst')) + install_requires = [ 'argparse', 'jsonschema', @@ -48,6 +52,7 @@ setup( name="letsencrypt", version=meta['version'], description="Let's Encrypt", + long_description=readme, # later: + '\n\n' + changes author="Let's Encrypt Project", license="", url="https://letsencrypt.org", From 4c7b2d202c1f98a7ee43f3fc19a16e95d8f3214b Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Thu, 29 Jan 2015 23:28:22 +0100 Subject: [PATCH 5/5] cosmetic fixes --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 0cdbdefe4..a2a4fd9e9 100755 --- a/setup.py +++ b/setup.py @@ -1,13 +1,13 @@ #!/usr/bin/env python +import codecs import os import re -import codecs from setuptools import setup def read_file(filename, encoding='utf8'): - """read unicode from given file""" + """Read unicode from given file.""" with codecs.open(filename, encoding=encoding) as fd: return fd.read()