Commit 1685fede authored by Kirill Smelkov's avatar Kirill Smelkov

golang: Provide __version__

Move version definition from setup.py to golang module so that it is
available at runtime with plain golang.__version__ .
parent 2506fa5f
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
... ...
""" """
__version__ = "0.0.0.dev6"
__all__ = ['method', 'go', 'chan', 'select', 'default', 'defer', 'panic', 'recover', 'func', 'gimport'] __all__ = ['method', 'go', 'chan', 'select', 'default', 'defer', 'panic', 'recover', 'func', 'gimport']
from golang._gopath import gimport # make gimport available from golang from golang._gopath import gimport # make gimport available from golang
......
# pygolang | pythonic package setup # pygolang | pythonic package setup
from setuptools import setup, find_packages from setuptools import setup, find_packages
from os.path import dirname, join
import re
# read file content # read file content
def readfile(path): def readfile(path):
with open(path, 'r') as f: with open(path, 'r') as f:
return f.read() return f.read()
# grep searches text for pattern.
# return re.Match object or raises if pattern was not found.
def grep1(pattern, text):
rex = re.compile(pattern, re.MULTILINE)
m = rex.search(text)
if m is None:
raise RuntimeError('%r not found' % pattern)
return m
# find our version
_ = readfile(join(dirname(__file__), 'golang/__init__.py'))
_ = grep1('^__version__ = "(.*)"$', _)
version = _.group(1)
setup( setup(
name = 'pygolang', name = 'pygolang',
version = '0.0.0.dev6', version = version,
description = 'Go-like features for Python', description = 'Go-like features for Python',
long_description = '%s\n----\n\n%s' % ( long_description = '%s\n----\n\n%s' % (
readfile('README.rst'), readfile('CHANGELOG.rst')), readfile('README.rst'), readfile('CHANGELOG.rst')),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment