Skip to content

Windows build fails with error C2039 in deepfreeze.c #94781

Closed

Description

@pfmoore

Bug report

Building CPython on windows fails with the following error:

❯ .\build.bat
Using py -3.10 (found 3.10 with py.exe)
Fetching external libraries...
bzip2-1.0.8 already exists, skipping.
sqlite-3.38.4.0 already exists, skipping.
xz-5.2.5 already exists, skipping.
zlib-1.2.12 already exists, skipping.
Fetching external binaries...
libffi-3.4.2 already exists, skipping.
openssl-bin-1.1.1n already exists, skipping.
tcltk-8.6.12.1 already exists, skipping.
Finished.
Using "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\msbuild.exe" (found in the Visual Studio installation)
Using py -3.10 (found 3.10 with py.exe)

C:\Work\Projects\cpython\PCbuild>"C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\msbuild.exe" "C:\Work\Projects\cpython\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:\Users\Gustav\scoop\shims\git.exe"
  _freeze_module.vcxproj -> C:\Work\Projects\cpython\PCbuild\win32\_freeze_module.exe
  Killing any running python.exe instances...
  Generated sources are up to date
  Getting build info from C:\Users\Gustav\scoop\shims\git.exe
  Building heads/main:cfafd3adf8 main
  deepfreeze.c
C:\Work\Projects\cpython\Python\deepfreeze\deepfreeze.c(48335,14): error C2039: '_zipimporter': is not a member of '<un
named-tag>' [C:\Work\Projects\cpython\PCbuild\pythoncore.vcxproj]
C:\Work\Projects\cpython\Include\internal\pycore_global_strings.h(54): message : see declaration of '<unnamed-tag>' [C:
\Work\Projects\cpython\PCbuild\pythoncore.vcxproj]
C:\Work\Projects\cpython\Python\deepfreeze\deepfreeze.c(48436,17): error C2039: '_zipimporter': is not a member of '<un
named-tag>' [C:\Work\Projects\cpython\PCbuild\pythoncore.vcxproj]
C:\Work\Projects\cpython\Include\internal\pycore_global_strings.h(54): message : see declaration of '<unnamed-tag>' [C:
\Work\Projects\cpython\PCbuild\pythoncore.vcxproj]
C:\Work\Projects\cpython\Python\deepfreeze\deepfreeze.c(48437,21): error C2039: '_zipimporter': is not a member of '<un
named-tag>' [C:\Work\Projects\cpython\PCbuild\pythoncore.vcxproj]
C:\Work\Projects\cpython\Include\internal\pycore_global_strings.h(54): message : see declaration of '<unnamed-tag>' [C:
\Work\Projects\cpython\PCbuild\pythoncore.vcxproj]
C:\Work\Projects\cpython\Python\deepfreeze\deepfreeze.c(52201,14): error C2039: '_zipimporter': is not a member of '<un
named-tag>' [C:\Work\Projects\cpython\PCbuild\pythoncore.vcxproj]
C:\Work\Projects\cpython\Include\internal\pycore_global_strings.h(54): message : see declaration of '<unnamed-tag>' [C:
\Work\Projects\cpython\PCbuild\pythoncore.vcxproj]
C:\Work\Projects\cpython\Python\deepfreeze\deepfreeze.c(52297,14): error C2039: '_zipimporter': is not a member of '<un
named-tag>' [C:\Work\Projects\cpython\PCbuild\pythoncore.vcxproj]
C:\Work\Projects\cpython\Include\internal\pycore_global_strings.h(54): message : see declaration of '<unnamed-tag>' [C:
\Work\Projects\cpython\PCbuild\pythoncore.vcxproj]

Build FAILED.

C:\Work\Projects\cpython\Python\deepfreeze\deepfreeze.c(48335,14): error C2039: '_zipimporter': is not a member of '<un
named-tag>' [C:\Work\Projects\cpython\PCbuild\pythoncore.vcxproj]
C:\Work\Projects\cpython\Python\deepfreeze\deepfreeze.c(48436,17): error C2039: '_zipimporter': is not a member of '<un
named-tag>' [C:\Work\Projects\cpython\PCbuild\pythoncore.vcxproj]
C:\Work\Projects\cpython\Python\deepfreeze\deepfreeze.c(48437,21): error C2039: '_zipimporter': is not a member of '<un
named-tag>' [C:\Work\Projects\cpython\PCbuild\pythoncore.vcxproj]
C:\Work\Projects\cpython\Python\deepfreeze\deepfreeze.c(52201,14): error C2039: '_zipimporter': is not a member of '<un
named-tag>' [C:\Work\Projects\cpython\PCbuild\pythoncore.vcxproj]
C:\Work\Projects\cpython\Python\deepfreeze\deepfreeze.c(52297,14): error C2039: '_zipimporter': is not a member of '<un
named-tag>' [C:\Work\Projects\cpython\PCbuild\pythoncore.vcxproj]
    0 Warning(s)
    5 Error(s)

