Open Source Development

Β View Only

 Cannot install orjson Python Module on AIX

  • AIX Open Source
Joerg Luehmann's profile image
Joerg Luehmann posted Mon December 09, 2024 06:11 AM

Hello Folks,

i have a problem installing Python module orjson on AIX 7.3.

I get following error message:

Collecting orjson==3.10.12
  Using cached orjson-3.10.12.tar.gz (5.4 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: orjson
  Building wheel for orjson (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  Building wheel for orjson (pyproject.toml) did not run successfully.
  exit code: 1
  
  [47 lines of output]
  Running `maturin pep517 build-wheel -i /opt/freeware/bin/python3.11 --compatibility off`
  πŸ“¦ Including license file "/tmp/pip-install-dmg_htd9/orjson_4eb228b18ce248f4b334325a9e5b822b/LICENSE-APACHE"
  πŸ“¦ Including license file "/tmp/pip-install-dmg_htd9/orjson_4eb228b18ce248f4b334325a9e5b822b/LICENSE-MIT"
  🍹 Building a mixed python/rust project
  πŸ”— Found pyo3-ffi bindings
  🐍 Found CPython 3.11 at /opt/freeware/bin/python3.11
     Compiling target-lexicon v0.12.16
     Compiling proc-macro2 v1.0.92
     Compiling unicode-ident v1.0.14
     Compiling once_cell v1.20.2
     Compiling rustversion v1.0.18
     Compiling serde v1.0.215
     Compiling cfg-if v1.0.0
     Compiling libc v0.2.164
     Compiling shlex v1.3.0
     Compiling itoa v1.0.13
     Compiling version_check v0.9.5
     Compiling serde_json v1.0.133
     Compiling ryu v1.0.18
     Compiling memchr v2.7.4
     Compiling static_assertions v1.1.0
     Compiling bytecount v0.6.8
     Compiling associative-cache v2.0.0
     Compiling itoap v1.0.1
     Compiling jiff v0.1.14
     Compiling smallvec v1.13.2
     Compiling simdutf8 v0.1.5
     Compiling uuid v1.11.0
     Compiling xxhash-rust v0.8.12
     Compiling encoding_rs v0.8.35
     Compiling half v2.4.1
     Compiling cc v1.2.1
     Compiling castaway v0.2.3
     Compiling pyo3-build-config v0.23.0-dev (/tmp/pip-install-dmg_htd9/orjson_4eb228b18ce248f4b334325a9e5b822b/include/pyo3/pyo3-build-config)
     Compiling quote v1.0.37
     Compiling syn v2.0.89
     Compiling pyo3-ffi v0.23.0-dev (/tmp/pip-install-dmg_htd9/orjson_4eb228b18ce248f4b334325a9e5b822b/include/pyo3/pyo3-ffi)
     Compiling orjson v3.10.12 (/tmp/pip-install-dmg_htd9/orjson_4eb228b18ce248f4b334325a9e5b822b)
     Compiling serde_derive v1.0.215
     Compiling compact_str v0.8.0
  error: failed to get bitcode from object file for LTO (could not find requested section)
  
  error: could not compile `orjson` (lib) due to 1 previous error
  πŸ’₯ maturin failed
    Caused by: Failed to build a native library through cargo
    Caused by: Cargo build finished with "exit status: 101": `env -u CARGO PYO3_ENVIRONMENT_SIGNATURE="cpython-3.11-64bit" PYO3_PYTHON="/opt/freeware/bin/python3.11" PYTHON_SYS_EXECUTABLE="/opt/freeware/bin/python3.11" "cargo" "rustc" "--message-format" "json-render-diagnostics" "--manifest-path" "/tmp/pip-install-dmg_htd9/orjson_4eb228b18ce248f4b334325a9e5b822b/Cargo.toml" "--release" "--lib"`
  Error: command ['maturin', 'pep517', 'build-wheel', '-i', '/opt/freeware/bin/python3.11', '--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 orjson
Failed to build orjson
ERROR: Could not build wheels for orjson, which is required to install pyproject.toml-based projects

I am using Python 3.11 but it does not work with Python 3.9 also

Any ideas?

kind regards

Joerg


#AIXOpenSource
Ranjit Ranjan's profile image
Ranjit Ranjan

Some discussion regarding this.  https://github.com/rust-lang/rust/issues/94232 . We will involve rust compiler team for further debugging. 

But for time being, can you follow below steps and try it in your system. Suggested patch is disabing  lto in Cargo.toml.

  • git clone https://github.com/ijl/orjson.git

  • git checkout 3.10.12

  • Apply below patch. 

    diff --git a/Cargo.toml b/Cargo.toml

    index 4a6213e..9ed7037 100644

    --- a/Cargo.toml

    +++ b/Cargo.toml

    @@ -88,7 +88,7 @@ overflow-checks = true

     codegen-units = 1

     debug = false

     incremental = false

    -lto = "thin"

    +lto = "off"

     opt-level = 3

     panic = "abort"

  • python3 -m pip install . --root $PWD/install -v

    In above command, change the value of '--root' as per your need.  


  • # python3

    Python 3.9.20 (main, Sep 27 2024, 03:16:26)

    [GCC 10.3.0] on aix

    Type "help", "copyright", "credits" or "license" for more information.

    >>> import orjson

    >>>


#AIXOpenSource