AllenInstitute/ipfx

pip install ipfx fails on macOS with M1 arm64 cpu (apple silicon)

Closed this issue · 1 comments

Hi all, I am trying to install ipfx on an m1 macOS (apple silicon) and the install fails.

My goal is to install ipfx so I can interoperate with ipfx from my desktop GUI called SanPy. Just had a poster at SFN and some Allen folks stopped by. Would be great if I could start using the 100+ features extracted by ipfx for current clamp recordings!

Describe the bug
pip install ipfx fails on macOS with M1 arm64 cpu (apple silicon)

To Reproduce

conda create -y -n tmp-env python=3.9
conda activate tmp-env
pip install ipfx

Expected behavior
Install should succeed

Actual Behavior
See pip install generated error pasted below

Environment (please complete the following information):

  • OS & version: macOS Ventura 13.3.1
  • Python version 3.9 or 3.11
  • AllenSDK version ???

Here is the output of pip install ipfx

(tmp-39) cudmore SanPy:pip install ipfx
Collecting ipfx
  Using cached IPFX-1.0.8-py2.py3-none-any.whl.metadata (2.9 kB)
Collecting argschema<2.0.0 (from ipfx)
  Using cached argschema-1.17.5-py2.py3-none-any.whl (18 kB)
Collecting allensdk (from ipfx)
  Using cached allensdk-2.16.1-py3-none-any.whl.metadata (1.9 kB)
Collecting dictdiffer (from ipfx)
  Using cached dictdiffer-0.9.0-py2.py3-none-any.whl (16 kB)
Collecting h5py==2.10.0 (from ipfx)
  Using cached h5py-2.10.0.tar.gz (301 kB)
  Preparing metadata (setup.py) ... done
Collecting marshmallow==3.0.0rc6 (from ipfx)
  Using cached marshmallow-3.0.0rc6-py2.py3-none-any.whl (42 kB)
Collecting matplotlib>=1.4.3 (from ipfx)
  Using cached matplotlib-3.8.1-cp39-cp39-macosx_10_12_x86_64.whl.metadata (5.8 kB)
Collecting methodtools (from ipfx)
  Using cached methodtools-0.4.7.tar.gz (3.6 kB)
  Preparing metadata (setup.py) ... done
Collecting numpy<1.19.0,>=1.15.4 (from ipfx)
  Using cached numpy-1.18.5.zip (5.4 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [54 lines of output]
      Running from numpy source directory.
      <string>:461: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates
      /private/var/folders/76/6bdl7smj72g6tynz3985xxl40000gn/T/pip-install-k7g2wjc9/numpy_5a72b93d57d1405f95b6ad19d0e1f1a5/tools/cythonize.py:75: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
        required_version = LooseVersion('0.29.14')
      /private/var/folders/76/6bdl7smj72g6tynz3985xxl40000gn/T/pip-install-k7g2wjc9/numpy_5a72b93d57d1405f95b6ad19d0e1f1a5/tools/cythonize.py:77: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
        if LooseVersion(cython_version) < required_version:
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
                  self.rng_state.ctr.v[i] = counter[i]
      
              self._reset_state_variables()
      
              self._bitgen.state = <void *>&self.rng_state
              self._bitgen.next_uint64 = &philox_uint64
                                         ^
      ------------------------------------------------------------
      
      _philox.pyx:195:35: Cannot assign type 'uint64_t (*)(void *) except? -1 nogil' to 'uint64_t (*)(void *) noexcept nogil'. Exception values are incompatible. Suggest adding 'noexcept' to type 'uint64_t (void *) except? -1 nogil'.
      Processing numpy/random/_bounded_integers.pxd.in
      Processing numpy/random/_philox.pyx
      Traceback (most recent call last):
        File "/private/var/folders/76/6bdl7smj72g6tynz3985xxl40000gn/T/pip-install-k7g2wjc9/numpy_5a72b93d57d1405f95b6ad19d0e1f1a5/tools/cythonize.py", line 238, in <module>
          main()
        File "/private/var/folders/76/6bdl7smj72g6tynz3985xxl40000gn/T/pip-install-k7g2wjc9/numpy_5a72b93d57d1405f95b6ad19d0e1f1a5/tools/cythonize.py", line 234, in main
          find_process_files(root_dir)
        File "/private/var/folders/76/6bdl7smj72g6tynz3985xxl40000gn/T/pip-install-k7g2wjc9/numpy_5a72b93d57d1405f95b6ad19d0e1f1a5/tools/cythonize.py", line 225, in find_process_files
          process(root_dir, fromfile, tofile, function, hash_db)
        File "/private/var/folders/76/6bdl7smj72g6tynz3985xxl40000gn/T/pip-install-k7g2wjc9/numpy_5a72b93d57d1405f95b6ad19d0e1f1a5/tools/cythonize.py", line 191, in process
          processor_function(fromfile, tofile)
        File "/private/var/folders/76/6bdl7smj72g6tynz3985xxl40000gn/T/pip-install-k7g2wjc9/numpy_5a72b93d57d1405f95b6ad19d0e1f1a5/tools/cythonize.py", line 80, in process_pyx
          subprocess.check_call(
        File "/Users/cudmore/opt/miniconda3/envs/tmp-39/lib/python3.9/subprocess.py", line 373, in check_call
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command '['/Users/cudmore/opt/miniconda3/envs/tmp-39/bin/python', '-m', 'cython', '-3', '--fast-fail', '-o', '_philox.c', '_philox.pyx']' returned non-zero exit status 1.
      Cythonizing sources
      Traceback (most recent call last):
        File "/Users/cudmore/opt/miniconda3/envs/tmp-39/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/Users/cudmore/opt/miniconda3/envs/tmp-39/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/Users/cudmore/opt/miniconda3/envs/tmp-39/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 149, in prepare_metadata_for_build_wheel
          return hook(metadata_directory, config_settings)
        File "/private/var/folders/76/6bdl7smj72g6tynz3985xxl40000gn/T/pip-build-env-tzjpnn2_/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 396, in prepare_metadata_for_build_wheel
          self.run_setup()
        File "/private/var/folders/76/6bdl7smj72g6tynz3985xxl40000gn/T/pip-build-env-tzjpnn2_/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 507, in run_setup
          super(_BuildMetaLegacyBackend, self).run_setup(setup_script=setup_script)
        File "/private/var/folders/76/6bdl7smj72g6tynz3985xxl40000gn/T/pip-build-env-tzjpnn2_/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 341, in run_setup
          exec(code, locals())
        File "<string>", line 488, in <module>
        File "<string>", line 469, in setup_package
        File "<string>", line 275, in generate_cython
      RuntimeError: Running cythonize failed!
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
(tmp-39) cudmore SanPy:

I did get it working by rolling back to Python 3.7 and NumPy 1.18.5.

Note, it is important to install NumPy with conda versus pip as conda has more pre-built C code over pip, reducing the need to compile (I think?).

create -y -n tmp-env python=3.7
conda activate tmp-env

conda install numpy=1.18.5

pip install ipfx

Edit: Thanks @sheriferson for working on bringing ipfx up to date with newer Python versions.