Time Elapsed 00:00:07.59

This is from a clean checkout of https://github.com/python/cpython, changing directory to PCBuild and running ./build.bat

Your environment

My system is Windows 11, with Visual Studio 2022 and Visual Studio 2019 installed. As can be seen from the messages, VS2022 is picked by build.bat.

  • CPython versions tested on: main branch commit cfafd3a
  • Operating system and architecture: Windows 11, 64-bit

Activity

  1. changed the title [-]Windows build fails with[/-] [+]Windows build fails with error C2039 in deepfreeze.c[/+] on Jul 12, 2022
  2. arhadthedev commented on Jul 12, 2022

    @arhadthedev
    Member

    Does the problem disappear after deletion of Python\deepfreeze\* and Python\frozen_modules\* with the following rebuilding?

    I get the very same problem after git pull/checkout and the deletion helps. Probably, git fails to update file modification dates?

  3. pfmoore commented on Jul 12, 2022

    @pfmoore
    MemberAuthor

    That seems to have fixed it, thanks. I'm pretty sure I did at least one of those deletions, deleting both directories seems to have been the key.

    Maybe PCBuild\clean.bat should delete those files? I'd tried that expecting it to reset everything, and was surprised when it didn't work.

  4. Fidget-Spinner commented on Jul 12, 2022

    @Fidget-Spinner
    Member

    @kumaraditya303 git clean -fdX as a workaround and that worked for me. However, I agree that clean.bat should do something about those files.

  5. zware commented on Aug 31, 2022

    @zware
    Member

    Rather than adding cleanup logic to clean.bat directly, can the Clean target of the project file that creates the files in question be taught how to clean them up? clean.bat is itself intentionally very bare-bones.

  6. CharlieZhao95 commented on Aug 31, 2022

    @CharlieZhao95
    Contributor

    Rather than adding cleanup logic to clean.bat directly, can the Clean target of the project file that creates the files in question be taught how to clean them up? clean.bat is itself intentionally very bare-bones.

    The build still fails after executing the clean.bat which is unexpected result, and the reason for the failure is indeed that some files were not deleted correctly.

    For users, executing clean.bat first and then build successfully is probably the simplest and best result.

    It's good advice to provide a more detailed build guide to teach users how to cleanup previous files and solve these potential problems, and I feel like it should. Also, it doesn't seem like adding logic to clean.bat will negatively affect the build process either. Maybe we coud do both.

  7. zware commented on Aug 31, 2022

    @zware
    Member

    My point is that clean.bat itself is the wrong place to add cleanup logic. I agree that the act of calling clean.bat should be sufficient to allow a successful build, but the place to make that happen is in the cleanup steps of the project files that generate the problematic files which clean.bat invokes.

  8. CharlieZhao95 commented on Sep 1, 2022

    @CharlieZhao95
    Contributor

    Thanks for your detailed reply. I may have misinterpreted your previous message.
    I will learn about the clean target in MSbuild later :)

  9. CharlieZhao95 commented on Sep 7, 2022

    @CharlieZhao95
    Contributor

    #96423 I modified the Clean target in pcbuild.proj, and now the files in the Python\deepfreeze and Python\frozen_modules directories can be removed correctly by executing clean.bat.

    I'm not sure if this is the best solution, please correct me if I'm wrong :)

  10. added a commit that references this issue on Sep 7, 2022
  11. added a commit that references this issue on Sep 7, 2022
  12. zooba commented on Sep 7, 2022

    @zooba
    Member

    I think this solution is great, and thanks for working it into the proper places in the build.

    Do we need a backport of this? If so, is it needed in 3.10? (I think the frozen modules were only added in 3.11, right?) Either way, I wouldn't want to put it into 3.11.0 at this late stage, so it can wait until 3.11.1.

  13. added a commit that references this issue on Sep 23, 2022
  14. kumaraditya303 commented on Sep 30, 2022

    @kumaraditya303
    Contributor

    Fixed by #96423

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-windowstype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions