Skip to content

Commit c25441c

Browse files
committed
Move package info from __init__.py into the more standard __version__.py.
1 parent f353b88 commit c25441c

File tree

2 files changed

+19
-21
lines changed

2 files changed

+19
-21
lines changed

icecream/__init__.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
# License: MIT
1111
#
1212

13+
from os.path import dirname, join as pjoin
14+
1315
from .icecream import * # noqa
1416

15-
__title__ = 'icecream'
16-
__license__ = 'MIT'
17-
__version__ = '1.3.1'
18-
__author__ = 'Ansgar Grunseid'
19-
__contact__ = 'grunseid@gmail.com'
20-
__url__ = 'https://github.com/gruns/icecream'
17+
# Import all variables in __version__.py without explicit imports.
18+
meta = {}
19+
with open(pjoin(dirname(__file__), '__version__.py')) as f:
20+
exec(f.read(), meta)
21+
globals().update(dict((k, v) for k, v in meta.items() if k not in globals()))

setup.py

+12-15
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,15 @@
1212
#
1313

1414
import os
15-
import re
1615
import sys
1716
from os.path import dirname, join as pjoin
1817
from setuptools import setup, find_packages, Command
1918
from setuptools.command.test import test as TestCommand
2019

2120

22-
with open(pjoin(dirname(__file__), 'icecream', '__init__.py')) as fo:
23-
regex = r".*__version__ = '(.*?)'"
24-
VERSION = re.compile(regex, re.S).match(fo.read()).group(1)
21+
meta = {}
22+
with open(pjoin('icecream', '__version__.py')) as f:
23+
exec(f.read(), meta)
2524

2625

2726
class Publish(Command):
@@ -37,8 +36,8 @@ def finalize_options(self):
3736
def run(self):
3837
os.system('python setup.py sdist bdist_wheel')
3938

40-
sdist = 'dist/icecream-%s.tar.gz' % VERSION
41-
wheel = 'dist/icecream-%s-py2.py3-none-any.whl' % VERSION
39+
sdist = 'dist/icecream-%s.tar.gz' % meta['__version__']
40+
wheel = 'dist/icecream-%s-py2.py3-none-any.whl' % meta['__version__']
4241
rc = os.system('twine upload "%s" "%s"' % (sdist, wheel))
4342

4443
sys.exit(rc)
@@ -67,15 +66,13 @@ def run_tests(self):
6766

6867

6968
setup(
70-
name='icecream',
71-
license='MIT',
72-
version=VERSION,
73-
author='Ansgar Grunseid',
74-
author_email='grunseid@gmail.com',
75-
url='https://github.com/gruns/icecream',
76-
description=(
77-
'Inspect variables, expressions, and program execution with a '
78-
'single, simple function call.'),
69+
name=meta['__title__'],
70+
license=meta['__license__'],
71+
version=meta['__version__'],
72+
author=meta['__author__'],
73+
author_email=meta['__contact__'],
74+
url=meta['__url__'],
75+
description=meta['__description__'],
7976
long_description=(
8077
'Information and documentation can be found at '
8178
'https://github.com/gruns/icecream.'),

0 commit comments

Comments
 (0)