Issue 2200: find_executable fails to find .bat files on win32 (original) (raw)

Issue2200

Created on 2008-02-28 13:52 by abbot, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
spawn.patch abbot,2008-03-02 15:29
spawn.patch.txt techtonik,2008-09-03 15:41
Messages (18)
msg63092 - (view) Author: Lev Shamardin (abbot) Date: 2008-02-28 13:52
distutils.spawn.find_executable appends '.exe' suffix on win32 and os2 platforms. This is incorrect behavior, since it prevents finding .bat, .cmd and other similar files. Ether all extensions from the %PATHEXT% must be checked or filenames both with appended suffix and without appending suffix must be checked.
msg63164 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2008-03-01 16:06
Can you provide a patch which uses PATHEXT and falls back to .com, .exe and .bat?
msg63180 - (view) Author: Lev Shamardin (abbot) Date: 2008-03-02 15:29
Here is my vision of this patch. I don't think that it is necessary to fall back to 'com/exe/bat' if PATHEXT is not set, since it must be set on any correctly configured Win32 platform.
msg63213 - (view) Author: Lev Shamardin (abbot) Date: 2008-03-03 15:12
I can't see this issue on the 'open issues' list nor in the search results. Is something wrong?
msg63216 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2008-03-03 16:57
By default issues are sorted by priority. I've given the bug the priority "normal". Have a look on page 3 or 4.
msg72388 - (view) Author: anatoly techtonik (techtonik) Date: 2008-09-03 15:40
I've run into the same problem. Attached patch (updated with Lev code) is almost the same except that it doesn't attempt to return executable files without executable extension. It also accounts that os2 executables can have arbitrary extensions according to Perl manual. http://www.perl.com/doc/manual/html/Porting/README.os2.html#Starting_OS_2_and_DOS_programs
msg116980 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-09-20 21:33
I think distutils changes should be aimed at several versions, please correct them if I'm wrong.
msg117003 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-09-20 23:31
distutils bugs follow standard Python rules: They are fixed in stable and development branches, now 2.7, 3.1 and py3k. If there is a security hazard, the fix would go into 2.6 and possibly 2.5 too. distutils2 has to work with 2.4-2.7 and (soon) 3.1-3.2, so Tarek told me to set all available versions for those bugs (2.5-py3k), even if I think “3rd party” is more appropriate and useful (since a distutils2 bug would not for example block a CPython 3.2 release). When a bug applies to distutils and distutils2, I prefer to set only versions relevant for distutils. distutils2 has only one branch which is tested with all supported Python version, and I actually consider distutils2 a version of distutils: It makes more sense to me to think “this bug exists in CPython 3.1, 3.2 and distutils2”.
msg117004 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-09-20 23:34
Could someone provide use cases for this change? What programs which were not .exe did you need to run though distutils?
msg117033 - (view) Author: Lev Shamardin (abbot) Date: 2010-09-21 06:56
My use case was compiling PyQt4 resources and Qt Designer .ui files from setup script using pyrcc4 and pyuic4 commands. On windows pyrcc4 is actually a pyrcc4.bat file (at least it was at the time of the original bug submission - haven't checked current status), and find_exe could not find it.
msg117037 - (view) Author: anatoly techtonik (techtonik) Date: 2010-09-21 08:56
I believe I had problems with SCons and other .py scripts that are installed as executable .bat files on Windows.
msg117038 - (view) Author: anatoly techtonik (techtonik) Date: 2010-09-21 08:56
Another use case for .bat files is adddin extra params for executable files.
msg117043 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-09-21 10:32
Thanks for the use cases. I agree this is a bug, not a feature, so unless Tarek disagrees I will commit the last patch. I'm not sure this requires tests.
msg128504 - (view) Author: Alexis Metaireau (alexis) * (Python triager) Date: 2011-02-13 15:06
Have the patch been applied ? (the state is still open since last message)
msg128512 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-02-13 15:44
Not yet.
msg131528 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-03-20 19:12
Martin, could you please review patch ?
msg131532 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2011-03-20 20:04
I think the patch is incorrect. Parsing PATHEXT means that it will believe that all extensions listed on PATHEXT are executable. However, os.spawnv is not able to run them all, but only a subset. IIUC, spawnv supports (from spawnve.c) static _TSCHAR *ext_strings[] = { _T(".cmd"), _T(".bat"), _T(".exe"), _T(".com") }; PATHEXT typically includes also .js and other extensions which cannot be run through spawnv.
msg386395 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-02-03 18:26
Distutils is now deprecated (see PEP 632) and all tagged issues are being closed. From now until removal, only release blocking issues will be considered for distutils. If this issue does not relate to distutils, please remove the component and reopen it. If you believe it still requires a fix, most likely the issue should be re-reported at https://github.com/pypa/setuptools
History
Date User Action Args
2022-04-11 14:56:31 admin set github: 46453
2021-02-03 18:26:37 steve.dower set status: open -> closednosy: + steve.dowermessages: + resolution: accepted -> out of datestage: patch review -> resolved
2014-08-10 19:54:28 BreamoreBoy set nosy: + dstufftcomponents: - Distutils2versions: + Python 3.4, Python 3.5, - 3rd party, Python 3.1, Python 3.2, Python 3.3
2014-02-03 19:17:10 BreamoreBoy set nosy: - BreamoreBoy
2011-03-20 20:04:18 loewis set nosy:loewis, techtonik, christian.heimes, tarek, abbot, eric.araujo, alexis, BreamoreBoymessages: +
2011-03-20 19:12:17 eric.araujo set nosy: + loewismessages: + versions: + Python 3.3
2011-02-13 15:44:42 eric.araujo set nosy:techtonik, christian.heimes, tarek, abbot, eric.araujo, alexis, BreamoreBoymessages: +
2011-02-13 15:06:19 alexis set nosy: + alexismessages: +
2010-09-29 23:46:55 eric.araujo set versions: + 3rd party
2010-09-21 10:32:33 eric.araujo set assignee: tarek -> eric.araujoresolution: acceptedmessages: + stage: patch review
2010-09-21 08:56:53 techtonik set messages: +
2010-09-21 08:56:09 techtonik set messages: +
2010-09-21 06:56:41 abbot set messages: +
2010-09-20 23:34:18 eric.araujo set messages: +
2010-09-20 23:31:33 eric.araujo set nosy:techtonik, christian.heimes, tarek, abbot, eric.araujo, BreamoreBoymessages: + components: + Distutils2versions: - Python 2.6, Python 2.5
2010-09-20 21:33:31 BreamoreBoy set nosy: + BreamoreBoy, eric.araujomessages: + versions: + Python 2.6, Python 2.5, Python 3.1, Python 3.2
2010-08-03 18:56:42 terry.reedy set versions: - Python 2.6, Python 2.5, Python 3.0
2009-02-28 17:45:15 akitada set nosy: + tarekcomponents: + Windowsassignee: tarek
2008-09-03 15:41:20 techtonik set files: + spawn.patch.txt
2008-09-03 15:41:10 techtonik set files: - spawn.patch.txt
2008-09-03 15:40:08 techtonik set files: + spawn.patch.txtnosy: + techtonikmessages: + versions: + Python 2.6, Python 3.0, Python 2.7
2008-03-03 16:57:38 christian.heimes set messages: +
2008-03-03 15:12:56 abbot set messages: +
2008-03-02 15:29:32 abbot set files: + spawn.patchkeywords: + patchmessages: +
2008-03-01 16:06:17 christian.heimes set priority: normalnosy: + christian.heimesmessages: +
2008-02-28 13:52:12 abbot create