classification
Title: Fresh build on Windows fails the first time for zlib.c
Type: Stage:
Components: Build, Windows Versions: Python 3.11
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: DiddiLeija, eryksun, gvanrossum, paul.moore, steve.dower, tim.golden, zach.ware
Priority: normal Keywords: easy

Created on 2021-08-31 01:44 by gvanrossum, last changed 2021-09-02 16:10 by steve.dower.

Messages (5)
msg400680 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2021-08-31 01:44
When I make a fresh checkout of the main branch on Windows and type "pcbuild\build" it starts downloading some distributions (e.g. sqlite) and then starts building. Fine. But at some point there's a whole bunch of errors that seem to come from building zlibmodule.c. Re-running pcbuild\build then downloads some extra thing and then everything builds to completion.

First set of downloads and selected logs:

Using py -3.9 (found 3.9 with py.exe)
Fetching external libraries...
Fetching bzip2-1.0.6...       
Fetching sqlite-3.35.5.0...
Fetching xz-5.2.2...
Fetching zlib-1.2.11...
Traceback (most recent call last):
  File "C:\Users\gvanrossum\deepfreeze\PCbuild\get_external.py", line 60, in <module>
    main()
  File "C:\Users\gvanrossum\deepfreeze\PCbuild\get_external.py", line 56, in main
    extract_zip(args.externals_dir, zip_path).replace(final_name)
  File "C:\Users\gvanrossum\AppData\Local\Programs\Python\Python39\lib\pathlib.py", line 1395, in 
replace
    self._accessor.replace(self, target)
PermissionError: [WinError 5] Access is denied: 'C:\\Users\\gvanrossum\\deepfreeze\\PCbuild\\..\\externals\\cpython-source-deps-zlib-1.2.11' -> 'C:\\Users\\gvanrossum\\deepfreeze\\PCbuild\\..\\externals\\zlib-1.2.11'
Fetching external binaries...
Fetching libffi-3.3.0...
Fetching openssl-bin-1.1.1l...
Fetching tcltk-8.6.11.0...
Finished.
Using "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe" (found in the Visual Studio installation)
Using py -3.9 (found 3.9 with py.exe)

C:\Users\gvanrossum\deepfreeze>"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe" "C:\Users\gvanrossum\deepfreeze\PCbuild\pcbuild.proj" /t:Build /m /nologo /v:m /clp:summary /p:Configuration=Release /p:Platform=x64 /p:IncludeExternals=true /p:IncludeCTypes=true /p:IncludeSSL=true /p:IncludeTkinter=true /p:UseTestMarker= /p:GIT="C:\Program Files\Git\cmd\git.exe"
  Killing any running python.exe instances...
  Regenerate pycore_ast.h pycore_ast_state.h Python-ast.c
  C:\Users\gvanrossum\deepfreeze\Python\Python-ast.c, C:\Users\gvanrossum\deepfreeze\Include\inte
  rnal\pycore_ast.h, C:\Users\gvanrossum\deepfreeze\Include\internal\pycore_ast_state.h regenerat
  ed.
  Regenerate opcode.h opcode_targets.h
  Include\opcode.h regenerated from Lib\opcode.py
  Jump table written into Python\opcode_targets.h
  Regenerate token-list.inc token.h token.c token.py
  Generated sources are up to date
  Getting build info from "C:\Program Files\Git\cmd\git.exe"
  Building heads/deepfreeze:044e8d866f deepfreeze
  _abc.c

...

Errors:

  Compiling...
  thread.c
  traceback.c
  zlibmodule.c
C:\Users\gvanrossum\deepfreeze\Modules\zlibmodule.c(10,10): fatal error C1083: Cannot open includ
e file: 'zlib.h': No such file or directory [C:\Users\gvanrossum\deepfreeze\PCbuild\pythoncore.vc
xproj]
  adler32.c
c1 : fatal error C1083: Cannot open source file: 'C:\Users\gvanrossum\deepfreeze\externals\zlib-1 
.2.11\adler32.c': No such file or directory [C:\Users\gvanrossum\deepfreeze\PCbuild\pythoncore.vc 
xproj]
  compress.c
c1 : fatal error C1083: Cannot open source file: 'C:\Users\gvanrossum\deepfreeze\externals\zlib-1
.2.11\compress.c': No such file or directory [C:\Users\gvanrossum\deepfreeze\PCbuild\pythoncore.v
cxproj]
  crc32.c
c1 : fatal error C1083: Cannot open source file: 'C:\Users\gvanrossum\deepfreeze\externals\zlib-1
.2.11\crc32.c': No such file or directory [C:\Users\gvanrossum\deepfreeze\PCbuild\pythoncore.vcxp 
roj]
  deflate.c
