Skip to content

ModuleNotFoundError: No module named 'distutils.msvccompiler' in package build CI #2971

Closed

Description

@hoodmane

🐛 Bug

Several different packages have failed with ModuleNotFoundError: No module named 'distutils.msvccompiler'. See for instance:
https://app.circleci.com/pipelines/github/hoodmane/pyodide/3667/workflows/dd548c6b-f1c8-40d3-88f5-e71573bf4934/jobs/43716

@ryanking13 any ideas? Maybe we need to pin something?

Activity

  1. added
    bug
    on Aug 15, 2022
  2. ryanking13 commented on Aug 15, 2022

    @ryanking13
    Member

    I think we need to pin the setuptools version. Setuptools embeds distutils in its source code and it seems like they removed some of msvc modules recently:

    pypa/setuptools#3505

  3. aminvakil commented on Aug 15, 2022

    @aminvakil

    FYI I also faced this issue and the problem with pinning setuptools is that some packages try to upgrade setuptools in their build process anyway:

    Step 9/10 : RUN pip install --ignore-installed implicit==0.4.8 -v
     ---> Running in 8ed28a7f9227
    Using pip 22.2.2 from /usr/local/lib/python3.8/site-packages/pip (python 3.8)
    Collecting implicit==0.4.8
      Downloading implicit-0.4.8.tar.gz (1.1 MB)
         ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.1/1.1 MB 1.4 MB/s eta 0:00:00
      Installing build dependencies: started
      Running command pip subprocess to install build dependencies
      Collecting setuptools>=40.8.0
        Downloading setuptools-65.0.0-py3-none-any.whl (1.2 MB)
           ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 1.4 MB/s eta 0:00:00
      Collecting wheel
        Downloading wheel-0.37.1-py2.py3-none-any.whl (35 kB)
      Installing collected packages: wheel, setuptools
      Successfully installed setuptools-65.0.0 wheel-0.37.1
      WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
      Installing build dependencies: finished with status 'done'
      Getting requirements to build wheel: started
      Running command Getting requirements to build wheel
      Traceback (most recent call last):
        File "/usr/local/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
          main()
        File "/usr/local/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/usr/local/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 130, in get_requires_for_build_wheel
          return hook(config_settings)
        File "/tmp/pip-build-env-_9pio9o2/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 337, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
        File "/tmp/pip-build-env-_9pio9o2/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 319, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-_9pio9o2/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 474, in run_setup
          super(_BuildMetaLegacyBackend,
        File "/tmp/pip-build-env-_9pio9o2/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 334, in run_setup
          exec(code, locals())
        File "<string>", line 10, in <module>
        File "/tmp/pip-install-uil7rlsk/implicit_d921eed9601c457fbaa43fc4ffadd90c/cuda_setup.py", line 6, in <module>
          from distutils import ccompiler, errors, msvccompiler, unixccompiler
      ImportError: cannot import name 'msvccompiler' from 'distutils' (/tmp/pip-build-env-_9pio9o2/overlay/lib/python3.8/site-packages/setuptools/_distutils/__init__.py)
      error: subprocess-exited-with-error
      
      × Getting requirements to build wheel did not run successfully.
      │ exit code: 1
      ╰─> See above for output.
      
      note: This error originates from a subprocess, and is likely not a problem with pip.
      full command: /usr/local/bin/python /usr/local/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py get_requires_for_build_wheel /tmp/tmpvhe7pez9
      cwd: /tmp/pip-install-uil7rlsk/implicit_d921eed9601c457fbaa43fc4ffadd90c
      Getting requirements to build wheel: finished with status 'error'
    error: subprocess-exited-with-error
    
    × Getting requirements to build wheel did not run successfully.
    │ exit code: 1
    ╰─> See above for output.
    
    note: This error originates from a subprocess, and is likely not a problem with pip.
    The command '/bin/sh -c pip install --ignore-installed implicit==0.4.8 -v' returned a non-zero code: 1
    

    I changed my installation to add --no-build-isolation to pip install to overcome this issue, not sure if we'll face any issue later.
    pip install implicit==0.4.8 --no-build-isolation

  4. rth commented on Aug 15, 2022

    @rth
    Member

    Yes, because most projects specify setuptools without pinning it in pyproject.toml

  5. tiran commented on Aug 16, 2022

    @tiran

    I have created a more general issue for the setuptools problem, pypa/setuptools#3532.

  6. nirpodoleanu commented on Aug 16, 2022

    @nirpodoleanu

    +1

  7. rgommers commented on Aug 19, 2022

    @rgommers
    Contributor

    I think we need to pin the setuptools version.

    All users of numpy.distutils should be pinning setuptools, see numpy/numpy#22135 (comment). If they don't and it's a problem for Pyodide, you could indeed consider adding the pin yourself.

  8. tiran commented on Aug 19, 2022

    @tiran

    Pinning setuptools introduces other issues, e.g. for downstream distributions like Pyodide, Debian, or Fedora. These distributions usually support only one version of a package. Some projects require more recent versions, e.g. setuptools-rust >= 1.4 for pyO3 requires requires setuptools >= 62.4.

  9. rgommers commented on Aug 19, 2022

    @rgommers
    Contributor

    There must be ways around that. We've been pinning setuptools in SciPy for a while, and no Linux packager complained. Also, we often require the very latest Cython bug fix release, and that is no problem. In general, if you support only one version of build-time dependencies, you are forcing upgrades of all packages in sync every time there is any breaking change.

    Is Pyodide really not able to use two different versions of a pure Python package at build time? (distribution only one version at runtime is a separate matter, and not a problem here)

  10. hoodmane commented on Aug 19, 2022

    @hoodmane
    MemberAuthor

    Is Pyodide really not able to use two different versions of a pure Python package at build time?

    We can do that yes. We use pypabuild with build isolation. I think we may need to add some extra logic that inserts a version upper bound if it's consistent. Something like in pseudo code:

    setuptools_json = fetch_json("pypi.org/setuptools/json")
    setuptools_vers = get_versions(setuptools_json)
    
    lt_65_vers = [v for v in setuptools_vers if v in setuptools_constrait and v.major<65]
    if less_than_65_vers:
       setuptools_constraint = "setuptools=="+max(less_than_65_vers)
  11. henryiii commented on Aug 24, 2022

    @henryiii
    Contributor

    FYI, 65.0.2 restored these removed modules.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions