Skip to content

Commit

Permalink
Resurrection sprint: python3 support (#4)
Browse files Browse the repository at this point in the history
* Ignore dev dir, sort imports

* Test on py3.5

* Work on python3 in dependencies

* Disable this part while working on python3.

* Python3 support

* Reach 'webtest' dependency through zope.app.wsgi[test]

* No longer use ZODB3.

* more deps

* Use print function

* Work on grokcore.security

* autocheckout grokcore.catalog

* Fix spurious print close paren

* Add zope.testbrowser.

* work on grokcore.catalog too

* Add ignore

* More deps auto-checkouts.

* look at the groktoolkit branch's idea of the version list

* PY2 vs PY3 normalizer for doctests

* Renormalize python2/python3 import paths

* Python2 and Python3 compatible print function

* Update to Browser moving to zope.testbrowser.wsgi

* Use the testbrowser wsgi Browser

* This is not a printable object

* Rewrite http() from zope.testbrowser

* Those version deps are in groktoolkit now.

* Zope.testbrowser merged to master.

* Merged zope.configuration.

* Use zope.testbrowser gocept fork for wsgi testbrowser.

* Flip the order of renormalizing

Full import paths for python3 will be renormalized to python2 instead
of the more error-prone other direction.

* python2/3 compatible print for doctests

* Python2/3 compatible error handling

* Add python3.5 specification.

* Moved to groktoolkit

* Fix rename of testlayer in zope.testbrowser.

* Python2/python3 compatible output.

* Don't override print, make more developer-friendly 'bprint'.

* Use zope.testing "renormalizing.IGNORE_EXCEPTION_MODULE_IN_PYTHON2"

Tracebacks need to be on one line.

* Rewrite tests to use full python paths

* Move bprint to `grok.testing`.

It is now used in different places, at least in `grokcore.view`.

* More generic normalizer for ConfigurationExecutionError.

* We do not use simplejson.

* get tests to work with tox. Hopefully with travis too. z3c.recipe.template is gone. Seems to be replaceable with collective.recipe.template.

* update changelog

* cleanups
  • Loading branch information
janjaapdriessen authored and janwijbrand committed Jan 16, 2018
1 parent 7094779 commit 4d1a2fd
Show file tree
Hide file tree
Showing 82 changed files with 412 additions and 318 deletions.
14 changes: 9 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
syntax:glob

.coverage.*
.installed.cfg
.mr.developer.cfg
.tox
*.bak
*.pyc
*.pyo
*.swo
*.swp
bin
coverage
develop/*
dev
develop-eggs
develop/*
dist
docs/_build
docs/doctrees
docs/html
docs/latex
docs/make.bat
docs/Makefile
dist
grokwiki/src/grokwiki.egg-info/
eggs
.installed.cfg
.mr.developer.cfg
grokwiki/src/grokwiki.egg-info/
parts
src/*.egg-info
var/
16 changes: 12 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
language: python
python:
- 2.7
- 3.4
- 3.5
- 3.6
- pypy
- pypy3
install:
- virtualenv .
- bin/pip install -UIr requirements.txt
- bin/buildout
- pip install -U pip setuptools
- pip install -U zope.testrunner coverage coveralls
- pip install -U -e .[test]
script:
- bin/test -v1
- coverage run -m zope.testrunner --test-path=src
after_success:
- coveralls
notifications:
email: false
cache: pip
7 changes: 1 addition & 6 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ Grok changes
1.16 (unreleased)
=================

- Nothing changed yet.

- Python 3 compatibility.

1.15 (2017-05-30)
=================
Expand All @@ -17,7 +16,6 @@ Grok changes

- Update tests.


1.14 (2015-06-11)
=================

Expand All @@ -37,20 +35,17 @@ with older versions.
- Replace ``grok.util.create_application`` with the one from
grokcore.site.util. It is now importable directly from grok.


1.13 (2015-06-04)
=================

- Advertise the ``ObjectEditedEvent`` from grokcore.content.


1.12 (2014-10-20)
=================

- Add ``grok.queryAnnotation()`` and ``grok.deleteAnnotation()`` from
``grokcore.annotation``.


1.11.3 (2013-04-03)
===================

Expand Down
74 changes: 53 additions & 21 deletions bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@

from optparse import OptionParser

tmpeggs = tempfile.mkdtemp()
__version__ = '2015-07-01'
# See zc.buildout's changelog if this version is up to date.

tmpeggs = tempfile.mkdtemp(prefix='bootstrap-')

usage = '''\
[DESIRED PYTHON FOR BUILDOUT] bootstrap.py [options]
Expand All @@ -35,13 +38,14 @@
Simply run this script in a directory containing a buildout.cfg, using the
Python that you want bin/buildout to use.
Note that by using --find-links to point to local resources, you can keep
Note that by using --find-links to point to local resources, you can keep
this script from going over the network.
'''

parser = OptionParser(usage=usage)
parser.add_option("-v", "--version", help="use a specific zc.buildout version")

parser.add_option("--version",
action="store_true", default=False,
help=("Return bootstrap.py version."))
parser.add_option("-t", "--accept-buildout-test-releases",
dest='accept_buildout_test_releases',
action="store_true", default=False,
Expand All @@ -59,36 +63,57 @@
parser.add_option("--allow-site-packages",
action="store_true", default=False,
help=("Let bootstrap.py use existing site packages"))

parser.add_option("--buildout-version",
help="Use a specific zc.buildout version")
parser.add_option("--setuptools-version",
help="Use a specific setuptools version")
parser.add_option("--setuptools-to-dir",
help=("Allow for re-use of existing directory of "
"setuptools versions"))

options, args = parser.parse_args()
if options.version:
print("bootstrap.py version %s" % __version__)
sys.exit(0)


######################################################################
# load/install setuptools

try:
if options.allow_site_packages:
import setuptools
import pkg_resources
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen

ez = {}
exec(urlopen('https://bootstrap.pypa.io/ez_setup.py').read(), ez)
if os.path.exists('ez_setup.py'):
exec(open('ez_setup.py').read(), ez)
else:
exec(urlopen('https://bootstrap.pypa.io/ez_setup.py').read(), ez)

if not options.allow_site_packages:
# ez_setup imports site, which adds site packages
# this will remove them from the path to ensure that incompatible versions
# this will remove them from the path to ensure that incompatible versions
# of setuptools are not in the path
import site
# inside a virtualenv, there is no 'getsitepackages'.
# inside a virtualenv, there is no 'getsitepackages'.
# We can't remove these reliably
if hasattr(site, 'getsitepackages'):
for sitepackage_path in site.getsitepackages():
sys.path[:] = [x for x in sys.path if sitepackage_path not in x]
# Strip all site-packages directories from sys.path that
# are not sys.prefix; this is because on Windows
# sys.prefix is a site-package directory.
if sitepackage_path != sys.prefix:
sys.path[:] = [x for x in sys.path
if sitepackage_path not in x]

setup_args = dict(to_dir=tmpeggs, download_delay=0)

if options.setuptools_version is not None:
setup_args['version'] = options.setuptools_version
if options.setuptools_to_dir is not None:
setup_args['to_dir'] = options.setuptools_to_dir

ez['use_setuptools'](**setup_args)
import setuptools
import pkg_resources
Expand All @@ -104,7 +129,12 @@

ws = pkg_resources.working_set

setuptools_path = ws.find(
pkg_resources.Requirement.parse('setuptools')).location

# Fix sys.path here as easy_install.pth added before PYTHONPATH
cmd = [sys.executable, '-c',
'import sys; sys.path[0:0] = [%r]; ' % setuptools_path +
'from setuptools.command.easy_install import main; main()',
'-mZqNxd', tmpeggs]

Expand All @@ -117,21 +147,23 @@
if find_links:
cmd.extend(['-f', find_links])

setuptools_path = ws.find(
pkg_resources.Requirement.parse('setuptools')).location

requirement = 'zc.buildout'
version = options.version
version = options.buildout_version
if version is None and not options.accept_buildout_test_releases:
# Figure out the most recent final version of zc.buildout.
import setuptools.package_index
_final_parts = '*final-', '*final'

def _final_version(parsed_version):
for part in parsed_version:
if (part[:1] == '*') and (part not in _final_parts):
return False
return True
try:
return not parsed_version.is_prerelease
except AttributeError:
# Older setuptools
for part in parsed_version:
if (part[:1] == '*') and (part not in _final_parts):
return False
return True

index = setuptools.package_index.PackageIndex(
search_path=[setuptools_path])
if find_links:
Expand All @@ -156,7 +188,7 @@ def _final_version(parsed_version):
cmd.append(requirement)

import subprocess
if subprocess.call(cmd, env=dict(os.environ, PYTHONPATH=setuptools_path)) != 0:
if subprocess.call(cmd) != 0:
raise Exception(
"Failed to execute command:\n%s" % repr(cmd)[1:-1])

Expand Down
23 changes: 11 additions & 12 deletions buildout.cfg
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
[buildout]
extends =
https://raw.github.com/zopefoundation/groktoolkit/master/grok.cfg
https://raw.githubusercontent.com/zopefoundation/groktoolkit/resurrection-python3/grok.cfg
index = https://pypi.python.org/simple/
parts =
interpreter
mkdirs
test
zope_conf site_zcml deploy_ini debug_ini
zpasswd
zope_conf
site_zcml
deploy_ini
debug_ini
develop =
.
grokwiki
versions = versions
extensions =
mr.developer
auto-checkout =

[sources]

[versions]
grok =

# needs to be same version as requirements.txt
grokcore.annotation = 1.6
setuptools = 33.1.1
zc.buildout = 2.9.3

Expand All @@ -46,27 +44,28 @@ eggs =
defaults = ['--tests-pattern', '^f?tests$', '-v', '--auto-color']

[zope_conf]
recipe = z3c.recipe.template
recipe = collective.recipe.template
input = etc/zope.conf.in
output = ${buildout:parts-directory}/etc/zope.conf
filestorage = ${buildout:directory}/var/filestorage
logfiles = ${buildout:directory}/var/log

[site_zcml]
recipe = z3c.recipe.template
recipe = collective.recipe.template
input = etc/site.zcml.in
output = ${buildout:parts-directory}/etc/site.zcml

[deploy_ini]
recipe = z3c.recipe.template
recipe = collective.recipe.template
input = etc/deploy.ini.in
output = ${buildout:parts-directory}/etc/deploy.ini

[debug_ini]
recipe = z3c.recipe.template
recipe = collective.recipe.template
input = etc/debug.ini.in
output = ${buildout:parts-directory}/etc/debug.ini

# python3 port: disabled.
# This section is named so that the zpasswd utility is
# called `zpasswd`
[zpasswd]
Expand Down
23 changes: 17 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ def read(*rnames):
)

tests_require = [
'zope.app.wsgi',
'zope.app.wsgi[test]',
'zope.configuration',
'zope.testbrowser',
'zope.testing',
]

Expand All @@ -31,12 +32,23 @@ def read(*rnames):
long_description=long_description,
license='ZPL',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Intended Audience :: Developers',
'License :: OSI Approved :: Zope Public License',
'Programming Language :: Python',
'Natural Language :: English',
'Operating System :: OS Independent',
'Topic :: Internet :: WWW/HTTP',
'Framework :: Zope3',
],
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: Implementation :: PyPy',
],
packages=find_packages('src'),
package_dir={'': 'src'},
include_package_data=True,
Expand All @@ -55,17 +67,16 @@ def read(*rnames):
'grokcore.security[role] >= 1.6',
'grokcore.site >= 1.7',
'grokcore.traverser >= 1.1',
'grokcore.view [security_publication]',
'grokcore.view >= 2.8',
'grokcore.viewlet >= 1.10',
'grokcore.view [security_publication]',
'grokcore.xmlrpc >= 1.2',
'martian >= 0.14',
'pytz',
'setuptools',
'simplejson',
'z3c.autoinclude',
'zc.catalog',
'ZODB3',
'ZODB',
'zope.annotation',
'zope.app.appsetup',
'zope.app.publication',
Expand All @@ -75,10 +86,10 @@ def read(*rnames):
'zope.component',
'zope.container',
'zope.contentprovider',
'zope.generations',
'zope.errorview [browser]',
'zope.event',
'zope.exceptions',
'zope.generations',
'zope.i18n',
'zope.i18nmessageid',
'zope.interface',
Expand Down
2 changes: 1 addition & 1 deletion src/grok/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
##############################################################################
"""Grok
"""
from zope.interface import implements
from zope.component import adapts

from martian import ClassGrokker, InstanceGrokker, GlobalGrokker
Expand All @@ -29,6 +28,7 @@
from grokcore.component import queryOrderedMultiSubscriptions

from grokcore.component.decorators import subscribe, adapter, implementer
from grokcore.component import implements

from grokcore.component.directive import context, name, title, description
from grokcore.component.directive import provides, direct
Expand Down
Loading

0 comments on commit 4d1a2fd

Please sign in to comment.