From b02af7dffd4cb34f69e96ff8834c430f569e239c Mon Sep 17 00:00:00 2001 From: Michael Howitz Date: Thu, 29 Nov 2018 13:59:43 +0100 Subject: [PATCH 01/10] Fix tests for Python 2.7. --- src/plone/recipe/zeoserver/tests/test_docs.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plone/recipe/zeoserver/tests/test_docs.py b/src/plone/recipe/zeoserver/tests/test_docs.py index 998c622..c21f0ce 100644 --- a/src/plone/recipe/zeoserver/tests/test_docs.py +++ b/src/plone/recipe/zeoserver/tests/test_docs.py @@ -28,6 +28,7 @@ def setUp(test): install('Twisted', test) install('hyperlink', test) install('idna', test) + install('PyHamcrest', test) dependencies = pkg_resources.working_set.require('ZODB3') for dep in dependencies: try: From e577cb27229531abb5eb0aa5ef5c297225941acb Mon Sep 17 00:00:00 2001 From: Michael Howitz Date: Thu, 29 Nov 2018 14:02:29 +0100 Subject: [PATCH 02/10] Test on Python 3+. When using buildout for the tests they break because zc.buildout does not seem to be installed. --- .travis.yml | 17 ++++++++++------- CHANGES.rst | 2 +- tox.ini | 16 ++++++---------- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index 33c1e93..ca52d14 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,20 @@ language: python -sudo: false +dist: xenial python: - 2.7 - - 3.5 - 3.6 + - 3.7 +before_install: + - pip install -U setuptools pip + - pip install -U coverage coveralls zope.testrunner install: - - python bootstrap.py - - bin/buildout + - pip install -U -e .[zrs] script: - - bin/test -v1 + - COVERAGE_PROCESS_START=.coveragerc coverage run -m zope.testrunner --test-path=src --all -v1 notifications: email: false +after_success: + - coverage combine + - coveralls cache: pip: true - directories: - - eggs/ diff --git a/CHANGES.rst b/CHANGES.rst index e732116..f368d46 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -10,7 +10,7 @@ Breaking changes: New features: -- *add item here* +- Add support for Python 3.6 and 3.7. Bug fixes: diff --git a/tox.ini b/tox.ini index 74aa833..a59e5f5 100644 --- a/tox.ini +++ b/tox.ini @@ -2,24 +2,19 @@ envlist = flake8, py27, - py35, py36, + py37, coverage, skip_missing_interpreters = False [testenv] +usedevelop = true commands = - {envbindir}/buildout -c {toxinidir}/buildout.cfg buildout:directory={envdir} buildout:develop={toxinidir} bootstrap - {envbindir}/buildout -c {toxinidir}/buildout.cfg buildout:directory={envdir} buildout:develop={toxinidir} -n install test - coverage run {envbindir}/test --all {posargs:-vc} -skip_install = true + zope-testrunner --test-path=src --all {posargs:-vc} +extras = zrs deps = - setuptools==33.1.1 - zc.buildout - coverage -setenv = - COVERAGE_FILE=.coverage.{envname} + zope.testrunner [testenv:coverage] basepython = python2.7 @@ -35,5 +30,6 @@ commands = [testenv:flake8] basepython = python2.7 +skip_install = true deps = flake8 commands = flake8 --doctests src setup.py From 20e38b0941ac53c8db68409ec5b38e8610f363d8 Mon Sep 17 00:00:00 2001 From: Michael Howitz Date: Thu, 29 Nov 2018 14:03:05 +0100 Subject: [PATCH 03/10] Fix coverage testing + test coverage in subprocesses. --- .coveragerc | 8 ++++++++ .gitignore | 6 +++++- tox.ini | 14 ++++++++------ 3 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..417be10 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,8 @@ +[run] +branch = True +source = $COVERAGE_HOME/src/plone/recipe/zeoserver +parallel = true +data_file = $COVERAGE_HOME/.coverage + +[report] +precision = 2 diff --git a/.gitignore b/.gitignore index de13ba3..66ec592 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,11 @@ -.installed.cfg *.pyc +.coverage +.coverage.* +.installed.cfg +.tox/ bin/ develop-eggs/ +htmlcov/ include/ lib/ parts/ diff --git a/tox.ini b/tox.ini index a59e5f5..e5adbdb 100644 --- a/tox.ini +++ b/tox.ini @@ -17,16 +17,18 @@ deps = zope.testrunner [testenv:coverage] -basepython = python2.7 -deps = coverage +basepython = python3.6 +deps = + zope.testrunner + coverage setenv = - COVERAGE_FILE=.coverage + COVERAGE_HOME={toxinidir} + COVERAGE_PROCESS_START={toxinidir}/.coveragerc commands = - coverage erase + coverage run -m zope.testrunner --test-path=src {posargs:-vc} coverage combine coverage html - coverage xml - coverage report + coverage report --fail-under=63 [testenv:flake8] basepython = python2.7 From 8f133d80b6a6836ac29cd4e0be2ec98215fbe26c Mon Sep 17 00:00:00 2001 From: Michael Howitz Date: Thu, 29 Nov 2018 14:04:37 +0100 Subject: [PATCH 04/10] Fix Manifest. --- MANIFEST.in | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index fc44ccb..869f7ea 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,8 @@ -include * + include *.rst -recursive-include src * + include tox.ini + exclude tox.ini -global-exclude *pyc + recursive-include src *.bat + recursive-include src *.in + recursive-include src *.txt From 67d466333e1cfa927b1dd03a16c35649380602b4 Mon Sep 17 00:00:00 2001 From: Michael Howitz Date: Thu, 29 Nov 2018 14:04:48 +0100 Subject: [PATCH 05/10] Fix classifiers. --- setup.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index fa7d427..6acf264 100644 --- a/setup.py +++ b/setup.py @@ -34,9 +34,16 @@ 'Framework :: Plone', 'Framework :: Plone :: 5.1', 'Framework :: Plone :: 5.2', - 'Framework :: Zope2', + 'Framework :: Zope', + 'Framework :: Zope :: 4', 'Programming Language :: Python', + 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: Implementation', + 'Programming Language :: Python :: Implementation :: CPython', ], packages=find_packages('src'), include_package_data=True, From f181664a9c68b4f8d119fc025042e2d6fa5af7fc Mon Sep 17 00:00:00 2001 From: Michael Howitz Date: Thu, 29 Nov 2018 15:08:00 +0100 Subject: [PATCH 06/10] Fix coverage path. --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ca52d14..8f3e11a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,9 @@ before_install: install: - pip install -U -e .[zrs] script: - - COVERAGE_PROCESS_START=.coveragerc coverage run -m zope.testrunner --test-path=src --all -v1 + - export COVERAGE_HOME=$(pwd) + - export COVERAGE_PROCESS_START=$COVERAGE_HOME/.coveragerc + - coverage run -m zope.testrunner --test-path=src --all -v1 notifications: email: false after_success: From 6e0124b0616d8b4294482019bc2ae37d61e3e7e0 Mon Sep 17 00:00:00 2001 From: Michael Howitz Date: Thu, 29 Nov 2018 15:33:23 +0100 Subject: [PATCH 07/10] Drop support for ``ZODB3`` but require ``ZODB >= 5``. --- CHANGES.rst | 6 ++--- README.rst | 4 ++-- setup.py | 7 +++--- src/plone/recipe/zeoserver/recipe.py | 22 +------------------ src/plone/recipe/zeoserver/tests/test_docs.py | 2 +- 5 files changed, 10 insertions(+), 31 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index f368d46..b6091e8 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,12 +1,12 @@ Changelog ========= -1.4.3 (unreleased) ------------------- +2.0 (unreleased) +---------------- Breaking changes: -- *add item here* +- Drop support for ``ZODB3`` but require ``ZODB >= 5``. New features: diff --git a/README.rst b/README.rst index 9b57c57..32847ec 100644 --- a/README.rst +++ b/README.rst @@ -196,7 +196,7 @@ zeo-conf repozo The path to the repozo.py backup script. A wrapper for this will be generated in bin/repozo, which sets up the appropriate environment for - running this. Defaults to using the repozo script from the ZODB3 egg. + running this. Defaults to using the repozo script from the ZODB egg. Set this to an empty value if you do not want this script to be generated. repozo-script-name @@ -209,7 +209,7 @@ zeopack The path to the zeopack.py backup script. A wrapper for this will be generated in bin/zeopack (unless you change `zeopack-script-name`), which sets up the appropriate environment to run this. Defaults to using the zeopack - script from the ZODB3 egg. Set this option to an empty value if you do not + script from the ZODB egg. Set this option to an empty value if you do not want this script to be generated. zeopack-script-name diff --git a/setup.py b/setup.py index 6acf264..6c9ff1b 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ import sys -version = '1.4.3.dev0' +version = '2.0.dev0' additional_install_requires = [] @@ -32,7 +32,6 @@ 'License :: OSI Approved :: Zope Public License', 'Framework :: Buildout', 'Framework :: Plone', - 'Framework :: Plone :: 5.1', 'Framework :: Plone :: 5.2', 'Framework :: Zope', 'Framework :: Zope :: 4', @@ -53,8 +52,8 @@ 'setuptools', 'zc.buildout', 'zc.recipe.egg', - 'ZODB3 >= 3.8', - 'zope.mkzeoinstance >=4', + 'ZODB >= 5', + 'zope.mkzeoinstance >=4.1', 'ZopeUndo', ] + additional_install_requires, extras_require={ diff --git a/src/plone/recipe/zeoserver/recipe.py b/src/plone/recipe/zeoserver/recipe.py index f8e4481..0a24b2e 100644 --- a/src/plone/recipe/zeoserver/recipe.py +++ b/src/plone/recipe/zeoserver/recipe.py @@ -1,7 +1,4 @@ # -*- coding: utf-8 -*- -from pkg_resources import get_distribution -from pkg_resources import parse_version - import logging import os import shutil @@ -506,11 +503,8 @@ def _write_file(self, path, content): # the template used to build a blob storage -zodb_version = get_distribution('ZODB3').version -if parse_version(zodb_version) >= parse_version('3.9'): - # ZODB 3.9+ supports blobs natively - blob_storage_template = """ +blob_storage_template = """ path %(file_storage)s blob-dir %(blob_storage)s @@ -519,20 +513,6 @@ def _write_file(self, path, content): """.strip() -else: - # ZODB 3.8 needs a blob storage wrapper - blob_storage_template = """ - - blob-dir %(blob_storage)s - - path %(file_storage)s - %(pack_gc)s - %(pack_keep_old)s - - -""".strip() - - zrs_template = """ %%import zc.zrs diff --git a/src/plone/recipe/zeoserver/tests/test_docs.py b/src/plone/recipe/zeoserver/tests/test_docs.py index c21f0ce..84dba40 100644 --- a/src/plone/recipe/zeoserver/tests/test_docs.py +++ b/src/plone/recipe/zeoserver/tests/test_docs.py @@ -29,7 +29,7 @@ def setUp(test): install('hyperlink', test) install('idna', test) install('PyHamcrest', test) - dependencies = pkg_resources.working_set.require('ZODB3') + dependencies = pkg_resources.working_set.require('ZODB') for dep in dependencies: try: install(dep.project_name, test) From 191e0c4842aef61fc1491a35f9caca9f980cd5ac Mon Sep 17 00:00:00 2001 From: Michael Howitz Date: Thu, 29 Nov 2018 15:34:51 +0100 Subject: [PATCH 08/10] Fix min coverage. --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index e5adbdb..e316814 100644 --- a/tox.ini +++ b/tox.ini @@ -28,7 +28,7 @@ commands = coverage run -m zope.testrunner --test-path=src {posargs:-vc} coverage combine coverage html - coverage report --fail-under=63 + coverage report --fail-under=62 [testenv:flake8] basepython = python2.7 From 7760e2f95d169cd715cdf52894740190af75360d Mon Sep 17 00:00:00 2001 From: Michael Howitz Date: Thu, 29 Nov 2018 15:47:13 +0100 Subject: [PATCH 09/10] Fix Python 3 resource warnings. --- .../recipe/zeoserver/tests/zeoserver.txt | 59 ++++++++++++------- 1 file changed, 38 insertions(+), 21 deletions(-) diff --git a/src/plone/recipe/zeoserver/tests/zeoserver.txt b/src/plone/recipe/zeoserver/tests/zeoserver.txt index d53dc00..080a4a8 100644 --- a/src/plone/recipe/zeoserver/tests/zeoserver.txt +++ b/src/plone/recipe/zeoserver/tests/zeoserver.txt @@ -37,7 +37,8 @@ Let's run it:: We should have a basic zeo.conf:: >>> zeo = os.path.join(sample_buildout, 'parts', 'zeo') - >>> conf = open(os.path.join(zeo, 'etc', 'zeo.conf')).read() + >>> with open(os.path.join(zeo, 'etc', 'zeo.conf')) as f: + ... conf = f.read() >>> print(conf.replace('\\', '/')) %define INSTANCE .../sample-buildout/parts/zeo @@ -105,7 +106,8 @@ Now, let's create a simple buildout to create a primary replication:: We should have primary zrs config in zeo.conf:: >>> zeo = os.path.join(sample_buildout, 'parts', 'zeo') - >>> print(open(os.path.join(zeo, 'etc', 'zeo.conf')).read()) + >>> with open(os.path.join(zeo, 'etc', 'zeo.conf')) as f: + ... print(f.read()) %define INSTANCE ... ... %import zc.zrs @@ -138,7 +140,8 @@ And for a secondary:: We should have primary zrs config in zeo.conf:: >>> zeo = os.path.join(sample_buildout, 'parts', 'zeo') - >>> print(open(os.path.join(zeo, 'etc', 'zeo.conf')).read()) + >>> with open(os.path.join(zeo, 'etc', 'zeo.conf')) as f: + ... print(f.read()) %define INSTANCE ... ... %import zc.zrs @@ -186,7 +189,8 @@ Let's run it:: We should have a zeo.conf with a rotatezlog:: >>> zeo = os.path.join(sample_buildout, 'parts', 'zeo') - >>> print(open(os.path.join(zeo, 'etc', 'zeo.conf')).read()) + >>> with open(os.path.join(zeo, 'etc', 'zeo.conf')) as f: + ... print(f.read()) %define INSTANCE ... ... @@ -230,7 +234,8 @@ Let's run it:: We should have a zeo.conf with a log level set to `error`:: >>> zeo = os.path.join(sample_buildout, 'parts', 'zeo') - >>> print(open(os.path.join(zeo, 'etc', 'zeo.conf')).read()) + >>> with open(os.path.join(zeo, 'etc', 'zeo.conf')) as f: + ... print(f.read()) %define INSTANCE ... ... @@ -266,7 +271,8 @@ Let's run it:: We should have a zeo.conf with log file rotation enabled:: >>> zeo = os.path.join(sample_buildout, 'parts', 'zeo') - >>> print(open(os.path.join(zeo, 'etc', 'zeo.conf')).read()) + >>> with open(os.path.join(zeo, 'etc', 'zeo.conf')) as f: + ... print(f.read()) %define INSTANCE ... ... @@ -313,7 +319,8 @@ Now check the values for `host`, `port` and `unix`:: >>> zeopack_path = os.path.join(sample_buildout, 'bin', 'zeopack') >>> if WINDOWS: ... zeopack_path += '-script.py' - >>> zeopack = open(zeopack_path, 'r').read() + >>> with open(zeopack_path, 'r') as f: + ... zeopack = f.read() >>> 'host = "127.0.0.1"' in zeopack True >>> 'port = "8001"' in zeopack @@ -344,7 +351,8 @@ Now check the values for `host`, `port` and `unix`:: >>> zeopack_path = os.path.join(sample_buildout, 'bin', 'zeopack') >>> if WINDOWS: ... zeopack_path += '-script.py' - >>> zeopack = open(zeopack_path, 'r').read() + >>> with open(zeopack_path, 'r') as f: + ... zeopack = f.read() >>> 'host = "192.168.0.11"' in zeopack True >>> 'port = "8001"' in zeopack @@ -375,7 +383,8 @@ Now check the values for `storage`:: >>> zeopack_path = os.path.join(sample_buildout, 'bin', 'zeopack') >>> if WINDOWS: ... zeopack_path += '-script.py' - >>> zeopack = open(zeopack_path, 'r').read() + >>> with open(zeopack_path, 'r') as f: + ... zeopack = f.read() >>> 'storage = "9"' in zeopack True @@ -403,7 +412,8 @@ Now check the values for `host`, `port` and `unix`:: >>> zeopack_path = os.path.join(sample_buildout, 'bin', 'zeopack') >>> if WINDOWS: ... zeopack_path += '-script.py' - >>> zeopack = open(zeopack_path, 'r').read() + >>> with open(zeopack_path, 'r') as f: + ... zeopack = f.read() >>> 'host = None' in zeopack True >>> 'port = None' in zeopack @@ -465,15 +475,17 @@ be different and correspond as the buildout specified:: >>> zeopack_paths = [os.path.join(sample_buildout, 'bin', script) for script in zeopack_scripts] >>> if WINDOWS: ... zeopack_paths = [zeopack + '-script.py' for zeopack in zeopacks] - >>> zeopacks = [open(zeopack_path, 'r').read() for zeopack_path in zeopack_paths] - - >>> 'username = "firstuser"' in zeopacks[0] + >>> with open(zeopack_paths[0], 'r') as f: + ... first_zeopack = f.read() + >>> with open(zeopack_paths[1], 'r') as f: + ... second_zeopack = f.read() + >>> 'username = "firstuser"' in first_zeopack True - >>> 'username = "seconduser"' in zeopacks[0] + >>> 'username = "seconduser"' in first_zeopack False - >>> 'username = "firstuser"' in zeopacks[1] + >>> 'username = "firstuser"' in second_zeopack False - >>> 'username = "seconduser"' in zeopacks[1] + >>> 'username = "seconduser"' in second_zeopack True Restore the original simple configuration:: @@ -532,7 +544,8 @@ Our generated script now has a reference to the relative path. >>> zeo_path = join('bin', 'zeo') >>> if WINDOWS: ... zeo_path += '-script.py' - >>> open(zeo_path).read() + >>> with open(zeo_path) as f: + ... f.read() '...base = os.path.dirname(os.path.abspath(os.path.realpath(__file__)))...' Extra paths in scripts @@ -569,17 +582,20 @@ The generated scripts should have the extra path. >>> parts_bin = join('parts', 'zeo', 'bin') - >>> extra in open(join('bin', 'zeo' + suffix)).read() + >>> with open(join('bin', 'zeo' + suffix)) as f: + ... extra in f.read() True >>> if not WINDOWS: - ... extra in open(join(parts_bin, 'runzeo' + suffix)).read() + ... with open(join(parts_bin, 'runzeo' + suffix)) as f: + ... extra in f.read() ... else: ... print(True) True >>> if not WINDOWS: - ... extra in open(join(parts_bin, 'zeoctl' + suffix)).read() + ... with open(join(parts_bin, 'zeoctl' + suffix)) as f: + ... extra in f.read() ... else: ... print(True) True @@ -613,5 +629,6 @@ The main script should have the initialization. ... else: ... suffix = '' - >>> 'foo = 1' in open(join('bin', 'zeo' + suffix)).read() + >>> with open(join('bin', 'zeo' + suffix)) as f: + ... 'foo = 1' in f.read() True From 7de5449fa70bbfccf51dae380f90cbe60f197138 Mon Sep 17 00:00:00 2001 From: Michael Howitz Date: Fri, 30 Nov 2018 10:48:39 +0100 Subject: [PATCH 10/10] Implement suggestions of @sallner. --- setup.py | 1 + tox.ini | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 6c9ff1b..aa662c9 100644 --- a/setup.py +++ b/setup.py @@ -32,6 +32,7 @@ 'License :: OSI Approved :: Zope Public License', 'Framework :: Buildout', 'Framework :: Plone', + 'Framework :: Plone :: 5.1', 'Framework :: Plone :: 5.2', 'Framework :: Zope', 'Framework :: Zope :: 4', diff --git a/tox.ini b/tox.ini index e316814..ecdf9bd 100644 --- a/tox.ini +++ b/tox.ini @@ -31,7 +31,7 @@ commands = coverage report --fail-under=62 [testenv:flake8] -basepython = python2.7 +basepython = python3.6 skip_install = true deps = flake8 commands = flake8 --doctests src setup.py