Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Python 3.6 and 3.7. #34

Merged
merged 10 commits into from
Dec 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[run]
branch = True
source = $COVERAGE_HOME/src/plone/recipe/zeoserver
parallel = true
data_file = $COVERAGE_HOME/.coverage

[report]
precision = 2
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
.installed.cfg
*.pyc
.coverage
.coverage.*
.installed.cfg
.tox/
bin/
develop-eggs/
htmlcov/
include/
lib/
parts/
Expand Down
19 changes: 12 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
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
- 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:
- coverage combine
- coveralls
cache:
pip: true
directories:
- eggs/
8 changes: 4 additions & 4 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
Changelog
=========

1.4.3 (unreleased)
------------------
2.0 (unreleased)
----------------

Breaking changes:

- *add item here*
- Drop support for ``ZODB3`` but require ``ZODB >= 5``.

New features:

- *add item here*
- Add support for Python 3.6 and 3.7.

Bug fixes:

Expand Down
9 changes: 6 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
15 changes: 11 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import sys


version = '1.4.3.dev0'
version = '2.0.dev0'

additional_install_requires = []

Expand Down Expand Up @@ -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,
Expand All @@ -46,8 +53,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={
Expand Down
22 changes: 1 addition & 21 deletions src/plone/recipe/zeoserver/recipe.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 = """
<filestorage %(storage_number)s>
path %(file_storage)s
blob-dir %(blob_storage)s
Expand All @@ -519,20 +513,6 @@ def _write_file(self, path, content):
</filestorage>
""".strip()

else:
# ZODB 3.8 needs a blob storage wrapper
blob_storage_template = """
<blobstorage %(storage_number)s>
blob-dir %(blob_storage)s
<filestorage %(storage_number)s>
path %(file_storage)s
%(pack_gc)s
%(pack_keep_old)s
</filestorage>
</blobstorage>
""".strip()


zrs_template = """
%%import zc.zrs

Expand Down
3 changes: 2 additions & 1 deletion src/plone/recipe/zeoserver/tests/test_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ def setUp(test):
install('Twisted', test)
install('hyperlink', test)
install('idna', test)
dependencies = pkg_resources.working_set.require('ZODB3')
install('PyHamcrest', test)
icemac marked this conversation as resolved.
Show resolved Hide resolved
dependencies = pkg_resources.working_set.require('ZODB')
for dep in dependencies:
try:
install(dep.project_name, test)
Expand Down
59 changes: 38 additions & 21 deletions src/plone/recipe/zeoserver/tests/zeoserver.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
icemac marked this conversation as resolved.
Show resolved Hide resolved
>>> print(conf.replace('\\', '/'))
%define INSTANCE .../sample-buildout/parts/zeo
<BLANKLINE>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ...
...
<eventlog>
Expand Down Expand Up @@ -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 ...
...
<eventlog>
Expand Down Expand Up @@ -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 ...
...
<eventlog>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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::
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Loading