Python 3 Porting
Clone this wiki locally
The Pyramid master branch runs on Python 3.2 (as of September 25, 2011). It does not require a "translation" (via 2to3 or 3to2) but instead uses a single codebase that run under 2 and 3.
Currently neither scaffolding ("paster create") or paster commands like "paster pshell" or "paster pview" work. Also, some scaffolding dependencies such as zope.sqlalchemy and the transaction package are not yet ported, or, if they are, haven't had a general release yet. So it's not really ready for general public usage yet. However, it can be used by the curious hacker under Python 3.2, like so:
from pyramid.view import view_config from pyramid.config import Configurator from pyramid.response import Response from wsgiref.simple_server import make_server @view_config(route_name='test_page') def test_page(request): return Response('Hello World') if __name__ == '__main__': config = Configurator() config.add_route('test_page', '/test') config.scan('__main__') httpd = make_server('', 8000, config.make_wsgi_app()) httpd.serve_forever()
Below are more details.
Dependencies that still need replacing
PasteScript has not been ported, nor have its dependencies. We likely will need to replace PasteScript rather than port it, unless someone is brave enough to do it in the meantime. Here's a list of the resulting packages that don't work that we will need to replace.
- Paste (won't port, will remove dependency; see Glue and Pyramid 2 Brainstorm)
- PasteScript (won't port, will replace; see also Glue and Pyramid 2 Brainstorm).
The fact that these dependencies are missing makes it necessary to create a Pyramid app "by hand" (ala https://docs.pylonsproject.org/docs/pyramid_quick_tutorial.html) instead of using "paster create" to create a new project.
Scaffolding dependencies that won't be ported
- ZODB (http://svn.zope.org/ZODB/trunk/; likely won't be ported by us, too large, just maybe keep an eye on other efforts; for example https://mail.zope.org/pipermail/zodb-dev/2011-September/014363.html)
Already-ported Pyramid dependencies
- Chameleon (already worked under Py2.5 and Py3.2)
- Mako (already worked under Py2.4-Py3.2)
- MarkupSafe (already worked under Py2.4-Py3.2)
- translationstring (merged jayd3e's py3 branch to trunk, released as 0.4)
- venusian (jbohman ported, released as 1.0a1)
- zope.interface (ported as of 3.6.0+)
- repoze.lru (jbohman ported, released as 0.4)
- zope.deprecation (chrism ported, released as 3.5.0)
- WebTest (ported by gawel, released as 1.3.1)
- WebOb (Joe Dallago: GSOC 2011 project, Chris McDonough picked up porting work, docs and testing work still remains, but webob trunk at https://github.com/Pylons/webob has 3.2 support, no release yet save for zipballs such as the one at https://github.com/Pylons/webob/zipball/master)
- PasteDeploy (already ported by agronholm, available in 1.5.0)
Already-ported Pyramid scaffolding dependencies
- transaction (http://svn.zope.org/transaction/branches/chrism-py3/)
- zope.sqlalchemy (http://svn.zope.org/zope.sqlalchemy/branches/chrism-py3/)
- pyramid_exclog (version 0.5 released to PyPI, thanks to Joe Dallago).
- pyramid_tm (version 0.3, released to PyPI)
- pyramid_jinja2 (version 1.2, released to PyPI)
- pyramid_debugtoolbar (version 0.9.4, released to PyPI)
Pyramid dependencies removed (and thus didn't need to be ported)
- zope.component (jbohman factored out "zope.registry" and placed it in zope SVN; also see https://mail.zope.org/pipermail/zope-dev/2011-August/043340.html, this code was later moved to zope.interface in version 3.8.0, removed z.component dep in Pyramid 1.3)
- zope.configuration (removed core dependency on this in Pyramid 1.2a5+; still dep'ed on by pyramid_zcml)
- zope.i18nmessageid (transitive dep of zope.configuration; removed z.config dep in Pyramid 1.2a5+)
- zope.schema (transitive dep of zope.configuration; removed z.config dep in Pyramid 1.2a5+)
- zope.event (transitive dep of zope.component, removed zope.component dep in Pyramid 1.3)
Related Zope package info: http://permalink.gmane.org/gmane.comp.web.zope.devel/26373
Review documentation with an eye on the WebOb (1.2) and Pyramid (1.3) changelogs.
Remove pyramid_zodb scaffold and put into a separate package (ZODB wont work under Python 3).
Unrelated to porting but may want to take the opportunity to do it anyway; put Chameleon and Mako bindings into separately installable packages and have scaffolding rely on them instead of the core.
Figure out which default WSGI server to use instead of
paste.httpserver. There's a bit of difficulty here, as the only WSGI servers that actually work under Python 3 are wsgiref and mod_wsgi. The cherrypy server is advertised to work, but has a few bugs preventing it from meeting the PEP 3333 spec (you can try it and see, if you're curious; it won't serve any pages at all). It's also not distributed separately from the rest of the CherryPy framework. If we go with wsgiref, we lose the ability to advise people to put their apps straight into production behind a proxy, as we used to with paste.httpserver; wsgiref makes no performance or security claims (except against).
mod_wsgi. Update: it runs but no "real" app has been tested within it. That's because no "real" app runs under Python 3.