Move canonical library version to __init__.py.

pull/220/head
David Wilson 6 years ago
parent 6fb3a76e68
commit 1fc7df5be5

@ -17,6 +17,7 @@ mitogen Package
.. automodule:: mitogen
.. autodata:: mitogen.__version__
.. autodata:: mitogen.is_master
.. autodata:: mitogen.context_id
.. autodata:: mitogen.parent_id

@ -1,6 +1,17 @@
import os
import sys
sys.path.append('..')
def grep_version():
path = os.path.join(os.path.dirname(__file__), '../mitogen/__init__.py')
with open(path) as fp:
for line in fp:
if line.startswith('__version__'):
_, _, s = line.partition('=')
return '.'.join(map(str, eval(s)))
author = u'David Wilson'
copyright = u'2016, David Wilson'
exclude_patterns = ['_build']
@ -20,8 +31,8 @@ language = None
master_doc = 'toc'
project = u'Mitogen'
pygments_style = 'sphinx'
release = u'master'
release = grep_version()
source_suffix = '.rst'
templates_path = ['_templates']
todo_include_todos = False
version = u'master'
version = grep_version()

@ -31,6 +31,11 @@ On the Mitogen master, this is imported from ``mitogen/__init__.py`` as would
be expected. On the slave, it is built dynamically during startup.
"""
#: Library version as a tuple.
__version__ = (0, 0, 2)
#: This is ``False`` in slave contexts. It is used in single-file Python
#: programs to avoid reexecuting the program's :py:func:`main` function in the
#: slave. For example:

@ -1586,7 +1586,8 @@ class ExternalContext(object):
sys.modules['mitogen.core'] = mitogen.core
del sys.modules['__main__']
def _setup_globals(self, context_id, parent_ids):
def _setup_globals(self, version, context_id, parent_ids):
mitogen.__version__ = version
mitogen.is_master = False
mitogen.context_id = context_id
mitogen.parent_ids = parent_ids
@ -1646,7 +1647,7 @@ class ExternalContext(object):
self.dispatch_stopped = True
def main(self, parent_ids, context_id, debug, profiling, log_level,
max_message_size, in_fd=100, out_fd=1, core_src_fd=101,
max_message_size, version, in_fd=100, out_fd=1, core_src_fd=101,
setup_stdio=True, setup_package=True, importer=None,
whitelist=(), blacklist=()):
self._setup_master(max_message_size, profiling, parent_ids[0],
@ -1657,7 +1658,7 @@ class ExternalContext(object):
self._setup_importer(importer, core_src_fd, whitelist, blacklist)
if setup_package:
self._setup_package()
self._setup_globals(context_id, parent_ids)
self._setup_globals(version, context_id, parent_ids)
if setup_stdio:
self._setup_stdio()

@ -350,6 +350,7 @@ def run(dest, router, args, deadline=None, econtext=None):
'parent_ids': parent_ids,
'profiling': getattr(router, 'profiling', False),
'setup_stdio': False,
'version': mitogen.__version__,
},))
finally:
fp.close()

@ -685,6 +685,7 @@ class Stream(mitogen.core.Stream):
'whitelist': self._router.get_module_whitelist(),
'blacklist': self._router.get_module_blacklist(),
'max_message_size': self.max_message_size,
'version': mitogen.__version__,
}
def get_preamble(self):

@ -28,9 +28,19 @@
from setuptools import find_packages, setup
def grep_version():
path = os.path.join(os.path.dirname(__file__), 'mitogen/__init__.py')
with open(path) as fp:
for line in fp:
if line.startswith('__version__'):
_, _, s = line.partition('=')
return '.'.join(map(str, eval(s)))
setup(
name = 'mitogen',
version = '0.0.2',
version = grep_version(),
description = 'Library for writing distributed self-replicating programs.',
author = 'David Wilson',
license = 'New BSD',

Loading…
Cancel
Save