PyO3 / pyo3

Rust bindings for the Python interpreter
https://pyo3.rs
Other
11.44k stars 693 forks source link

Confusing error messages with invalid `PYO3_CROSS_LIB_DIR` #4277

Closed mrexodia closed 1 week ago

mrexodia commented 1 week ago

Bug Description

I had a workflow that contained a step:

      - name: Build
        shell: bash
        env:
          DEVELOPER_DIR: /Applications/Xcode.app/Contents/Developer
          MACOSX_DEPLOYMENT_TARGET: '10.9'
          ARCHFLAGS: -arch x86_64 -arch arm64
          PYO3_CROSS_LIB_DIR: /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib
        run: |
          pip install -r requirements.txt
          python setup.py bdist_wheel --py-limited-api=cp37
          pip install --force-reinstall dist/*_universal2.whl
          python -c "import icicle"

The tag was macos-latest and I didn't run it for a while. When I ran the build the error was:

error: failed to run custom build command for `pyo3-ffi v0.21.2`

Caused by:
  process didn't exit successfully: `/Users/runner/work/icicle-python/icicle-python/target/release/build/pyo3-ffi-d150facabc083c7d/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=PYO3_CROSS
  cargo:rerun-if-env-changed=PYO3_CROSS_LIB_DIR
  cargo:rerun-if-env-changed=PYO3_CROSS_PYTHON_VERSION
  cargo:rerun-if-env-changed=PYO3_CROSS_PYTHON_IMPLEMENTATION
  cargo:rerun-if-env-changed=PYO3_NO_PYTHON

  --- stderr
  thread 'main' panicked at /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pyo3-build-config-0.21.2/src/impl_.rs:1334:33:
  Path does not exist: Os { code: 2, kind: NotFound, message: "No such file or directory" }
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I think this message could be improved, because there was no mention of PYO3_CROSS_LIB_DIR or the actual path that was not found. It took me a while to figure out the PYO3_CROSS_LIB_DIR

Steps to Reproduce

N/A

Backtrace

No response

Your operating system and version

macos

Your Python version (python --version)

Python 3.9

Your Rust version (rustc --version)

rustc 1.71.1

Your PyO3 version

0.21.2

How did you install python? Did you use a virtualenv?

Came with Xcode, venv was not used

Additional Info

No response

davidhewitt commented 1 week ago

Thanks - we have #4278 and #4043 which should improve this hopefully...

davidhewitt commented 1 week ago

Fixed in #4043 (and just published in 0.22)