Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Source build with python 3.13.0 fails; 3.9.17 works #1846

Closed
faisalmemon opened this issue Feb 8, 2025 · 3 comments
Closed

[BUG] Source build with python 3.13.0 fails; 3.9.17 works #1846

faisalmemon opened this issue Feb 8, 2025 · 3 comments

Comments

@faisalmemon
Copy link

https://ml-explore.github.io/mlx/build/html/install.html
says the pre-requisites for python are:
"Using a native Python >= 3.9"
but actually when performing the editable install
CMAKE_BUILD_PARALLEL_LEVEL=8 pip install -e ".[dev]"
you get an install failure at the end if your python is newer than 3.9.x, such as 3.13.0.

      [100%] Linking CXX shared module /tmp/tmpjioegrhn.build-lib/mlx/core.cpython-39-darwin.so
      [100%] Built target core
      Install the project...
      -- Install configuration: "Release"
      Traceback (most recent call last):
        File "/private/tmp/pip-build-env-b3tvd6sc/overlay/lib/python3.13/site-packages/setuptools/command/editable_wheel.py", line 139, in run
          self._create_wheel_file(bdist_wheel)
          ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
        File "/private/tmp/pip-build-env-b3tvd6sc/overlay/lib/python3.13/site-packages/setuptools/command/editable_wheel.py", line 340, in _create_wheel_file
          files, mapping = self._run_build_commands(dist_name, unpacked, lib, tmp)
                           ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/tmp/pip-build-env-b3tvd6sc/overlay/lib/python3.13/site-packages/setuptools/command/editable_wheel.py", line 263, in _run_build_commands
          self._run_build_subcommands()
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
        File "/private/tmp/pip-build-env-b3tvd6sc/overlay/lib/python3.13/site-packages/setuptools/command/editable_wheel.py", line 290, in _run_build_subcommands
          self.run_command(name)
          ~~~~~~~~~~~~~~~~^^^^^^
        File "/private/tmp/pip-build-env-b3tvd6sc/overlay/lib/python3.13/site-packages/setuptools/_distutils/cmd.py", line 339, in run_command
          self.distribution.run_command(command)
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
        File "/private/tmp/pip-build-env-b3tvd6sc/overlay/lib/python3.13/site-packages/setuptools/dist.py", line 999, in run_command
          super().run_command(command)
          ~~~~~~~~~~~~~~~~~~~^^^^^^^^^
        File "/private/tmp/pip-build-env-b3tvd6sc/overlay/lib/python3.13/site-packages/setuptools/_distutils/dist.py", line 1002, in run_command
          cmd_obj.run()
          ~~~~~~~~~~~^^
        File "<string>", line 117, in run
        File "/private/tmp/pip-build-env-b3tvd6sc/overlay/lib/python3.13/site-packages/setuptools/command/build_ext.py", line 102, in run
          self.copy_extensions_to_source()
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
        File "/private/tmp/pip-build-env-b3tvd6sc/overlay/lib/python3.13/site-packages/setuptools/command/build_ext.py", line 123, in copy_extensions_to_source
          self.copy_file(regular_file, inplace_file, level=self.verbose)
          ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/tmp/pip-build-env-b3tvd6sc/overlay/lib/python3.13/site-packages/setuptools/_distutils/cmd.py", line 377, in copy_file
          return file_util.copy_file(
                 ~~~~~~~~~~~~~~~~~~~^
              infile,
              ^^^^^^^
          ...<5 lines>...
              dry_run=self.dry_run,
              ^^^^^^^^^^^^^^^^^^^^^
          )
          ^
        File "/private/tmp/pip-build-env-b3tvd6sc/overlay/lib/python3.13/site-packages/setuptools/_distutils/file_util.py", line 108, in copy_file
          raise DistutilsFileError(
              f"can't copy '{src}': doesn't exist or not a regular file"
          )
      distutils.errors.DistutilsFileError: can't copy '/tmp/tmpjioegrhn.build-lib/mlx/core.cpython-313-darwin.so': doesn't exist or not a regular file
      /private/tmp/pip-build-env-b3tvd6sc/overlay/lib/python3.13/site-packages/setuptools/_distutils/dist.py:1002: _DebuggingTips: Problem in editable installation.
      !!
      

To Reproduce

  1. Install python 3.13.0
  2. CMAKE_BUILD_PARALLEL_LEVEL=8 pip install .
  3. CMAKE_BUILD_PARALLEL_LEVEL=8 pip install -e ".[dev]"

Expected behavior
Editable python install succeeds.

Desktop (please complete the following information):

  • OS Version: 15.1.1 (24B91)
  • Version source code main branch as of 9eb7d73

Additional context

➜  mlx git:(main) ✗ find . -iname "*.so"
./python/mlx/core.cpython-39-darwin.so
./build/lib.macosx-15.1-arm64-cpython-39/mlx/core.cpython-39-darwin.so
./build/lib.macosx-15.1-arm64-cpython-313/mlx/core.cpython-39-darwin.so
@awni
Copy link
Member

awni commented Feb 8, 2025

I'm not sure what's going on there but it builds fine for me with Python 3.13 (and any Python version).

For some reason part of the build thinks you are using Python 3.9 while the other thinks you are using 3.13 and the mismatch is causing issues. It suggests something is off in your environment.

My recommendation would be to make a fresh miniconda environment for whichever Python version you are using and install it there.

@faisalmemon
Copy link
Author

Thanks for the information. I wasn't using miniconda. But switching to that makes it work! Here were my steps based off a zsh environment with brew package manager installed:

  1. cd mlx
  2. rm -rf *
  3. git checkout -- .
  4. brew install --cask miniconda
  5. conda init "$(basename "${SHELL}")"
  6. source ~/.zshrc
  7. conda create --name myenv python=3.13.0
  8. conda activate myenv
  9. pip install --upgrade pip
  10. CMAKE_BUILD_PARALLEL_LEVEL=8 pip install ".[dev]"
  11. CMAKE_BUILD_PARALLEL_LEVEL=8 pip install -e ".[dev]"

@faisalmemon
Copy link
Author

I can raise a PR to supplement the Troubleshooting section with guidance on using miniconda if it cannot perform the editable install. I hope that helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants