Differences between revisions 24 and 25
Revision 24 as of 2008-01-10 05:18:49
Size: 13478
Editor: PhilipJenvey
Comment: add setuptools-0.6 test results
Revision 25 as of 2008-01-10 05:23:12
Size: 13638
Editor: PhilipJenvey
Comment: elaborate on why we don't support this
Deletions are marked like this. Additions are marked like this.
Line 43: Line 43:
 * setuptools' use of marshal: setuptools uses marshal.load in two places -- to get a code object from a .pyc file, so it can scan the code object's co_names and co_consts (basically to read a module's variables without importing it).  * setuptools' use of marshal: setuptools uses marshal.load in two places -- to get a code object from a .pyc file, so it can scan the code object's co_names and co_consts (basically to read a module's variables without importing it). This isn't portable: Jython's compiled .pys (actually Java .class files) can't be read via marshal, nor do Jython's code objects support co_names and co_consts

Setuptools requirements:

  • PEP 302 style zipimport module Added in r3463

  • number of misc. Jython bug fixes most already committed

  • file descriptor support for tempfile.mkstemp, os.open and tarfile Added in r3711

  • tempfile.mkstemp Added in r3712

  • os.chdir (also needed for distutils) Added in r3844

  • tarfile module Added in r3850

  • a valid sys.executable. required by setuptools and distutils for spawning subprocesses. Added in r3867, enabled via -Dpython.executable (see http://article.gmane.org/gmane.comp.lang.jython.devel/4068 )

  • a site-packages dir (jython needs to include it on sys.path by default). required by setuptools and distutils Added in r3886

  • distutils: requires [http://hg.underboss.org/jython-pjenvey/rev/1026fe32c01c a number of small patches]:

    • a valid sys.executable Added in r3867

    • getpass module Added in r3876

    • distutils metadata for the os.name == 'java' (like path names, default bdist type, etc)
    • a jython spawn-like function: "error: don't know how to spawn programs on platform 'java'". os.system works as a replacement
    • compile .py files to $py.class instead of .pyc distutils and these last 3 modifications were added in r3888

  • imp.acquire/release_lock (and the accompanying lock_held which we don't actually need). Exposes the import machinery's lock via the imp module Added in r3894

  • setuptools runs a test to ensure .pth files work by running "sys.executable -E -c pass". -E is ignore environment on CPython, but is different on Jython (takes an argument):
    • -E codec : Use a different codec the reading from the console. -E codec renamed to -C codec in r4013. -E is now a noop (but valid) command line arg

  • os.lstat. setuptools cut and pasted shutil's rmtree from CPython 2.4, which uses lstat to check for a directory vs a symlink to a directory. We now support an os.stat that fills in st_mode's directory bit, but can we support lstat? (We definitely can with JNA)? Can setuptools avoid lstat completely (requiring a patch)? I don't think Java can safely determine a sym link yet. Java 1.7's JSR 203 (nio part 2) should address this as well as chmod, but we obviously need a solution for Java 1.5 Turned out we can implement a simple lstat in pure Java, added in r4014

We don't have:

  • os.chmod. This can be implemented with JNA. We can still support setuptools on deployments lacking JNA if we submit a patch back to setuptools to only use chmod if it exists
  • setuptools' use of marshal: setuptools uses marshal.load in two places -- to get a code object from a .pyc file, so it can scan the code object's co_names and co_consts (basically to read a module's variables without importing it). This isn't portable: Jython's compiled .pys (actually Java .class files) can't be read via marshal, nor do Jython's code objects support co_names and co_consts
    • the two places this is used:
    • when a package doesn't mark itself as zip_safe, setuptools will scan it for special variable names (like 'file') to determine zip_safetyness.

    • setuptools.depend.get_module_constant: a generic way to grab the value of a module variable. currently only used by Require.get_version

In Jython, in some cases the zip_safe check will avoid the marshal.load code path because there won't be any .pyc or .pyos in the package (because jython's distutils compiles .py to $py.class instead). Though there may be cases where Jython installs a .egg that already includes .pycs (they aren't pruned).

Unfortunately setuptools is defaulting zip_safe to True unless proved otherwise (and it won't be proved otherwise no .pycs exist). So even if marshal.load is avoided in some cases, those cases can be incorrectly marked as being zip_safe when they are not.

We'll probably need setuptools patched to just assume zip_safe=False under jython when a package doesn't define it, and to avoid marshal.load completely when scanning for zip_safety under Jython. I'm not sure how to workaround issue #2

setuptools-0.6 (from svn) tests: the first 3 failures are related to marshal.load, the 4th test also fails on CPython, and the final two failures are due to assuming CPython dict ordering

testExtractConst (setuptools.tests.DependsTests) ... ERROR
testFindModule (setuptools.tests.DependsTests) ... ok
testModuleExtract (setuptools.tests.DependsTests) ... ERROR
testRequire (setuptools.tests.DependsTests) ... ERROR
testContents (setuptools.tests.DistroTests) ... ok
testDistroType (setuptools.tests.DistroTests) ... ok
testEmpty (setuptools.tests.DistroTests) ... ok
testExcludePackage (setuptools.tests.DistroTests) ... ok
testExcludePackages (setuptools.tests.DistroTests) ... ok
testIncludeExclude (setuptools.tests.DistroTests) ... ok
testInvalidIncludeExclude (setuptools.tests.DistroTests) ... ok
testAvailability (setuptools.tests.FeatureTests) ... ok
testDefaults (setuptools.tests.FeatureTests) ... ok
testFeatureOptions (setuptools.tests.FeatureTests) ... ok
testFeatureWithInvalidRemove (setuptools.tests.FeatureTests) ... ok
testUseFeatures (setuptools.tests.FeatureTests) ... ok
testConflictingOptions (setuptools.tests.TestCommandTests) ... ok
testDefaultSuite (setuptools.tests.TestCommandTests) ... ok
testDefaultWModuleOnCmdLine (setuptools.tests.TestCommandTests) ... ok
testLongOptSuiteWNoDefault (setuptools.tests.TestCommandTests) ... ok
testNoSuite (setuptools.tests.TestCommandTests) ... ok
testTestIsCommand (setuptools.tests.TestCommandTests) ... ok
Doctest: api_tests.txt ... ok
test_bad_urls (setuptools.tests.test_packageindex.TestPackageIndex) ... FAIL
testCollection (setuptools.tests.test_resources.DistroTests) ... ok
testDistroBasics (setuptools.tests.test_resources.DistroTests) ... ok
testDistroDependsOptions (setuptools.tests.test_resources.DistroTests) ... ok
testDistroDependsSimple (setuptools.tests.test_resources.DistroTests) ... ok
testDistroMetadata (setuptools.tests.test_resources.DistroTests) ... ok
testDistroParse (setuptools.tests.test_resources.DistroTests) ... ok
testResolve (setuptools.tests.test_resources.DistroTests) ... ok
testBasics (setuptools.tests.test_resources.EntryPointTests) ... ok
testParse (setuptools.tests.test_resources.EntryPointTests) ... ok
testParseList (setuptools.tests.test_resources.EntryPointTests) ... FAIL
testParseMap (setuptools.tests.test_resources.EntryPointTests) ... FAIL
testRejects (setuptools.tests.test_resources.EntryPointTests) ... ok
testEmptyParse (setuptools.tests.test_resources.ParseTests) ... ok
testSafeName (setuptools.tests.test_resources.ParseTests) ... ok
testSafeVersion (setuptools.tests.test_resources.ParseTests) ... ok
testSimpleRequirements (setuptools.tests.test_resources.ParseTests) ... ok
testSplitting (setuptools.tests.test_resources.ParseTests) ... ok
testVersionEquality (setuptools.tests.test_resources.ParseTests) ... ok
testVersionOrdering (setuptools.tests.test_resources.ParseTests) ... ok
testYielding (setuptools.tests.test_resources.ParseTests) ... ok
testAdvancedContains (setuptools.tests.test_resources.RequirementsTests) ... ok
testBasicContains (setuptools.tests.test_resources.RequirementsTests) ... ok
testBasics (setuptools.tests.test_resources.RequirementsTests) ... ok
testOptionsAndHashing (setuptools.tests.test_resources.RequirementsTests) ... ok
testOrdering (setuptools.tests.test_resources.RequirementsTests) ... ok
testVersionEquality (setuptools.tests.test_resources.RequirementsTests) ... ok

======================================================================
ERROR: testExtractConst (setuptools.tests.DependsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/pjenvey/src/java/jython-trunk/dist/Lib/unittest.py", line 229, in __call__
    testMethod()
  File "/Users/pjenvey/src/python/setuptools-0.6/setuptools/tests/__init__.py", line 59, in testExtractConst
    self.assertEqual(extract_constant(f1.func_code,'q', -1), None)
  File "/Users/pjenvey/src/python/setuptools-0.6/setuptools/depends.py", line 220, in extract_constant
    if symbol not in code.co_names:
AttributeError: 'tablecode' object has no attribute 'co_names'

======================================================================
ERROR: testModuleExtract (setuptools.tests.DependsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/pjenvey/src/java/jython-trunk/dist/Lib/unittest.py", line 229, in __call__
    testMethod()
  File "/Users/pjenvey/src/python/setuptools-0.6/setuptools/tests/__init__.py", line 80, in testModuleExtract
    )
  File "/Users/pjenvey/src/python/setuptools-0.6/setuptools/depends.py", line 182, in get_module_constant
    code = marshal.load(f)
  File "/Users/pjenvey/src/java/jython-trunk/dist/Lib/marshal.py", line 323, in load
    return Unmarshaller(f).load()
  File "/Users/pjenvey/src/java/jython-trunk/dist/Lib/marshal.py", line 187, in load
    return self.dispatch[c](self)
KeyError: 

======================================================================
ERROR: testRequire (setuptools.tests.DependsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/pjenvey/src/java/jython-trunk/dist/Lib/unittest.py", line 229, in __call__
    testMethod()
  File "/Users/pjenvey/src/python/setuptools-0.6/setuptools/tests/__init__.py", line 99, in testRequire
    self.assertEqual(req.get_version(), __version__)
  File "/Users/pjenvey/src/python/setuptools-0.6/setuptools/depends.py", line 62, in get_version
    v = get_module_constant(self.module,self.attribute,default,paths)
  File "/Users/pjenvey/src/python/setuptools-0.6/setuptools/depends.py", line 182, in get_module_constant
    code = marshal.load(f)
  File "/Users/pjenvey/src/java/jython-trunk/dist/Lib/marshal.py", line 323, in load
    return Unmarshaller(f).load()
  File "/Users/pjenvey/src/java/jython-trunk/dist/Lib/marshal.py", line 187, in load
    return self.dispatch[c](self)
KeyError: 

======================================================================
FAIL: test_bad_urls (setuptools.tests.test_packageindex.TestPackageIndex)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/pjenvey/src/java/jython-trunk/dist/Lib/unittest.py", line 229, in __call__
    testMethod()
  File "/Users/pjenvey/src/python/setuptools-0.6/setuptools/tests/test_packageindex.py", line 19, in test_bad_urls
    self.assert_(False)
  File "/Users/pjenvey/src/java/jython-trunk/dist/Lib/unittest.py", line 278, in failUnless
    if not expr: raise self.failureException, msg
AssertionError

======================================================================
FAIL: testParseList (setuptools.tests.test_resources.EntryPointTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/pjenvey/src/java/jython-trunk/dist/Lib/unittest.py", line 229, in __call__
    testMethod()
  File "/Users/pjenvey/src/python/setuptools-0.6/setuptools/tests/test_resources.py", line 274, in testParseList
    self.checkSubMap(EntryPoint.parse_group("xyz", self.submap_str))
  File "/Users/pjenvey/src/python/setuptools-0.6/setuptools/tests/test_resources.py", line 264, in checkSubMap
    )
  File "/Users/pjenvey/src/java/jython-trunk/dist/Lib/unittest.py", line 302, in failUnlessEqual
    raise self.failureException, \
AssertionError: "{'feature3': EntryPoint.parse('feature3 = this.module [something]'), 'feature2': EntryPoint.parse('feature2 = another.module:SomeClass [extra1,extra2]'), 'feature1': EntryPoint.parse('feature1 = somemodule:somefunction')}" != "{'feature2': EntryPoint.parse('feature2 = another.module:SomeClass [extra1,extra2]'), 'feature3': EntryPoint.parse('feature3 = this.module [something]'), 'feature1': EntryPoint.parse('feature1 = somemodule:somefunction')}"

======================================================================
FAIL: testParseMap (setuptools.tests.test_resources.EntryPointTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/pjenvey/src/java/jython-trunk/dist/Lib/unittest.py", line 229, in __call__
    testMethod()
  File "/Users/pjenvey/src/python/setuptools-0.6/setuptools/tests/test_resources.py", line 281, in testParseMap
    self.checkSubMap(m['xyz'])
  File "/Users/pjenvey/src/python/setuptools-0.6/setuptools/tests/test_resources.py", line 264, in checkSubMap
    )
  File "/Users/pjenvey/src/java/jython-trunk/dist/Lib/unittest.py", line 302, in failUnlessEqual
    raise self.failureException, \
AssertionError: "{'feature3': EntryPoint.parse('feature3 = this.module [something]'), 'feature2': EntryPoint.parse('feature2 = another.module:SomeClass [extra1,extra2]'), 'feature1': EntryPoint.parse('feature1 = somemodule:somefunction')}" != "{'feature2': EntryPoint.parse('feature2 = another.module:SomeClass [extra1,extra2]'), 'feature3': EntryPoint.parse('feature3 = this.module [something]'), 'feature1': EntryPoint.parse('feature1 = somemodule:somefunction')}"

----------------------------------------------------------------------
Ran 50 tests in 2.342s

FAILED (failures=3, errors=3)

SetuptoolsOnJython (last edited 2010-01-02 16:58:16 by AndrewKuchling)