classification
Title: test_distutils fails for Python 3.1b1 on MacOS X
Type: behavior Stage:
Components: IO, Tests Versions: Python 3.1
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: MrJean1, amaury.forgeotdarc, ned.deily, pitrou
Priority: normal Keywords:

Created on 2009-05-07 17:13 by MrJean1, last changed 2009-05-16 17:10 by ned.deily. This issue is now closed.

Files
File name Uploaded Description Edit
Issue5956.jpg MrJean1, 2009-05-13 20:28 Finder window of Lib/distutils/command
Messages (11)
msg87378 - (view) Author: Jean Brouwers (MrJean1) Date: 2009-05-07 17:13
% make test
....
test_distutils
test test_distutils failed -- Traceback (most recent call last):
  File "../Python-3.1b1/Lib/distutils/tests/test_bdist_wininst.py", line 
23, in test_get_exe_bytes
    exe_file = cmd.get_exe_bytes()
  File "../Python-3.1b1/Lib/distutils/command/bdist_wininst.py", line 
343, in get_exe_bytes
    return open(filename, "rb").read()
IOError: [Errno 21] Is a directory: '../Python-
3.1b1/Lib/distutils/command/wininst-6.0.exe'
....

% ./python.exe Lib/test/test_distutils.py
test_formats (distutils.tests.test_bdist.BuildTestCase) ... ok
test_simple_built (distutils.tests.test_bdist_dumb.BuildDumbTestCase) 
... ok
test_no_optimize_flag (distutils.tests.test_bdist_rpm.BuildRpmTestCase) 
... ok
test_quiet (distutils.tests.test_bdist_rpm.BuildRpmTestCase) ... ok
test_get_exe_bytes 
(distutils.tests.test_bdist_wininst.BuildWinInstTestCase) ... ERROR
... <all other tests are ... ok>

