
Hi,
I want to port pyobjc to python 3.1 and need a py3k port of setuptools for that. I'm slowy moving forward with the latter, partly based on earlier discussions on this list. I don't have anything useful to share at the moment, beyond a setup3.py file (see below).
But first a question: some of the tests use docutils and I'm having a hard time getting those to run with both python3 and python2. The bit that's particularly annoying is this bit of api_tests.txt:
Note that asking for a conflicting version of a distribution already in a working set triggers a ``pkg_resources.VersionConflict`` error:
>>> ws.find(Requirement.parse("Bar==1.0")) # doctest: +NORMALIZE_WHITESPACE Traceback (most recent call last): ... VersionConflict: (Bar 0.9 (http://example.com/something), Requirement.parse('Bar==1.0'))
This passes with 2.6, but fails in 3.1 because it expects 'pkg_resources.VersionConflict' rather than just 'VersionConflict'. What's the best way to work around this issue?
The attached file "setup3.py" is a script that incrementally copies the setuptools source-tree to a temporary directory, runs 2to3 on that copy and exec-s the contents of the translated 'setup.py' file. This seems to be good enough to be able to install setuptools for python2 and python3 using the same code-base. That said, this is just the first step of a python3 port there need to be changes to the setuptools sources to be able to actually use the translated sources.
Ronald

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Ronald Oussoren wrote:
But first a question: some of the tests use docutils and I'm having a hard time getting those to run with both python3 and python2. The bit that's particularly annoying is this bit of api_tests.txt:
Note that asking for a conflicting version of a distribution
already in a working set triggers a ``pkg_resources.VersionConflict`` error:
>>> ws.find(Requirement.parse("Bar==1.0")) # doctest:
+NORMALIZE_WHITESPACE* Traceback (most recent call last): ... VersionConflict: (Bar 0.9 (http://example.com/something), Requirement.parse('Bar==1.0'))
This passes with 2.6, but fails in 3.1 because it expects 'pkg_resources.VersionConflict' rather than just 'VersionConflict'. What's the best way to work around this issue?
Don't rely on the repr of an exception. This kind of problem is why I hate using doctest to test edge cases. If you must, then something like:
from pkg_resources import VersionConflict try:
... ws.find(Requirement.parse("Bar==1.0")) ... except VersionConflict: ... pass ... else: ... print 'VersionConflict not raised.'
with no output expected. Note that this is actually *less* verbose and easier to understand than the repr bit. Of course, a traditional unit test would be even shorter and easier to understand.
The attached file "setup3.py" is a script that incrementally copies the setuptools source-tree to a temporary directory, runs 2to3 on that copy and exec-s the contents of the translated 'setup.py' file. This seems to be good enough to be able to install setuptools for python2 and python3 using the same code-base. That said, this is just the first step of a python3 port there need to be changes to the setuptools sources to be able to actually use the translated sources.
Great work.
Tres. - -- =================================================================== Tres Seaver +1 540-429-0999 tseaver@palladion.com Palladion Software "Excellence by Design" http://palladion.com

On 8 Jun, 2009, at 5:53, Tres Seaver wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Ronald Oussoren wrote:
But first a question: some of the tests use docutils and I'm having a hard time getting those to run with both python3 and python2. The bit that's particularly annoying is this bit of api_tests.txt:
Note that asking for a conflicting version of a distribution already in a working set triggers a ``pkg_resources.VersionConflict`` error:
ws.find(Requirement.parse("Bar==1.0")) # doctest:
+NORMALIZE_WHITESPACE* Traceback (most recent call last): ... VersionConflict: (Bar 0.9 (http://example.com/something), Requirement.parse('Bar==1.0'))
This passes with 2.6, but fails in 3.1 because it expects 'pkg_resources.VersionConflict' rather than just 'VersionConflict'. What's the best way to work around this issue?
Don't rely on the repr of an exception. This kind of problem is why I hate using doctest to test edge cases. If you must, then something like:
from pkg_resources import VersionConflict try:
... ws.find(Requirement.parse("Bar==1.0")) ... except VersionConflict: ... pass ... else: ... print 'VersionConflict not raised.'
with no output expected. Note that this is actually *less* verbose and easier to understand than the repr bit. Of course, a traditional unit test would be even shorter and easier to understand.
I like your workaround. A tradition unittest would be better, but I'd prefer to keep the patches for py3k support as small as possible.
The attached file "setup3.py" is a script that incrementally copies the setuptools source-tree to a temporary directory, runs 2to3 on that copy and exec-s the contents of the translated 'setup.py' file. This seems to be good enough to be able to install setuptools for python2 and python3 using the same code-base. That said, this is just the first step of a python3 port there need to be changes to the setuptools sources to be able to actually use the translated sources.
Great work.
This is only a first step, I'm found a number of annoying issues that might require interface changes to get right (such a number of functions in pkg_resources that claim to return a string, but actually return bytes (by opening a file in binary mode and returning the file contents). Hopefully I'll have a set of patches soonish, that would make discussion easier.
Ronald
Tres.
=================================================================== Tres Seaver +1 540-429-0999 tseaver@palladion.com Palladion Software "Excellence by Design" http://palladion.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFKLQnZ+gerLs4ltQ4RAh3cAJ4wHai8q+svdYKjDLB3sk8LwshIMgCg1PDL xFCDzoM52IwA1n0rUlBsWpU= =zl9H -----END PGP SIGNATURE-----
Distutils-SIG maillist - Distutils-SIG@python.org http://mail.python.org/mailman/listinfo/distutils-sig

On Mon, Jun 8, 2009 at 5:27 PM, Ronald Oussorenronaldoussoren@mac.com wrote:
Great work.
+1
This is only a first step, I'm found a number of annoying issues that might require interface changes to get right (such a number of functions in pkg_resources that claim to return a string, but actually return bytes (by opening a file in binary mode and returning the file contents). Hopefully I'll have a set of patches soonish, that would make discussion easier.
There are also a lot of important pending patches for setuptools 'trunk'
Phillip, can we move forward and retire the 0.6.x branch with a final release, then start to work on the python 3 port in the 0.7 branch ?
Do you need help to do this / how may I help to speed up this final release ?
Regards Tarek
participants (3)
-
Ronald Oussoren
-
Tarek Ziadé
-
Tres Seaver