[Zope-dev] Porting zope.dottedname to Python 3
Marius Gedminas
marius at gedmin.as
Tue Feb 5 16:56:21 UTC 2013
This ought to be a wiki page somewhere, but since I can't even figure out how
to log in to http://wiki.zope.org, I'll settle for an email.
I'm trying to dip my toes into Python 3 migration of zope.*. Stephan
Richter suggested I start with zope.dottedname, since it's a very
trivial package with no dependencies.
The mailing list archive contains a lot of advice. (If this were a wiki
page, I'd add links to the relevant emails). What I'm trying to do
here is to provide a concrete example of the porting pattern discovered
by others (especially Lennart Regebro and Tres Seaver):
- make sure you've got Python interpreters for all the interesting
versions (2.6, 2.7, 3.2, 3.3) (duh)
- check out the sources (duh)
svn co svn+ssh://svn.zope.org/repos/main/zope.dottedname/trunk
- get the tests to pass with 'python setup.py test'
this basically means you need a
test_suite='zope.dottedname.tests.test_suite', which was already
there, and a tests_require=[...] if your tests have any
dependencies.
- get the tests to pass using tox -e py27, i.e. add a tox.ini
existing packages on github.com/zopefoundation provided examples
there; here's the one I started with for zope.dottedname:
[tox]
envlist =
py26,py27,py32,py33
# you can also add pypy because why not?
[testenv]
commands =
python setup.py test -q
- add a MANIFEST.in, because tox builds sdists and installs them into
virtualenvs under ./.tox, and because setuptools doesn't understand
Subversion 1.7 working trees
I used 'check-manifest --create' from https://gist.github.com/4277075
- see how the tests fail with tox -e py32 and/or py33
- decide that the easiest way to fix them for zope.dottedname would be
to add a renormalizer
https://github.com/zopefoundation/zope.dottedname/commit/1a2440c#diff-3
Alternative (and perhaps better) strategies would include rewriting
doctests into unittests
- this adds a test dependency on zope.testing:
+ edit setup.py and add tests_require=['zope.testing'],
+ also add extras={'testing': ['zope.testing']} because
+ you need to update buildout.cfg to require zope.dottedname[zope.testing]
+ also edit tox.ini and add
[testenv]
deps = zope.testing
(otherwise setup.py test will unpack zope.testing et al into $PWD and
clutter your working tree)
- get the tests passing (detox is very useful here as it runs tests for
all Pythons in parallel)
- check test coverage
I tried to get tox -e coverage working, gave up, and used the old
python setup.py bootstrap
bin/buildout
bin/test --coverage=coverage
method
- update Trove classifiers in setup.py:
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
- update CHANGES.txt and indicate Python 3.x support
- bump version number in CHANGES.txt and setup.py to 4.0.0 to indicate
Python 3.x support
- maybe migrate to github while you're at it
- make a release to PyPI eventually (zest.releaser FTW)
Marius Gedminas
--
http://pov.lt/ -- Zope 3/BlueBream consulting and development
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: Digital signature
URL: <http://mail.zope.org/pipermail/zope-dev/attachments/20130205/8e0ae6f0/attachment.sig>
More information about the Zope-Dev
mailing list