acquire-project / acquire-python

Acquire: a multi-camera video streaming software focusing on microscopy
Apache License 2.0
18 stars 9 forks source link

Installation fails on M1 Macs #55

Closed dgmccart closed 1 year ago

dgmccart commented 1 year ago

I am trying to install the acquire-imaging package on my M1 mac, but the installation fails due to a "metadata-generation-failed" error. I started the installation in a clean conda environment with either python 3.9 or 3.11 installed. I also updated wheel and setuptools, but installation still failed. The error is below:

Collecting acquire-imaging
  Using cached acquire_imaging-0.1.3.tar.gz (11.0 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
  ╰─> [6 lines of output]

      Cargo, the Rust package manager, is not installed or is not on PATH.
      This package requires Rust and Cargo to compile extensions. Install it through
      the system's package manager or via https://rustup.rs/

      Checking for Rust toolchain....
      [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.
aliddell commented 1 year ago

OK, this one should hopefully be pretty easy to solve, but seems like we missed a step in the documentation. You'll need to install Rust (instructions are here) but then you should be able to try again.

@nclack is there something we can do to the build script or the pyproject.toml so we don't have to build on install from PyPI?

dgmccart commented 1 year ago

Looks like the rust installation didn't completely fix the issue.

Rust is installed now. Great!

To get started you may need to restart your current shell.
This would reload your PATH environment variable to include
Cargo's bin directory ($HOME/.cargo/bin).

To configure your current shell, run:
source "$HOME/.cargo/env"

(acquire) dmccarthy@czimacos3887 ~ % python -m pip install acquire-imaging
Collecting acquire-imaging
  Using cached acquire_imaging-0.1.3.tar.gz (11.0 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
  ╰─> [6 lines of output]

      Cargo, the Rust package manager, is not installed or is not on PATH.
      This package requires Rust and Cargo to compile extensions. Install it through
      the system's package manager or via https://rustup.rs/

      Checking for Rust toolchain....
      [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.

So I closed terminal and tried to install again:

(base) dmccarthy@czimacos3887 ~ % conda activate acquire
(acquire) dmccarthy@czimacos3887 ~ % python -m pip install acquire-imaging
Collecting acquire-imaging
  Using cached acquire_imaging-0.1.3.tar.gz (11.0 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting numpy>=1.22 (from acquire-imaging)
  Obtaining dependency information for numpy>=1.22 from https://files.pythonhosted.org/packages/48/73/df07644e8fa1127a7985db70cf1d07123004e2dd7a3cf33e8b83297a775b/numpy-1.25.1-cp311-cp311-macosx_11_0_arm64.whl.metadata
  Downloading numpy-1.25.1-cp311-cp311-macosx_11_0_arm64.whl.metadata (5.6 kB)
Downloading numpy-1.25.1-cp311-cp311-macosx_11_0_arm64.whl (14.0 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 14.0/14.0 MB 4.0 MB/s eta 0:00:00
Building wheels for collected packages: acquire-imaging
  Building wheel for acquire-imaging (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for acquire-imaging (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [195 lines of output]
      Running `maturin pep517 build-wheel -i /opt/miniconda3/envs/acquire/bin/python --compatibility off`
      📦 Including license file "/private/var/folders/lp/tnrf4kq9095g1j__47pw9jdm0000gq/T/pip-install-nw1k40hk/acquire-imaging_217e1f6b58f44630b8913a6852cccc55/LICENSE"
      🍹 Building a mixed python/rust project
      🔗 Found pyo3 bindings with abi3 support for Python ≥ 3.8
      🐍 Not using a specific python interpreter
      💻 Using `MACOSX_DEPLOYMENT_TARGET=11.0` for aarch64-apple-darwin by default
         Compiling libc v0.2.144
         Compiling autocfg v1.1.0
         Compiling cfg-if v1.0.0
         Compiling proc-macro2 v1.0.56
         Compiling quote v1.0.27
         Compiling unicode-ident v1.0.8
         Compiling once_cell v1.17.1
         Compiling typenum v1.16.0
         Compiling version_check v0.9.4
         Compiling log v0.4.17
         Compiling target-lexicon v0.12.7
         Compiling generic-array v0.14.7
         Compiling pkg-config v0.3.27
         Compiling serde v1.0.163
         Compiling memchr v2.5.0
         Compiling pin-project-lite v0.2.9
         Compiling futures-core v0.3.28
         Compiling bytes v1.4.0
         Compiling tokio v1.28.1
         Compiling io-lifetimes v1.0.10
         Compiling subtle v2.4.1
         Compiling bitflags v1.3.2
         Compiling itoa v1.0.6
         Compiling pyo3-build-config v0.18.3
         Compiling jobserver v0.1.26
         Compiling cc v1.0.79
         Compiling syn v2.0.15
         Compiling num_cpus v1.15.0
         Compiling mio v0.8.6
         Compiling socket2 v0.4.9
         Compiling slab v0.4.8
         Compiling crypto-common v0.1.6
         Compiling block-buffer v0.10.4
         Compiling rustix v0.37.19
         Compiling futures-task v0.3.28
         Compiling core-foundation-sys v0.8.4
         Compiling zstd-sys v2.0.8+zstd.1.5.5
         Compiling digest v0.10.6
         Compiling cpufeatures v0.2.7
         Compiling errno v0.3.1
         Compiling indexmap v1.9.3
         Compiling tracing-core v0.1.30
         Compiling syn v1.0.109
         Compiling fnv v1.0.7
         Compiling futures-util v0.3.28
         Compiling http v0.2.9
         Compiling tracing v0.1.37
         Compiling pyo3-ffi v0.18.3
         Compiling bzip2-sys v0.1.11+1.0.8
         Compiling core-foundation v0.9.3
         Compiling security-framework-sys v2.8.0
         Compiling lock_api v0.4.9
         Compiling fastrand v1.9.0
         Compiling pin-utils v0.1.0
         Compiling native-tls v0.2.11
         Compiling hashbrown v0.12.3
         Compiling glob v0.3.1
         Compiling zstd-safe v5.0.2+zstd.1.5.2
         Compiling lazy_static v1.4.0
         Compiling crc32fast v1.3.2
         Compiling httparse v1.8.0
         Compiling futures-channel v0.3.28
         Compiling parking_lot_core v0.9.7
         Compiling futures-sink v0.3.28
         Compiling futures-io v0.3.28
         Compiling tinyvec_macros v0.1.1
         Compiling tinyvec v1.6.0
         Compiling tokio-util v0.7.8
         Compiling serde_derive v1.0.163
         Compiling clang-sys v1.6.1
         Compiling tempfile v3.5.0
         Compiling security-framework v2.8.2
         Compiling memoffset v0.8.0
         Compiling num-traits v0.2.15
         Compiling adler v1.0.2
         Compiling try-lock v0.2.4
         Compiling scopeguard v1.1.0
         Compiling anyhow v1.0.71
         Compiling rand_core v0.6.4
         Compiling prettyplease v0.2.4
         Compiling smallvec v1.10.0
         Compiling percent-encoding v2.2.0
         Compiling base64ct v1.6.0
         Compiling form_urlencoded v1.1.0
         Compiling password-hash v0.4.2
         Compiling pyo3-macros-backend v0.18.3
         Compiling want v0.3.0
         Compiling miniz_oxide v0.7.1
         Compiling h2 v0.3.18
         Compiling unicode-normalization v0.1.22
         Compiling http-body v0.4.5
         Compiling sha2 v0.10.6
         Compiling pyo3 v0.18.3
         Compiling hmac v0.12.1
         Compiling cipher v0.3.0
         Compiling httpdate v1.0.2
         Compiling time-core v0.1.1
         Compiling ryu v1.0.13
         Compiling minimal-lexical v0.2.1
         Compiling opaque-debug v0.3.0
         Compiling tower-service v0.3.2
         Compiling thiserror v1.0.40
         Compiling serde_json v1.0.96
         Compiling unicode-bidi v0.3.13
         Compiling nom v7.1.3
         Compiling aes v0.7.5
         Compiling pyo3-macros v0.18.3
         Compiling idna v0.3.0
         Compiling time v0.3.21
         Compiling hyper v0.14.26
         Compiling pbkdf2 v0.11.0
         Compiling flate2 v1.0.26
         Compiling tokio-native-tls v0.3.1
         Compiling parking_lot v0.12.1
         Compiling thiserror-impl v1.0.40
         Compiling sha1 v0.10.5
         Compiling matrixmultiply v0.3.7
         Compiling num-integer v0.1.45
         Compiling libloading v0.7.4
         Compiling constant_time_eq v0.1.5
         Compiling bindgen v0.65.1
         Compiling unindent v0.1.11
         Compiling byteorder v1.4.3
         Compiling regex-syntax v0.7.1
         Compiling either v1.8.1
         Compiling indoc v1.0.9
         Compiling which v4.4.0
         Compiling hyper-tls v0.5.0
         Compiling cexpr v0.6.0
         Compiling serde_urlencoded v0.7.1
         Compiling url v2.3.1
         Compiling encoding_rs v0.8.32
         Compiling base64 v0.21.0
         Compiling regex v1.8.1
         Compiling rawpointer v0.2.1
         Compiling mime v0.3.17
         Compiling peeking_take_while v0.1.2
         Compiling lazycell v1.3.0
         Compiling ipnet v2.7.2
         Compiling rustc-hash v1.1.0
         Compiling shlex v1.1.0
         Compiling reqwest v0.11.17
         Compiling num-complex v0.4.3
         Compiling cmake v0.1.50
         Compiling json v0.12.4
         Compiling ndarray v0.15.6
         Compiling arc-swap v1.6.0
         Compiling pyo3-log v0.8.1
         Compiling pythonize v0.18.0
         Compiling bzip2 v0.4.4
         Compiling numpy v0.18.0
         Compiling zstd v0.11.2+zstd.1.5.2
         Compiling zip v0.6.5
         Compiling zip-extract v0.1.2
         Compiling acquire-imaging v0.1.3 (/private/var/folders/lp/tnrf4kq9095g1j__47pw9jdm0000gq/T/pip-install-nw1k40hk/acquire-imaging_217e1f6b58f44630b8913a6852cccc55)
      error: failed to run custom build command for `acquire-imaging v0.1.3 (/private/var/folders/lp/tnrf4kq9095g1j__47pw9jdm0000gq/T/pip-install-nw1k40hk/acquire-imaging_217e1f6b58f44630b8913a6852cccc55)`

      Caused by:
        process didn't exit successfully: `/private/var/folders/lp/tnrf4kq9095g1j__47pw9jdm0000gq/T/pip-install-nw1k40hk/acquire-imaging_217e1f6b58f44630b8913a6852cccc55/target/release/build/acquire-imaging-2cd5ad19ecf5fcf7/build-script-build` (exit status: 101)
        --- stdout
        CMAKE_TOOLCHAIN_FILE_acquire-video-runtime = None
        CMAKE_TOOLCHAIN_FILE_acquire_video_runtime = None
        TARGET_CMAKE_TOOLCHAIN_FILE = None
        CMAKE_TOOLCHAIN_FILE = None
        CMAKE_GENERATOR_acquire-video-runtime = None
        CMAKE_GENERATOR_acquire_video_runtime = None
        TARGET_CMAKE_GENERATOR = None
        CMAKE_GENERATOR = None
        CMAKE_PREFIX_PATH_acquire-video-runtime = None
        CMAKE_PREFIX_PATH_acquire_video_runtime = None
        TARGET_CMAKE_PREFIX_PATH = None
        CMAKE_PREFIX_PATH = None
        CMAKE_acquire-video-runtime = None
        CMAKE_acquire_video_runtime = None
        TARGET_CMAKE = None
        CMAKE = None
        running: cd "/private/var/folders/lp/tnrf4kq9095g1j__47pw9jdm0000gq/T/pip-install-nw1k40hk/acquire-imaging_217e1f6b58f44630b8913a6852cccc55/target/release/build/acquire-imaging-a837f0b430701aaa/out/build" && CMAKE_PREFIX_PATH="" "cmake" "/private/var/folders/lp/tnrf4kq9095g1j__47pw9jdm0000gq/T/pip-install-nw1k40hk/acquire-imaging_217e1f6b58f44630b8913a6852cccc55/acquire-video-runtime" "-DNOTEST=TRUE" "-DNO_UNIT_TESTS=TRUE" "-DNO_EXAMPLES=TRUE" "-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15" "-DCMAKE_SYSTEM_NAME=Darwin" "-DCMAKE_SYSTEM_PROCESSOR=arm64" "-DCMAKE_INSTALL_PREFIX=/private/var/folders/lp/tnrf4kq9095g1j__47pw9jdm0000gq/T/pip-install-nw1k40hk/acquire-imaging_217e1f6b58f44630b8913a6852cccc55/target/release/build/acquire-imaging-a837f0b430701aaa/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC" "-DCMAKE_C_COMPILER=/usr/bin/cc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC" "-DCMAKE_CXX_COMPILER=/usr/bin/c++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC" "-DCMAKE_ASM_COMPILER=/usr/bin/cc" "-DCMAKE_BUILD_TYPE=RelWithDebInfo"

        --- stderr
        thread 'main' panicked at '
        failed to execute command: No such file or directory (os error 2)
        is `cmake` not installed?

        build script failed, must exit now', /Users/dmccarthy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cmake-0.1.50/src/lib.rs:1098:5
        note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
      💥 maturin failed
        Caused by: Failed to build a native library through cargo
        Caused by: Cargo build finished with "exit status: 101": `MACOSX_DEPLOYMENT_TARGET="11.0" PYO3_ENVIRONMENT_SIGNATURE="cpython-3.11-64bit" PYO3_PYTHON="/opt/miniconda3/envs/acquire/bin/python" PYTHON_SYS_EXECUTABLE="/opt/miniconda3/envs/acquire/bin/python" "cargo" "rustc" "--message-format" "json-render-diagnostics" "--manifest-path" "/private/var/folders/lp/tnrf4kq9095g1j__47pw9jdm0000gq/T/pip-install-nw1k40hk/acquire-imaging_217e1f6b58f44630b8913a6852cccc55/Cargo.toml" "--release" "--lib" "--" "-C" "link-arg=-undefined" "-C" "link-arg=dynamic_lookup" "-C" "link-args=-Wl,-install_name,@rpath/acquire.abi3.so"`
      Error: command ['maturin', 'pep517', 'build-wheel', '-i', '/opt/miniconda3/envs/acquire/bin/python', '--compatibility', 'off'] returned non-zero exit status 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for acquire-imaging
Failed to build acquire-imaging
ERROR: Could not build wheels for acquire-imaging, which is required to install pyproject.toml-based projects
nclack commented 1 year ago

@nclack is there something we can do to the build script or the pyproject.toml so we don't have to build on install from PyPI?

We should be building and releasing wheels for the platform. I thought we did have M1 wheels but maybe not. That should get fixed.

We should probably document requirements for building from source but users need to understand that's not the expected path and there be dragons.

nclack commented 1 year ago

oh lol, we're only publishing the windows wheel. That would explain things. @aliddell how hard is it to publish the osx and linux wheels?

aliddell commented 1 year ago

lol indeed. This might've been before we had builds for the other platforms. One sec, let me try to rectify that.

aliddell commented 1 year ago

OK @dgmccart, try that pip install one more time.

dgmccart commented 1 year ago

Success!!