[tor-commits] [stem/master] Remove need to import stem in setup.py
atagar at torproject.org
atagar at torproject.org
Fri Apr 3 01:42:42 UTC 2020
commit ec26b63537ac32e5e3c03eea72c2bbb0b07d37f5
Author: msramalho <up201403027 at fe.up.pt>
Date: Thu Apr 2 13:34:59 2020 +0100
Remove need to import stem in setup.py
Code based on https://gitweb.torproject.org/stem.git/commit/?id=3b2a31b
---
setup.py | 32 ++++++++++++++++++++++++++------
1 file changed, 26 insertions(+), 6 deletions(-)
diff --git a/setup.py b/setup.py
index eccd29eb..dfe855da 100644
--- a/setup.py
+++ b/setup.py
@@ -68,8 +68,8 @@
import setuptools
import os
+import re
import sys
-import stem
if '--dryrun' in sys.argv:
DRY_RUN = True
@@ -127,16 +127,36 @@ with open('MANIFEST.in', 'w') as manifest_file:
manifest_file.write(MANIFEST)
+def get_module_info():
+ # reads the basic __stat__ strings from our module's init
+
+ STAT_REGEX = re.compile(r"^__(.+)__ = '(.+)'$")
+ 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_REGEX.match(line)
+
+ if line_match:
+ keyword, value = line_match.groups()
+ result[keyword] = value
+
+ return result
+
+
+module_info = get_module_info()
+
try:
setuptools.setup(
name = 'stem-dry-run' if DRY_RUN else 'stem',
- version = stem.__version__,
+ version = module_info['version'],
description = DRY_RUN_SUMMARY if DRY_RUN else SUMMARY,
long_description = DESCRIPTION,
- license = stem.__license__,
- author = stem.__author__,
- author_email = stem.__contact__,
- url = stem.__url__,
+ license = module_info['license'],
+ author = module_info['author'],
+ author_email = module_info['contact'],
+ url = module_info['url'],
packages = setuptools.find_packages(exclude=['test*']),
keywords = 'tor onion controller',
scripts = ['tor-prompt'],
More information about the tor-commits
mailing list