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.

Title: bdist_wininst doesn't clean up read-only files in build dir
Type: behavior Stage: resolved
Components: Distutils Versions: Python 3.4, Python 3.5, Python 2.7
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: tarek Nosy List: dstufft, eric.araujo, jaraco, mhammond, tarek, theller, vstinner
Priority: normal Keywords:

Created on 2003-09-20 17:49 by jaraco, last changed 2022-04-10 16:11 by admin. This issue is now closed.

Messages (5)
msg60389 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2003-09-20 17:49
Using Windows XP SP1, Python 2.3, Win32Extensions 
build 159:

I recently added some data_files to my setup script as 

setup( ..., data_files = [ ( 'files', ['file.txt'] ) ] )

and when I ran my setup script with the build 
option 'bdist_wininst', I get the following error at the 
cleanup stage of the build:

removing 'build\bdist.win32\wininst' (and everything 
under it)
error removing build\bdist.win32\wininst: 
build\bdist.win32\wininst\DATA\file.txt: Permission denied

The error is followed by more errors attempting to 
remove the parent directories because they're not 

The reason permission is denied is because the file is 
marked as read-only (via file attributes, not file 
permissions).  The source file is marked as read-only in 
this case because it is being taken from a Visual 
SourceSafe project which uses the RO attribute to 
indicate check-out status.  If I check out the file or 
remove the RO flag, the script runs without errors.

Regardless of the reason for a file being marked RO, the 
temporary files in wininst\DATA should not be copied 
with their RO attribute or when cleaning up, the routine 
should delete the files regardless of RO status.

I'm not sure what is the best way to approach this 
problem, but I will be willing to provide input or even 
code patches.  I need input from the community, 
however, on how to best fix this issue.
msg60390 - (view) Author: Mark Hammond (mhammond) * (Python committer) Date: 2004-07-02 00:46
Logged In: YES 

Do other distutils commands suffer the same problem cleaning
their temp files?  If so, the problem is a little more
delicate (special-casing these attributes on Linux, for
example, would be non-trivial), but if only bdist_win32 has
the problem we could be more brutal (there are very few
attributes we need to worry about!).

The other potential problem is that people may actually want
this r/o attribute to end up on the installed file - which
means the installer and uninstaller need to deal with it too.

So I too am unsure what the "correct" thing to do is.
msg60391 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2004-07-02 19:28
Logged In: YES 

The sdist command, for example, has the same problem - so
it's not bdist_wininst specific.
py2exe's module has a force_remove_tree()
variant of distutils' dir_util.remove_tree() function which
could serve as a possible example how to force removal. 
(This function was contributed by a py2exe-user, but I don't
remember who it was.)

For distutils, the remove_tree() function could grow a
'force' parameter, and that could be used in the cleanup
phase - it should be safe to remove the temporary build tree
we have created, and that wouldn't change the read-only bit
in the installed file(s).
msg227791 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-09-29 10:17
I understand from the experts list that tarek is no longer maintaining distutils but I can't change the "assigned to" field.  As a matter of interest there are another 67 issues with tarek assigned.
msg384815 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-01-11 12:50
The distutils bdist_wininst command has been removed in Python 3.10: see bpo-42802.
Date User Action Args
2022-04-10 16:11:15adminsetgithub: 39262
2021-01-11 12:50:49vstinnersetstatus: open -> closed

nosy: + vstinner
messages: + msg384815

resolution: wont fix
stage: test needed -> resolved
2019-04-26 20:38:32BreamoreBoysetnosy: - BreamoreBoy
2014-09-29 10:17:45BreamoreBoysetnosy: + dstufft, BreamoreBoy

messages: + msg227791
versions: + Python 3.4, Python 3.5, - Python 3.1, Python 3.2
2010-08-18 21:10:27eric.araujosettitle: distutils/bdistwin32 doesn't clean up RO files properly -> bdist_wininst doesn't clean up read-only files in build dir
2010-08-18 19:51:04BreamoreBoysetversions: + Python 3.1, Python 2.7, Python 3.2
2010-07-28 10:07:15eric.araujosetversions: - Python 2.3
nosy: + eric.araujo

assignee: tarek
type: behavior
stage: test needed
2009-02-10 16:47:28akitadasetnosy: + tarek
2003-09-20 17:49:39jaracocreate