c1 : fatal error C1083: Cannot open source file: 'C:\Users\gvanrossum\deepfreeze\externals\zlib-1
.2.11\deflate.c': No such file or directory [C:\Users\gvanrossum\deepfreeze\PCbuild\pythoncore.vc 
xproj]
  infback.c
c1 : fatal error C1083: Cannot open source file: 'C:\Users\gvanrossum\deepfreeze\externals\zlib-1
.2.11\infback.c': No such file or directory [C:\Users\gvanrossum\deepfreeze\PCbuild\pythoncore.vc 
xproj]
  inffast.c
c1 : fatal error C1083: Cannot open source file: 'C:\Users\gvanrossum\deepfreeze\externals\zlib-1
.2.11\inffast.c': No such file or directory [C:\Users\gvanrossum\deepfreeze\PCbuild\pythoncore.vc 
xproj]
  inflate.c
c1 : fatal error C1083: Cannot open source file: 'C:\Users\gvanrossum\deepfreeze\externals\zlib-1
.2.11\inflate.c': No such file or directory [C:\Users\gvanrossum\deepfreeze\PCbuild\pythoncore.vc 
xproj]
  inftrees.c
c1 : fatal error C1083: Cannot open source file: 'C:\Users\gvanrossum\deepfreeze\externals\zlib-1
.2.11\inftrees.c': No such file or directory [C:\Users\gvanrossum\deepfreeze\PCbuild\pythoncore.v 
cxproj]
  trees.c
c1 : fatal error C1083: Cannot open source file: 'C:\Users\gvanrossum\deepfreeze\externals\zlib-1
.2.11\trees.c': No such file or directory [C:\Users\gvanrossum\deepfreeze\PCbuild\pythoncore.vcxp 
roj]
  uncompr.c
c1 : fatal error C1083: Cannot open source file: 'C:\Users\gvanrossum\deepfreeze\externals\zlib-1
.2.11\uncompr.c': No such file or directory [C:\Users\gvanrossum\deepfreeze\PCbuild\pythoncore.vc 
xproj]
  zutil.c
c1 : fatal error C1083: Cannot open source file: 'C:\Users\gvanrossum\deepfreeze\externals\zlib-1
.2.11\zutil.c': No such file or directory [C:\Users\gvanrossum\deepfreeze\PCbuild\pythoncore.vcxp 
roj]
  dl_nt.c

Build FAILED.

(Followed by the same errors repeated.)

Second build:

Using py -3.9 (found 3.9 with py.exe)
Fetching external libraries...
bzip2-1.0.6 already exists, skipping.
sqlite-3.35.5.0 already exists, skipping.
xz-5.2.2 already exists, skipping.
Fetching zlib-1.2.11...
Fetching external binaries...
libffi-3.3.0 already exists, skipping.
openssl-bin-1.1.1l already exists, skipping.
tcltk-8.6.11.0 already exists, skipping.
Finished.

And then everything builds problem-free.
msg400701 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-08-31 09:25
This looks like a typical "lingering open handle" issue, though I can't tell whether it's in the destination or the source.

Probably just needs a bit of retry logic (personally I'd be fine putting in CPython itself, though that doesn't help this build which is using an already-released version). So get_externals.py needs it.

It's certainly not reliably reproducible or the CI system would be on the floor ;) This runs on every build
msg400727 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2021-08-31 13:04
I can't directly reproduce the problem. Does it reproduce reliably for you? My guess would be that there's a file open in "cpython-source-deps-zlib-1.2.11" when get_external.py tries to rename it to "zlib-1.2.11". Maybe an anti-malware scanner or content indexer has a file open.
msg400770 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2021-08-31 18:55
I've seen it a few times. I don't do this that often, but since I've discovered "git worktree" this has occurred to me a few times (can't recall if it was every time, but today wasn't the first). I'm totally happy to be the human in the retry loop. :-)
msg400935 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-09-02 16:10
I use git worktree as well (it's great for backporting - I have all the release branches checked out all the time), but it likely means that you are regularly downloading and extracting these files.

So whatever app is keeping the file handle open is probably doing it reliably for one of the files, which is why you'll hit it each time. Once it's been copied into place, you won't see it again. And once we have the retry logic in the script then you won't see it the first time either.

This should be an easy project, though not trivial to test.
History
Date User Action Args
2021-09-02 16:10:10steve.dowersetkeywords: + easy

messages: + msg400935
2021-08-31 18:55:09gvanrossumsetmessages: + msg400770
2021-08-31 18:37:57DiddiLeijasetnosy: + DiddiLeija
2021-08-31 13:04:50eryksunsetmessages: + msg400727
2021-08-31 09:25:39steve.dowersetnosy: + eryksun
messages: + msg400701
2021-08-31 01:44:59gvanrossumcreate