Skip to content

Commit

Permalink
Manage version strings manually (#420)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikkemperman committed Jun 7, 2019
1 parent c1edd1c commit 862f3cb
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 39 deletions.
28 changes: 0 additions & 28 deletions .bumpversion.cfg

This file was deleted.

8 changes: 4 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@

# -- Project information -----------------------------------------------------

# General project metadata is stored in .bumpversion.cfg
with open(os.path.join(root, '.bumpversion.cfg')) as project_file:
# General project metadata is stored in project.cfg
with open(os.path.join(root, 'project.cfg')) as project_file:
config = ConfigParser()
config.read_file(project_file)
project_meta = dict(config.items('bumpversion'))
project_meta = dict(config.items('project'))

project = project_meta['project']
author = project_meta['author']
Expand All @@ -38,7 +38,7 @@
title = project + ' Documentation'

# The full version, including alpha/beta/rc tags
release = project_meta['current_version']
release = project_meta['version']
# The short X.Y.Z version
version = re.sub('[^0-9.].*$', '', release)

Expand Down
12 changes: 12 additions & 0 deletions project.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[project]
name = Rx
project = RxPY
# Please make sure the version here remains the same as in rx/__init__.py
version = 3.0.0b4
description = Reactive Extensions (Rx) for Python
author = Dag Brattli
author_email = dag@brattli.net
copyright = Copyright 2013-2019, Dag Brattli, Microsoft Corp., and Contributors
license = MIT License
url = http://reactivex.io
download_url = https://github.com/ReactiveX/RxPY
4 changes: 3 additions & 1 deletion rx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
from .core import Observable, typing, pipe
from .core.typing import Mapper, Predicate

__version__ = "3.0.0-beta4"

# Please make sure the version here remains the same as in project.cfg
__version__ = '3.0.0b4'


def amb(*sources: Observable) -> Observable:
Expand Down
11 changes: 5 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
from configparser import ConfigParser


# General project metadata is stored in .bumpversion.cfg
with open('.bumpversion.cfg') as project_file:
# General project metadata is stored in project.cfg
with open('project.cfg') as project_file:
config = ConfigParser()
config.read_file(project_file)
project_meta = dict(config.items('bumpversion'))
project_meta = dict(config.items('project'))


# Populate the long_description field from README.rst
Expand All @@ -25,7 +25,7 @@
setup(
**{key: project_meta[key] for key in (
'name',
'current_version',
'version',
'description',
'long_description',
'author',
Expand All @@ -34,7 +34,6 @@
'url',
'download_url'
)},
version=project_meta.get("current_version"),
zip_safe=True,
python_requires='>=3.6.0',

Expand All @@ -57,7 +56,7 @@
package_data={'rx': ['py.typed']},
packages=['rx', 'rx.internal', 'rx.core', 'rx.core.abc',
'rx.core.operators', 'rx.core.operators.connectable',
'rx.core.observer', 'rx.core.observable',
'rx.core.observable', 'rx.core.observer',
'rx.scheduler', 'rx.scheduler.eventloop', 'rx.scheduler.mainloop',
'rx.operators', 'rx.disposable', 'rx.subject',
'rx.testing'],
Expand Down
27 changes: 27 additions & 0 deletions tests/test_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import unittest

from configparser import ConfigParser
from os.path import abspath, dirname, join
from re import match


class VersionTest(unittest.TestCase):

def test_version(self):

root = abspath(join(dirname(__file__), '..'))

with open(join(root, 'project.cfg')) as project_file:
config = ConfigParser()
config.read_file(project_file)
project_meta = dict(config.items('project'))

version = None
with open(join(root, 'rx', '__init__.py')) as init_py:
for line in init_py:
version = match('\\s*__version__\\s*=\\s*[\'"](.*)[\'"]', line)
if version is not None:
version = version.group(1)
break

assert project_meta['version'] == version

0 comments on commit 862f3cb

Please sign in to comment.