======================================================================
ERROR: test_get_exe_bytes 
(distutils.tests.test_bdist_wininst.BuildWinInstTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "../Python-3.1b1/Lib/distutils/tests/test_bdist_wininst.py", line 
23, in test_get_exe_bytes
    exe_file = cmd.get_exe_bytes()
  File "../Python-3.1b1/Lib/distutils/command/bdist_wininst.py", line 
343, in get_exe_bytes
    return open(filename, "rb").read()
IOError: [Errno 21] Is a directory: '../Python-
3.1b1/Lib/distutils/command/wininst-6.0.exe'

----------------------------------------------------------------------
Ran 97 tests in 0.948s

FAILED (errors=1)
Traceback (most recent call last):
  File "Lib/test/test_distutils.py", line 17, in <module>
    test_main()
  File "Lib/test/test_distutils.py", line 13, in test_main
    test.support.run_unittest(distutils.tests.test_suite())
  File "../Python-3.1b1/Lib/test/support.py", line 878, in run_unittest
    _run_suite(suite)
  File "../Python-3.1b1/Lib/test/support.py", line 861, in _run_suite
    raise TestFailed(err)
test.support.TestFailed: Traceback (most recent call last):
  File "../Python-3.1b1/Lib/distutils/tests/test_bdist_wininst.py", line 
23, in test_get_exe_bytes
    exe_file = cmd.get_exe_bytes()
  File "../Python-3.1b1/Lib/distutils/command/bdist_wininst.py", line 
343, in get_exe_bytes
    return open(filename, "rb").read()
IOError: [Errno 21] Is a directory: '../Python-
3.1b1/Lib/distutils/command/wininst-6.0.exe'

% ./python.exe
Python 3.1b1 (r31b1:72412, May  7 2009, 09:16:22) 
[GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
msg87697 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009-05-13 17:47
"Is a directory"? I suppose you are trying to install from a source tar
ball? What happens when you try to "ls" this file?
msg87705 - (view) Author: Jean Brouwers (MrJean1) Date: 2009-05-13 20:14
Indeed, this is Python 3.1b1 built from source on MacOS X 10.4.1 Tiger 
(Intel).

MacOS considers some of these win*.exe files directories.  See the 
attached picture and below.

% ls -l Python-3.1b1/Lib/distutils/command/win*
-rw-r--r--   1 jean  jean   61440 Jul 15  2008 Python-
3.1b1/Lib/distutils/command/wininst-6.0.1.exe
-rw-r--r--   1 jean  jean   65536 Jul 15  2008 Python-
3.1b1/Lib/distutils/command/wininst-7.1.1.exe
-rw-r--r--   1 jean  jean   61440 Jan 20 13:25 Python-
3.1b1/Lib/distutils/command/wininst-8.0.1.exe
-rw-r--r--   1 jean  jean  224256 Jan 29 05:08 Python-
3.1b1/Lib/distutils/command/wininst-9.0-amd64.1.exe
-rw-r--r--   1 jean  jean  196096 Jan 29 05:08 Python-
3.1b1/Lib/distutils/command/wininst-9.0.exe

Python-3.1b1/Lib/distutils/command/wininst-6.0.exe:

Python-3.1b1/Lib/distutils/command/wininst-7.1.exe:

Python-3.1b1/Lib/distutils/command/wininst-8.0.exe:

Python-3.1b1/Lib/distutils/command/wininst-9.0-amd64.exe:

% ls -l Python-3.1b1/Lib/distutils/command/
total 2240
....
-rw-r--r--   1 jean  jean   61440 Jul 15  2008 wininst-6.0.1.exe
drwxr-xr-x   2 jean  jean      68 May  7 09:10 wininst-6.0.exe
-rw-r--r--   1 jean  jean   65536 Jul 15  2008 wininst-7.1.1.exe
drwxr-xr-x   2 jean  jean      68 May  7 09:10 wininst-7.1.exe
-rw-r--r--   1 jean  jean   61440 Jan 20 13:25 wininst-8.0.1.exe
drwxr-xr-x   2 jean  jean      68 May  7 09:10 wininst-8.0.exe
-rw-r--r--   1 jean  jean  224256 Jan 29 05:08 wininst-9.0-amd64.1.exe
drwxr-xr-x   2 jean  jean      68 May  7 09:10 wininst-9.0-amd64.exe
-rw-r--r--   1 jean  jean  196096 Jan 29 05:08 wininst-9.0.exe
msg87706 - (view) Author: Jean Brouwers (MrJean1) Date: 2009-05-13 20:28
Another attempt to attach the image.
msg87843 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-05-15 22:54
Ouch! Could you try to simply open() an exe file in the interactive
interpreter?
What does os.stat() give on this exe file?
What does os.stat() give on a "real" directory?

If some files are also directories under MacOS X, perhaps we must
reconsider the directory detection routine in _fileio.c.
msg87844 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-05-15 23:11
Where does wininst-6.0.1.exe come from? I don't see it on a fresh
checkout (there's only wininst-6.0.exe (without the ".1")). Does MacOS X
create these "aliases" automatically?

Did you install Python 3.1 or are your running directly from the source
tree?
msg87851 - (view) Author: Jean Brouwers (MrJean1) Date: 2009-05-16 03:16
Here are the answers to your questions.

% python
Python 2.6.2 (r262:71600, Apr 16 2009, 09:17:39) 
[GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> f = open('Lib/distutils/command/wininst-6.0.exe')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IOError: [Errno 21] Is a directory: 'Lib/distutils/command/wininst-6.0.exe'

>>> import os
>>> os.path.isdir('Lib/distutils/command/wininst-6.0.exe')
True

>>> os.stat('Lib/distutils/command/wininst-6.0.exe')
posix.stat_result(st_mode=16877, st_ino=6314085L, st_dev=234881026L, st_nlink=2, st_uid=501, 
st_gid=501, st_size=68L, st_atime=1242244664, st_mtime=1241712622, st_ctime=1241712622)

>>> os.stat('Lib/distutils/command')
posix.stat_result(st_mode=16877, st_ino=6314060L, st_dev=234881026L, st_nlink=58, st_uid=501, 
st_gid=501, st_size=1972L, st_atime=1242244781, st_mtime=1242245012, st_ctime=1242245012)


But here is the root cause.  The Python-3.1b1 files were created by Stuffit Expander ffrom the original 
Python-3.1b1 tar ball downloaded from the Python website.  Changing the Stuffit preferences does not 
make any difference.  

However, if that same tar ball is uncompressed by the  tar -zxf ... command, there are no directories.  
Only five simple files, as expected:

-rw-r--r--   1 jean  jean   61440 Jul 15  2008 wininst-6.0.exe
-rw-r--r--   1 jean  jean   65536 Jul 15  2008 wininst-7.1.exe
-rw-r--r--   1 jean  jean   61440 Jan 20 13:25 wininst-8.0.exe
-rw-r--r--   1 jean  jean  224256 Jan 29 05:08 wininst-9.0-amd64.exe
-rw-r--r--   1 jean  jean  196096 Jan 29 05:08 wininst-9.0.exe


After removing the directory files (and renaming the *.1.exe to *.exe), the regression tests passes.

% ./python.exe ../Python-3.1b1/Lib/test/test_distutils.py
test_formats (distutils.tests.test_bdist.BuildTestCase) ... ok
test_simple_built (distutils.tests.test_bdist_dumb.BuildDumbTestCase) ... ok
test_no_optimize_flag (distutils.tests.test_bdist_rpm.BuildRpmTestCase) ... ok
test_quiet (distutils.tests.test_bdist_rpm.BuildRpmTestCase) ... ok
test_get_exe_bytes (distutils.tests.test_bdist_wininst.BuildWinInstTestCase) ... ok
test_build_libraries (distutils.tests.test_build_clib.BuildCLibTestCase) ... ok
test_check_library_dist (distutils.tests.test_build_clib.BuildCLibTestCase) ... ok
test_finalize_options (distutils.tests.test_build_clib.BuildCLibTestCase) ... ok
test_get_source_files (distutils.tests.test_build_clib.BuildCLibTestCase) ... ok
test_build_ext (distutils.tests.test_build_ext.BuildExtTestCase) ... ok
test_optional_extension (distutils.tests.test_build_ext.BuildExtTestCase) ... ok
test_solaris_enable_shared (distutils.tests.test_build_ext.BuildExtTestCase) ... ok
test_user_site (distutils.tests.test_build_ext.BuildExtTestCase) ... ok
test_empty_package_dir (distutils.tests.test_build_py.BuildPyTestCase) ... ok
test_package_data (distutils.tests.test_build_py.BuildPyTestCase) ... ok
test_build (distutils.tests.test_build_scripts.BuildScriptsTestCase) ... ok
test_default_settings (distutils.tests.test_build_scripts.BuildScriptsTestCase) ... ok
test_version_int (distutils.tests.test_build_scripts.BuildScriptsTestCase) ... ok
test_check_all (distutils.tests.test_check.CheckTestCase) ... ok
test_check_document (distutils.tests.test_check.CheckTestCase) ... ok
test_check_metadata (distutils.tests.test_check.CheckTestCase) ... ok
test_check_restructuredtext (distutils.tests.test_check.CheckTestCase) ... ok
test_simple_run (distutils.tests.test_clean.cleanTestCase) ... ok
test_dump_options (distutils.tests.test_cmd.CommandTestCase) ... ok
test_ensure_dirname (distutils.tests.test_cmd.CommandTestCase) ... ok
test_ensure_filename (distutils.tests.test_cmd.CommandTestCase) ... ok
test_ensure_string (distutils.tests.test_cmd.CommandTestCase) ... ok
test_ensure_string_list (distutils.tests.test_cmd.CommandTestCase) ... ok
test_make_file (distutils.tests.test_cmd.CommandTestCase) ... ok
test_server_empty_registration (distutils.tests.test_config.PyPIRCCommandTestCase) ... ok
test_server_registration (distutils.tests.test_config.PyPIRCCommandTestCase) ... ok
test_clean (distutils.tests.test_config_cmd.ConfigTestCase) ... ok
test_dump_file (distutils.tests.test_config_cmd.ConfigTestCase) ... ok
test_finalize_options (distutils.tests.test_config_cmd.ConfigTestCase) ... ok
test_search_cpp (distutils.tests.test_config_cmd.ConfigTestCase) ... ok
test_run_setup_provides_file (distutils.tests.test_core.CoreTestCase) ... ok
test_run_setup_uses_current_dir (distutils.tests.test_core.CoreTestCase) ... ok
test_copy_tree_verbosity (distutils.tests.test_dir_util.DirUtilTestCase) ... ok
test_create_tree_verbosity (distutils.tests.test_dir_util.DirUtilTestCase) ... ok
test_mkpath_remove_tree_verbosity (distutils.tests.test_dir_util.DirUtilTestCase) ... ok
test_command_packages_cmdline (distutils.tests.test_dist.DistributionTestCase) ... ok
test_command_packages_configfile (distutils.tests.test_dist.DistributionTestCase) ... ok
test_command_packages_unspecified (distutils.tests.test_dist.DistributionTestCase) ... ok
test_empty_options (distutils.tests.test_dist.DistributionTestCase) ... ok
test_custom_pydistutils (distutils.tests.test_dist.MetadataTestCase) ... ok
test_obsoletes (distutils.tests.test_dist.MetadataTestCase) ... ok
test_obsoletes_illegal (distutils.tests.test_dist.MetadataTestCase) ... ok
test_provides (distutils.tests.test_dist.MetadataTestCase) ... ok
test_provides_illegal (distutils.tests.test_dist.MetadataTestCase) ... ok
test_requires (distutils.tests.test_dist.MetadataTestCase) ... ok
test_requires_illegal (distutils.tests.test_dist.MetadataTestCase) ... ok
test_simple_metadata (distutils.tests.test_dist.MetadataTestCase) ... ok
test_move_file_verbosity (distutils.tests.test_file_util.FileUtilTestCase) ... ok
test_glob_to_re (distutils.tests.test_filelist.FileListTestCase) ... ok
test_home_installation_scheme (distutils.tests.test_install.InstallTestCase) ... ok
test_user_site (distutils.tests.test_install.InstallTestCase) ... ok
test_simple_run (distutils.tests.test_install_data.InstallDataTestCase) ... ok
test_simple_run (distutils.tests.test_install_headers.InstallHeadersTestCase) ... ok
test_default_settings (distutils.tests.test_install_scripts.InstallScriptsTestCase) ... ok
test_installation (distutils.tests.test_install_scripts.InstallScriptsTestCase) ... ok
test_no_compiler (distutils.tests.test_msvc9compiler.msvc9compilerTestCase) ... ok
test_reg_class (distutils.tests.test_msvc9compiler.msvc9compilerTestCase) ... ok
test_create_pypirc (distutils.tests.test_register.registerTestCase) ... ok
test_password_not_in_file (distutils.tests.test_register.registerTestCase) ... ok
test_password_reset (distutils.tests.test_register.registerTestCase) ... ok
test_registering (distutils.tests.test_register.registerTestCase) ... ok
test_server_empty_registration (distutils.tests.test_register.registerTestCase) ... ok
test_server_registration (distutils.tests.test_register.registerTestCase) ... ok
test_add_defaults (distutils.tests.test_sdist.sdistTestCase) ... ok
test_make_distribution (distutils.tests.test_sdist.sdistTestCase) ... ok
test_prune_file_list (distutils.tests.test_sdist.sdistTestCase) ... ok
test_server_empty_registration (distutils.tests.test_sdist.sdistTestCase) ... ok
test_server_registration (distutils.tests.test_sdist.sdistTestCase) ... ok
test_nt_quote_args (distutils.tests.test_spawn.SpawnTestCase) ... ok
test_customize_compiler (distutils.tests.test_sysconfig.SysconfigTestCase) ... ok
test_get_config_h_filename (distutils.tests.test_sysconfig.SysconfigTestCase) ... ok
test_get_config_vars (distutils.tests.test_sysconfig.SysconfigTestCase) ... ok
test_get_python_inc (distutils.tests.test_sysconfig.SysconfigTestCase) ... ok
test_get_python_lib (distutils.tests.test_sysconfig.SysconfigTestCase) ... ok
test_class (distutils.tests.test_text_file.TextFileTestCase) ... ok
test_finalize_options (distutils.tests.test_upload.uploadTestCase) ... ok
test_saved_password (distutils.tests.test_upload.uploadTestCase) ... ok
test_server_empty_registration (distutils.tests.test_upload.uploadTestCase) ... ok
test_server_registration (distutils.tests.test_upload.uploadTestCase) ... ok
test_upload (distutils.tests.test_upload.uploadTestCase) ... ok
test_change_root (distutils.tests.test_util.utilTestCase) ... ok
test_check_environ (distutils.tests.test_util.utilTestCase) ... ok
test_convert_path (distutils.tests.test_util.utilTestCase) ... ok
test_get_platform (distutils.tests.test_util.utilTestCase) ... ok
test_rfc822_escape (distutils.tests.test_util.utilTestCase) ... ok
test_split_quoted (distutils.tests.test_util.utilTestCase) ... ok
test_strtobool (distutils.tests.test_util.utilTestCase) ... ok
test_cmp (distutils.tests.test_version.VersionTestCase) ... ok
test_cmp_strict (distutils.tests.test_version.VersionTestCase) ... ok
test_prerelease (distutils.tests.test_version.VersionTestCase) ... ok
Doctest: distutils.versionpredicate.VersionPredicate ... ok
Doctest: distutils.versionpredicate.split_provision ... ok

----------------------------------------------------------------------
Ran 97 tests in 2.646s

OK


My apologies for creating this much trouble.
msg87860 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009-05-16 08:24
Is it possible that Stuffit tries to unpack every compressed file found 
inside the tar file?
the wininst*.exe files are templates for installers. They likely contain  
part of the signature of a ZIP file, and Stuffit would handle them as an 
archive to unpack.
msg87864 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-05-16 08:41
Ok, I was fearing some MacOS X-specific "feature" à la application bundles.
Thanks for reporting the problem anyway :)
msg87902 - (view) Author: Jean Brouwers (MrJean1) Date: 2009-05-16 16:37
Possible, I do not know and had never seen this before.

Also, I just installed the latest (free) version 13.0.3 (Intel Build 
165) of Stuffit Expander and the problem does *not* occur.  

But the older Stuffit 11.0.2 (Intel Build 627) still creates 2 files for 
each of these wininst-*.exe file, an empty directory called wininst-
X.exe and a file called wininst-X.1.exe.  And only for these particular 
wininst-*.exe files.  For other *.exe files, empry ones, binaries and 
even files named wininst-X.exe, Stuffit 11 creates only the single file.
msg87905 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2009-05-16 17:10
Another good reason not to install Stuffit or Stuffit Expander.  These 
days OS X expands the standard open formats (i.e. .gz, .zip, .tar, etc) 
all by itself, and there are the standard command line tools as well.  
If you need Stuffit for actual stuffit archives, I think there is (or 
was) a preference in Stuffit Expander and Stuffit so you can restrict 
which formats they should process.
History
Date User Action Args
2009-05-16 17:10:18ned.deilysetnosy: + ned.deily
messages: + msg87905
2009-05-16 16:37:42MrJean1setmessages: + msg87902
2009-05-16 08:42:00pitrousetstatus: open -> closed
resolution: not a bug
messages: + msg87864
2009-05-16 08:24:28amaury.forgeotdarcsetmessages: + msg87860
2009-05-16 03:16:41MrJean1setmessages: + msg87851
2009-05-15 23:11:07pitrousetmessages: + msg87844
2009-05-15 22:55:05pitrousetnosy: amaury.forgeotdarc, pitrou, MrJean1
components: + IO
2009-05-15 22:54:45pitrousetnosy: + pitrou
messages: + msg87843
2009-05-13 20:28:38MrJean1setfiles: + Issue5956.jpg

messages: + msg87706
2009-05-13 20:14:26MrJean1setmessages: + msg87705
2009-05-13 17:47:33amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg87697
2009-05-07 17:13:15MrJean1create