[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Simplify setup.py



commit 3b2a31bd2d005d73df3907d74a0a452ddbe11ed5
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sun May 24 13:18:15 2015 -0700

    Simplify setup.py
    
    We read rather than imported our stem/__init__.py constants because importing
    our python2 codebase could result in syntax errors for python3. Now that we
    have a unified python2/3 codebase this is no longer a concern so we can drop
    this hack! \o/
---
 setup.py |   47 +++++++++--------------------------------------
 1 file changed, 9 insertions(+), 38 deletions(-)

diff --git a/setup.py b/setup.py
index 774ee10..4d0df77 100644
--- a/setup.py
+++ b/setup.py
@@ -2,47 +2,18 @@
 # Copyright 2012-2015, Damian Johnson and The Tor Project
 # See LICENSE for licensing information
 
-# We cannot import anything from the stem module since this would risk
-# importing code that does not work under python 3 *without* being converted.
-#
-# I hate to do this, but reading our module file's information directly.
+import distutils.core
+import stem
 
-import os
-import re
-from distutils.core import setup
 
-STAT_LINE = re.compile(r"^__(.+)__ = '(.+)'$")
-
-DESCRIPTION = """\
-Stem is a Python controller library that allows applications to interact with
-Tor <https://www.torproject.org/>."""
-
-def get_module_info():
-  # reads the basic __stat__ strings from our module's init
-
-  result = {}
-  cwd = os.path.sep.join(__file__.split(os.path.sep)[:-1])
-
-  with open(os.path.join(cwd, 'stem', '__init__.py')) as init_file:
-    for line in init_file.readlines():
-      line_match = STAT_LINE.match(line)
-
-      if line_match:
-        keyword, value = line_match.groups()
-        result[keyword] = value
-
-  return result
-
-module_info = get_module_info()
-
-setup(
+distutils.core.setup(
   name = 'stem',
-  version = module_info['version'],
-  description = DESCRIPTION,
-  license = module_info['license'],
-  author = module_info['author'],
-  author_email = module_info['contact'],
-  url = module_info['url'],
+  version = stem.__version__,
+  description = "Python controller library that allows applications to interact with Tor <https://www.torproject.org/>.",
+  license = stem.__license__,
+  author = stem.__author__,
+  author_email = stem.__contact__,
+  url = stem.__url__,
   packages = ['stem', 'stem.descriptor', 'stem.interpreter', 'stem.response', 'stem.util'],
   provides = ['stem'],
   keywords = 'tor onion controller',

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits