This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: test_distutils fails on Windows in 2.6.5rc2
Type: behavior Stage: test needed
Components: Distutils Versions: Python 2.6
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: loewis Nosy List: barry, ezio.melotti, loewis, ned.deily, ronaldoussoren, tarek, vstinner
Priority: release blocker Keywords: buildbot

Created on 2010-03-10 08:20 by loewis, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (23)
msg100779 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2010-03-10 08:20
test_distutils fails like this:

test test_distutils crashed -- <type 'exceptions.TypeError'>: object of type 'NoneType' has no len()
Traceback (most recent call last):
  File "Lib\test\regrtest.py", line 560, in runtest_inner
    indirect_test()
  File "c:\Python26\lib\test\test_distutils.py", line 13, in test_main
    test.test_support.run_unittest(distutils.tests.test_suite())
  File "c:\Python26\lib\distutils\tests\__init__.py", line 30, in test_suite
    suite.addTest(module.test_suite())
  File "c:\Python26\lib\distutils\tests\test_build_ext.py", line 391, in test_suite
    src = _get_source_filename()
  File "c:\Python26\lib\distutils\tests\test_build_ext.py", line 22, in _get_sou
rce_filename
    return os.path.join(srcdir, 'Modules', 'xxmodule.c')
  File "c:\Python26\lib\ntpath.py", line 96, in join
    assert len(path) > 0
TypeError: object of type 'NoneType' has no len()

Not sure whether this is a regression from 2.6.4.
msg100781 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2010-03-10 12:36
This has been introduced in r77955, and affected all the 2.6 Windows buildbots (e.g. http://www.python.org/dev/buildbot/builders/x86%20XP-5%202.6/builds/9/steps/test/logs/stdio).
The problem is caused by the fact that "srcdir = sysconfig.get_config_var('srcdir')" returns None on Windows.
msg100811 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2010-03-10 22:44
Um, this sucks because I think that that means it was introduced after 2.6.4 final.  Since it's a regression, marking as a blocker for 2.6.5 final, but in order to stay a blocker it has to be a really critical bug and I'll want to review the fix before it goes it (to make sure it doesn't break anything else).  Otherwise, I'll bump it down to deferred blocker and we can fix it for 2.6.6.
msg100812 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-03-10 22:51
r77955 is a backport of r69304, commit made 12 months before the backport. It's related to issue #4151.
msg100813 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-03-10 22:53
The patch replaces sysconfig.project_base by sysconfig.get_config_var('srcdir'). You can maybe use sysconfig.project_base if sysconfig.get_config_var('srcdir') is None?
msg100815 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2010-03-10 23:23
This test just grabs xxmodule.c from Python to try out a compilation.

It's a lot of work just to try out a .c file in build_ext. I've already changed this in trunk by having a c file local to distutils tests, as a fallback in case the location cannot be found (depending on the execution context).

I can backport this to 2.6. It's pretty safe to do it since its just a change in the test, the distutils code is not changed. Barry let me know if you want me to do backport it in release26, and if yes, when I should do it.
msg100816 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2010-03-10 23:50
I'm guessing this falls into the same category as Issue8102, that is, since the python tests are also installed and run on end-user systems by various installers, it is important that none of the tests depend on files from a python build directory or source tree.  In other words, if a test needs a file, that file needs to be explicitly installed.
msg100826 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2010-03-11 01:47
Tarek, I guess the fix is as haypo suggests?  Just use sysconfig.project_base if sysconfig.get_config_var('srcdir') returns None?

If that's the only change, then please do fix this for 2.6.5 final.  Thanks!
msg100833 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2010-03-11 04:55
No that won't work because the test tries to find a module that is only in the source dir. So not existing on python installations. The simplest thing to do is to skip the test if srcdir cannot be found. 

I'll fix this asap
msg100834 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2010-03-11 05:03
Also, notice that srcdir can be broken on some platform. For instance, under Mac OS X Framework install:

>>> import distutils.sysconfig
>>> distutils.sysconfig.get_config_var('srcdir')
'/Volumes/Rivendell/Users/ronald/Projects/python/r264'

we get the path that was used by Ronald to compile the distribution :)

Working on it..
msg100835 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2010-03-11 06:25
It's not that "srcdir" is broken - that undoubtedly was the value of the source directory on the *build* machine.  The problem is that "srcdir", (and likely some other build related config variables) has no meaning other than on the *build* machine at the time of the build.  It (they) cannot in general be meaningfully used at execution time, particularly if the install takes place on a machine other than build machine.
msg100837 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2010-03-11 06:53
IMHO stuffing xxmodule.c inside the distutils test tree (see msg100815) is the right solution because the python source tree might not be present during testing (such as when the user does a binary install and then runs the unittests to check if everything works).

Tarek: sysconfig.get_config_var('srcdir') returns the value of 'srcdir' in  'Makefile' and that value is only valid during the build of Python. It is the variable that is used in Python's makefiles to refer to files in the source tree and is needed when you run configure from a directory that is not the root of the source tree.
msg100858 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2010-03-11 14:46
Adding xxmodule.c to the test directory is more than I want to do for 2.6.5.  The actual crash happens because if sysconfig.get_config_var('srcdir') returns None, os.path.join() will traceback.  It doesn't know how to handle None arguments.  So my suggestion is that when srcdir is None, fallback to using sysconfig.project_base as before.

As long as that is guaranteed to be a string, we won't get the crash.  _get_source_filename() will return some bogus but syntactically valid path, and then the os.path.exists() test in test_suite() will return False, so the test will be skipped.  That seems like the safest change for 2.6.5 final, though I am fine with backporting the trunk fix for realzies in 2.6.6.
msg100872 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2010-03-11 16:07
@Ronald, @Barry: Yes that's what I did in trunk, so I can just merge that revision. (r78707, r78709)

The only problem I had with it is that in case xxmodule.c changes, I have to change it there too, but it's no big deal.

Barry, I'll merge back this as soon as I get a correct wifi connection this week :)  (I am at a conference)
msg100951 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2010-03-12 18:28
done in r78877
msg100952 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2010-03-12 18:47
Tarek, r78877 is not the fix I recommended in

http://bugs.python.org/issue8107#msg100858

Are you sure you're more comfortable with the one you committed than the one I suggested?
msg100955 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2010-03-12 18:59
This will skip the whole test class if srcdir is not found, removing all tests run in test_build_ext.

Are you sure you want to skip the whole test class if the srcdir is not there for 2.6.5 final ? (we have important tests in there, related to options like inplace etc)

If so, I'll change it like you said (so test_build_ext is completely skipped under some environments).
msg100959 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2010-03-12 19:35
Hi Martin,

Can you just double check that the addition of xxmodule.c won't cause problems with the Windows installer.  If it's okay (no problems), please close this bug and we'll keep the fix.

Thanks.
msg101013 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2010-03-13 18:12
The patch in its current form is incomplete: xxmodule.c won't end up on the target system, since msi.py doesn't package it. So that would need to be changed as well.

With the current release26-maint branch, test_distutils now passes, both with xxmodule.c present, and with it being absent. If it is present, test_distutils prints a number of additional output lines, starting with "Creating library ...".

I also agree that the change is too heavy for the 2.6 maintenance release.
msg101014 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2010-03-13 18:28
Ok then, I am applying Barry's suggestion right now in release26-maint then
msg101015 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2010-03-13 18:46
done in r78935.
msg101026 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2010-03-13 22:24
So, issue closed right?  Or do you want to keep it bumped down and open for 2.6.6?
msg101029 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2010-03-13 22:34
No I guess its fine to leave it closed.
History
Date User Action Args
2022-04-11 14:56:58adminsetgithub: 52354
2010-03-13 22:34:38tareksetmessages: + msg101029
2010-03-13 22:24:23barrysetstatus: open -> closed

messages: + msg101026
2010-03-13 18:46:58tareksetmessages: + msg101015
2010-03-13 18:28:20tareksetmessages: + msg101014
2010-03-13 18:12:15loewissetmessages: + msg101013
2010-03-12 19:35:58barrysetassignee: tarek -> loewis
messages: + msg100959
2010-03-12 18:59:59tareksetstatus: closed -> open

messages: + msg100955
2010-03-12 18:47:27barrysetmessages: + msg100952
2010-03-12 18:28:23tareksetstatus: open -> closed

messages: + msg100951
2010-03-11 16:07:14tareksetmessages: + msg100872
2010-03-11 14:46:08barrysetmessages: + msg100858
2010-03-11 06:53:52ronaldoussorensetnosy: + ronaldoussoren
messages: + msg100837
2010-03-11 06:25:45ned.deilysetmessages: + msg100835
2010-03-11 05:03:46tareksetmessages: + msg100834
2010-03-11 04:55:04tareksetmessages: + msg100833
2010-03-11 01:47:41barrysetmessages: + msg100826
2010-03-10 23:50:24ned.deilysetnosy: + ned.deily
messages: + msg100816
2010-03-10 23:23:22tareksetmessages: + msg100815
2010-03-10 22:53:16vstinnersetmessages: + msg100813
2010-03-10 22:51:52vstinnersetnosy: + vstinner
messages: + msg100812
2010-03-10 22:44:16barrysetpriority: high -> release blocker

messages: + msg100811
2010-03-10 13:50:29tareksetpriority: normal -> high
resolution: accepted
2010-03-10 12:36:06ezio.melottisetpriority: normal

type: behavior

keywords: + buildbot
nosy: + ezio.melotti
messages: + msg100781
stage: test needed
2010-03-10 08:20:19loewiscreate