Commit 279d1bc0 authored by Jason Madden's avatar Jason Madden

Merge branch 'combine-tests'

parents 61432c16 75c11563
......@@ -4,6 +4,8 @@ universal = 0
[zest.releaser]
python-file-with-version = src/gevent/__init__.py
create-wheel = no
prereleaser.middle =
gevent._util.prereleaser_middle
[metadata]
long_description_content_type = text/x-rst
......
......@@ -214,3 +214,74 @@ except ImportError:
Interface = Interface
implementer = implementer
Attribute = Attribute
def prereleaser_middle(data): # pragma: no cover
"""
zest.releaser prerelease middle hook for gevent.
The prerelease step:
asks you for a version number
updates the setup.py or version.txt and the
CHANGES/HISTORY/CHANGELOG file (with either
this new version
number and offers to commit those changes to git
The middle hook:
All data dictionary items are available and some questions
(like new version number) have been asked.
No filesystem changes have been made yet.
It is our job to finish up the filesystem changes needed, including:
- Calling towncrier to handle CHANGES.rst
- Add the version number to ``versionadded``, ``versionchanged`` and
``deprecated`` directives in Python source.
"""
if data['name'] != 'gevent':
# We are specified in ``setup.cfg``, not ``setup.py``, so we do not
# come into play for other projects, only this one. We shouldn't
# need this check, but there it is.
return
import re
import os
import subprocess
from gevent.testing import modules
new_version = data['new_version']
# Generate CHANGES.rst, remove old news entries.
subprocess.check_call([
'towncrier',
'build',
'--version', data['new_version'],
'--yes'
])
# Put the version number in source files.
regex = re.compile(b'.. (versionchanged|versionadded|deprecated):: NEXT')
replacement = r'.. \1:: %s' % (new_version,)
for path, _ in modules.walk_modules(
# Start here
basedir=os.path.join(data['reporoot'], 'src', 'gevent'),
# Include sub-dirs
recursive=True,
# Include tests
include_tests=True,
# and other things usually excluded
excluded_modules=(),
# Don't return build binaries
include_so=False,
# Don't try to import things; we want all files.
check_optional=False,
):
with open(path, 'rb') as f:
contents = f.read()
new_contents, count = regex.subn(replacement, contents)
if count:
print("Replaced version NEXT in", path)
with open(path, 'wb') as f:
f.write(new_contents)
......@@ -43,6 +43,16 @@ OPTIONAL_MODULES = frozenset({
'gevent.libuv.watcher',
})
EXCLUDED_MODULES = frozenset({
'__init__',
'core',
'ares',
'_util',
'_semaphore',
'corecffi',
'_corecffi',
'_corecffi_build',
})
def walk_modules(
basedir=None,
......@@ -50,7 +60,9 @@ def walk_modules(
include_so=False,
recursive=False,
check_optional=True,
include_tests=False,
optional_modules=OPTIONAL_MODULES,
excluded_modules=EXCLUDED_MODULES,
):
"""
Find gevent modules, yielding tuples of ``(path, importable_module_name)``.
......@@ -78,14 +90,20 @@ def walk_modules(
if os.path.isdir(path):
if not recursive:
continue
if fn in ['testing', 'tests']:
if not include_tests and fn in ['testing', 'tests']:
continue
pkg_init = os.path.join(path, '__init__.py')
if os.path.exists(pkg_init):
yield pkg_init, modpath + fn
for p, m in walk_modules(path, modpath + fn + ".",
check_optional=check_optional,
optional_modules=optional_modules):
for p, m in walk_modules(
path, modpath + fn + ".",
include_so=include_so,
recursive=recursive,
check_optional=check_optional,
include_tests=include_tests,
optional_modules=optional_modules,
excluded_modules=excluded_modules,
):
yield p, m
continue
......@@ -93,8 +111,7 @@ def walk_modules(
x = fn[:-3]
if x.endswith('_d'):
x = x[:-2]
if x in ['__init__', 'core', 'ares', '_util', '_semaphore',
'corecffi', '_corecffi', '_corecffi_build']:
if x in excluded_modules:
continue
modname = modpath + x
if check_optional and modname in optional_modules:
......
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