Open Source Development

Power Open Source Development

Explore the open source tools and capabilities for building and deploying modern applications on IBM Power platforms including AIX, IBM i, and Linux.


#Power


#Power

 View Only
Expand all | Collapse all

Building Python Cryptography 46.0.7

  • 1.  Building Python Cryptography 46.0.7

    Posted Thu April 16, 2026 08:24 AM

    Hi all,

    I am trying to build python cryptography 46.0.7 and maturin 1.12.6 for Python 3.13.11 + OpenSSL 3.5.6

    @Aditya Kamath public.dhe.ibm.com/aix/freeSoftware/aixtoolbox/SPECS/python3.12-maturin-1.9.0-2.spec

    The python I built only create a libPython3.13.so file, no .a file.

    When I try to build Python Cryptography I get the following error 

     warning[E0602]: unknown lint: `_ALL_SOURCE`
        |
        = note: requested on the command line with `-D _ALL_SOURCE`
        = note: `#[warn(unknown_lints)]` on by default
    
         Compiling foreign-types v0.3.2
      For more information about this error, try `rustc --explain E0602`.
      warning: `cryptography-key-parsing` (build script) generated 1 warning (1 duplicate)
      warning: `cryptography-openssl` (build script) generated 1 warning
         Compiling cc v1.2.37
         Compiling pem v3.0.5
         Compiling memoffset v0.9.1
         Compiling pyo3-build-config v0.26.0
         Compiling quote v1.0.40
         Compiling syn v2.0.106
         Compiling openssl-sys v0.9.110
         Compiling cryptography-cffi v0.1.0 (/tmp/pip-wheel-9rfw0k7k/cryptography_69b630b938b4412a99b8bcb6e5dfbfc9/src/rust/cryptography-cffi)
      warning: `cryptography-cffi` (build script) generated 1 warning (1 duplicate)
         Compiling pyo3-macros-backend v0.26.0
         Compiling pyo3-ffi v0.26.0
         Compiling pyo3 v0.26.0
         Compiling cryptography-rust v0.1.0 (/tmp/pip-wheel-9rfw0k7k/cryptography_69b630b938b4412a99b8bcb6e5dfbfc9/src/rust)
      warning: `cryptography-rust` (build script) generated 1 warning (1 duplicate)
         Compiling openssl-macros v0.1.1
         Compiling asn1_derive v0.22.0
         Compiling asn1 v0.22.0
         Compiling cryptography-x509 v0.1.0 (/tmp/pip-wheel-9rfw0k7k/cryptography_69b630b938b4412a99b8bcb6e5dfbfc9/src/rust/cryptography-x509)
      warning: cryptography-cffi@0.1.0: /opt/IBM/xlC/16.1.0/bin/.orig/xlclang++: warning: 1501-257 Option target=powerpc64-ibm-aix is not recognized.  Option will be ignored.
      warning: cryptography-cffi@0.1.0: warning: 1540-5200 The option "-ffunction-sections" is not supported.
      warning: cryptography-cffi@0.1.0: warning: 1540-5200 The option "-fdata-sections" is not supported.
      warning: cryptography-cffi@0.1.0: 2 warnings generated.
         Compiling pyo3-macros v0.26.0
         Compiling cryptography-crypto v0.1.0 (/tmp/pip-wheel-9rfw0k7k/cryptography_69b630b938b4412a99b8bcb6e5dfbfc9/src/rust/cryptography-crypto)
      warning: `cryptography-openssl` (lib) generated 1 warning (1 duplicate)
      warning: `cryptography-crypto` (lib) generated 1 warning (1 duplicate)
         Compiling cryptography-x509-verification v0.1.0 (/tmp/pip-wheel-9rfw0k7k/cryptography_69b630b938b4412a99b8bcb6e5dfbfc9/src/rust/cryptography-x509-verification)
      warning: `cryptography-key-parsing` (lib) generated 1 warning (1 duplicate)
      warning: `cryptography-x509-verification` (lib) generated 1 warning (1 duplicate)
      warning: `cryptography-x509` (lib) generated 1 warning (1 duplicate)
         Compiling cryptography-keepalive v0.1.0 (/tmp/pip-wheel-9rfw0k7k/cryptography_69b630b938b4412a99b8bcb6e5dfbfc9/src/rust/cryptography-keepalive)
      warning: `cryptography-keepalive` (lib) generated 1 warning (1 duplicate)
      warning: `cryptography-cffi` (lib) generated 1 warning (1 duplicate)
      error: linking with `ld` failed: exit status: 255
        |
        = note:  "ld" "-bE:/tmp/rustcyh243M/list.exp" "-b64" "-bpT:0x100000000" "-bpD:0x110000000" "-bcdtors:all:0:s" "/tmp/rustcyh243M/symbols.o" "<17 object files omitted>" "-bnoipath" "-bstatic" "/tmp/pip-wheel-9rfw0k7k/cryptography_69b630b938b4412a99b8bcb6e5dfbfc9/target/release/deps/{libcryptography_cffi-e587dfe594a86d1d,libcryptography_keepalive-f05aebc224c71f5e,libcryptography_openssl-cbff964ae3e68165,libpem-323a9dde10d2c3a5,libself_cell-41890c3c99b83821,libcryptography_x509_verification-e6d92614b29d65db,libcryptography_key_parsing-08c908ed8eabe13d,libbase64-f9f58bf153af4bba,libcryptography_crypto-f174fa484b771f3b,libcryptography_x509-3a2f37408d524c2a,libasn1-1b15a3eed6d8173d,libitoa-955cf1a5a2b7c6c8,libpyo3-b2c942f54edf10b9,libpyo3_ffi-d0a6ee5779ac4983,libmemoffset-ed998556f337f5e1,libunindent-eea165ce7ccb5a82,libopenssl-bbb5d67ee1122215,libonce_cell-9d34341cf8045d48,libbitflags-b9690c545b6b51a2,libcfg_if-483de3806f63a583,libforeign_types-27c749557a0d273c,libforeign_types_shared-b2ab3d7db50ae4fd,libopenssl_sys-bb817c0666652038,liblibc-dc13d487339ce841}.rlib" "<sysroot>/lib/rustlib/powerpc64-ibm-aix/lib/{libstd-*,libpanic_unwind-*,libobject-*,libmemchr-*,libaddr2line-*,libgimli-*,libcfg_if-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,liblibc-*,librustc_std_workspace_core-*,liballoc-*,libcore-*,libcompiler_builtins-*}.rlib" "-bdynamic" "-lpython3.13" "-lthread" "-lpthread" "-liconv" "-lunwind" "-lc" "-lm" "-lbsd" "-lpthread" "-lthread" "-lpthread" "-liconv" "-L" "/opt/freeware/lib" "-L" "/tmp/pip-wheel-9rfw0k7k/cryptography_69b630b938b4412a99b8bcb6e5dfbfc9/target/release/build/cryptography-cffi-8ada48bbece47206/out" "-L" "/opt/openssl/3.5.6/lib" "-L" "/space/logs/3.13.11/lib" "-L" "<sysroot>/lib/rustlib/powerpc64-ibm-aix/lib" "-o" "/tmp/rustcyh243M/libcryptography_rust.so" "-bgc" "-bM:SRE" "-bnoentry" "-bexpfull" "-bbigtoc" "-bnoipath" "/space/logs/3.13.11/lib/libpython3.13.so"
        = note: some arguments are omitted. use `--verbose` to show all linker arguments
        = note: ld: 0706-006 Cannot find or open library file: -l python3.13
                    ld:open(): No such file or directory
    
    
      warning: `cryptography-rust` (lib) generated 1 warning (1 duplicate)
      error: could not compile `cryptography-rust` (lib) due to 1 previous error; 1 warning emitted
      💥 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_BUILD_EXTENSION_MODULE="1" PYO3_ENVIRONMENT_SIGNATURE="cpython-3.13-64bit" PYO3_PYTHON="/disks/sc_scratch/AIX/test/venv/bin/python3.13" PYTHON_SYS_EXECUTABLE="/disks/sc_scratch/AIX/test/venv/bin/python3.13" "cargo" "rustc" "--profile" "release" "--message-format" "json-render-diagnostics" "--locked" "--manifest-path" "/tmp/pip-wheel-9rfw0k7k/cryptography_69b630b938b4412a99b8bcb6e5dfbfc9/src/rust/Cargo.toml" "--lib"`
      Error: command ['maturin', 'pep517', 'build-wheel', '-i', '/disks/sc_scratch/AIX/test/venv/bin/python3.13', '--compatibility', 'off'] returned non-zero exit status 1
      error: subprocess-exited-with-error
    
      Building wheel for cryptography (pyproject.toml) did not run successfully.
      exit code: 1
    
      No available output.
    
      note: This error originates from a subprocess, and is likely not a problem with pip.
      full command: /disks/sc_scratch/AIX/test/venv/bin/python3.13 /disks/sc_scratch/AIX/test/venv/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py build_wheel /tmp/tmphf6ajg5k
      cwd: /tmp/pip-wheel-9rfw0k7k/cryptography_69b630b938b4412a99b8bcb6e5dfbfc9
      Building wheel for cryptography (pyproject.toml) ... error
      ERROR: Failed building wheel for cryptography
    Failed to build cryptography
    
    [notice] A new release of pip is available: 25.3 -> 26.0.1
    [notice] To update, run: pip install --upgrade pip
    ERROR: Failed to build one or more wheels
    



    ------------------------------
    Avinesh Benjamin
    ------------------------------


  • 2.  RE: Building Python Cryptography 46.0.7

    Posted Thu April 16, 2026 08:44 AM

    @Avinesh Benjamin

    > The python I built only create a libPython3.13.so file, no .a file.

    You may want to rebuild python3.13, looking at the SPEC file of python3.12, to have a shared library in an archive in AIX.

    So in AIX, the linker expects a shared object in an archive by default. So the error below is obvious.

    = note: ld: 0706-006 Cannot find or open library file: -l python3.13
                    ld:open(): No such file or directory
    


    It is not able to find libpython3.13.a

    One thing you can do is try with -brtl which will link to libpython3.13.so if available in the same RUSTFLAGS and try.

    The other way is to rebuild Python 3.13 to have a shared object in an archive. If you do want to do that, you can try a manual archive as well with an ar command.

    But it will be a trial and error.



    ------------------------------
    Aditya Kamath
    ------------------------------



  • 3.  RE: Building Python Cryptography 46.0.7

    Posted Thu April 16, 2026 08:50 AM

    Hi @Aditya Kamath

    I actually tried but for some reason the python build always outputs libpython3.13.so only, I tried using ar -X64 -r -c and ranlib -X64 but it causes some other issues I assume related to linking which causes all libraries like pyzmq to fail.

    I tried passing export RUSTFLAGS="-C link-arg=-bbigtoc -L/opt/freeware/lib -D_ALL_SOURCE -C link-arg=-bnoipath -C link-arg=/space/logs/3.13.11/lib/libpython3.13.so" but for some reason -lpython still gets added



    ------------------------------
    Avinesh Benjamin
    ------------------------------



  • 4.  RE: Building Python Cryptography 46.0.7

    Posted Thu April 16, 2026 08:58 AM

    @Avinesh Benjamin

    >I tried passing export RUSTFLAGS="-C link-arg=-bbigtoc -L/opt/freeware/lib -D_ALL_SOURCE -C link-arg=-bnoipath -C link-arg=/space/logs/3.13.11/lib/libpython3.13.so" but for some reason -lpython still gets added

    Yes, linking python3.13 is needed, that is why it is rightly added by the build. 

    How about this, since you want to use a .so

     export RUSTFLAGS="-C link-arg=-bbigtoc -L/opt/freeware/lib -D_ALL_SOURCE -C link-arg=-bnoipath -C link-arg=-brtl"

    Let me what happens. This brtl option should make it work though we do not suggest to normally. brtl will make it link to libpython3.13.so.



    ------------------------------
    Aditya Kamath
    ------------------------------



  • 5.  RE: Building Python Cryptography 46.0.7

    Posted Fri April 24, 2026 09:25 AM

    Hi @Aditya Kamath

    Yes the cryptography library is now successfully built thanks.

    Since on AIX its best python library even shared be generated as libpython3.13.a (.so file inside) can you share what extra env variables need to be set?

    I tried adding the libpython.3.13.so to an archive and running ranlib but if I do that and try to install pyzmq or cyrptorpahy

    I get the below error:

    Fatal Python error: PyInterpreterState_Get: the function must be called with the GIL held, after Python initialization and before Python finalization, but the GIL is released (the current Python thread state is NULL)
    Python runtime state: unknown
    
    IOT/Abort trap             (core dumped) python
    

    Please note that using -Wl,-bnoipath for pyzmq and in cryptography using -brtl flag works and the post installing the packages work fine no errors, but converting the so using ar, ranlib result in the below errors



    ------------------------------
    Avinesh Benjamin
    ------------------------------



  • 6.  RE: Building Python Cryptography 46.0.7

    Posted Wed April 29, 2026 11:45 AM

    @Avinesh Benjamin

    This can happen because we mix up a .So, then archive and, finally, in linking time, applications do not know whom to link. If we get that build right, everything falls in place.

    Let us start with rebuilding python itslef correctly with .a

    https://public.dhe.ibm.com/aix/freeSoftware/aixtoolbox/PATCHES/python3.12-archive-libpython.patch

    You see this patch. You can go to the source code and apply the same.

    https://public.dhe.ibm.com/aix/freeSoftware/aixtoolbox/SPECS/python3.12-3.12.13-1.spec

    In the spec file there are 11. You can see what those patches are and apply them in the source and then build. Let us know if you need help.



    ------------------------------
    Aditya Kamath
    ------------------------------



  • 7.  RE: Building Python Cryptography 46.0.7

    Posted Thu April 30, 2026 08:16 AM
    LIBPATH=/space/logs/Python-3.12.13 ./python -E -c 'import sys ; from sysconfig import get_platform ; print("%s-%d.%d" % (get_platform(), *sys.version_info[:2]))' >platform
    Traceback (most recent call last):
      File "/disks/sc_scratch/AIX/Python-3.12.13/./Tools/build/check_extension_modules.py", line 25, in <module>
        import pathlib
      File "/disks/sc_scratch/AIX/Python-3.12.13/Lib/pathlib.py", line 20, in <module>
        from urllib.parse import quote_from_bytes as urlquote_from_bytes
      File "/disks/sc_scratch/AIX/Python-3.12.13/Lib/urllib/parse.py", line 36, in <module>
        import math
    ImportError:    0509-136   Symbol _Py_get___phello___ham_toplevel (number 1855) is not exported from
                       dependent module /space/logs/Python-3.12.13/libpython3.12.a(libpython3.12.so).
            0509-136   Symbol _Py_get___phello___ham_eggs_toplevel (number 1854) is not exported from
                       dependent module /space/logs/Python-3.12.13/libpython3.12.a(libpython3.12.so).
            0509-136   Symbol _Py_get___hello___toplevel (number 1853) is not exported from
                       dependent module /space/logs/Python-3.12.13/libpython3.12.a(libpython3.12.so).
            0509-136   Symbol _Py_find__doc__ (number 1852) is not exported from
                       dependent module /space/logs/Python-3.12.13/libpython3.12.a(libpython3.12.so).
            0509-136   Symbol _Py_endswith__doc__ (number 1851) is not exported from
                       dependent module /space/logs/Python-3.12.13/libpython3.12.a(libpython3.12.so).
            0509-136   Symbol _Py_count__doc__/space/logs/Python-3.12.13/libpython3.12.a (number libpython3.12.so) is not exported from
                       dependent module 1850(/space/logs/Python-3.12.13/libpython3.12.a).
            0509-136   Symbol _Py_capitalize__doc__ (number 1849) is not exported from
                       dependent module /space/logs/Python-3.12.13/libpython3.12.a(libpython3.12.so).
            0509-021 Additional errors occurred but are not reported.
            0509-192 Examine .loader section symbols with the
                     'dump -Tv' command.
    

    Getting the above error



    ------------------------------
    Avinesh Benjamin
    ------------------------------



  • 8.  RE: Building Python Cryptography 46.0.7

    Posted 27 days ago

    Are you building python 3.12 or 3.13 ?
    The last message shows as python 3.12 and the symbols show in the error message is not there in python 3.12 source. 



    ------------------------------
    Ayappan P
    ------------------------------



  • 9.  RE: Building Python Cryptography 46.0.7

    Posted 26 days ago

    Hi @Ayappan P

    First I tried 3.13.11 that failed so now I am trying to build 3.12.13



    ------------------------------
    Avinesh Benjamin
    ------------------------------



  • 10.  RE: Building Python Cryptography 46.0.7

    Posted 19 days ago

    @Ayappan P @Aditya Kamath

    public.dhe.ibm.com/aix/freeSoftware/aixtoolbox/PATCHES/python3.12-get_platform-aix.patch

    Based on above patch

    (venv) bash-5.2$ python
    Python 3.13.11 (main, Apr 30 2026, 08:48:40) [GCC 10.3.0] on aix
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import sysconfig
    >>> sysconfig.get_platform()
    'aix-ppc64'

    This will change the name for wheels being created as well, is this expected say we want to build wheels once and host internally wont this cause issues among AIX operating system

    versions like issues between 7.2, 7.3

    When I tried building a wheel with this patch the naming convention is as follows cryptography-46.0.7-cp313-abi3-aix_ppc64.whl

    Without this patch cryptography-46.0.7-cp313-abi3-aix_7302_9988_64.whl

    Please explain if this is expected or will cause any issues or will this cause issues  if multiple AIX versions are present?

    The reason I am asking is cause the official python distributed by AIX under /usr/ returns the below

    bash-5.2$ oslevel -s
    7300-02-04-2520
    bash-5.2$ python3
    Python 3.9.20 (main, Oct 18 2024, 06:15:28)
    [IBM XL C/C++ for AIX 16.1.0.14] on aix
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import sysconfig
    >>> sysconfig.get_platform()
    'aix-7302-9988-64'



    ------------------------------
    Avinesh Benjamin
    ------------------------------



  • 11.  RE: Building Python Cryptography 46.0.7

    Posted 19 days ago

    There were recent changes in python packaging module which now relies on python's get_platform() to create and validate the wheel tag. Having a common name like "aix-ppc64" can take advantage of binary backward compatibility, hence the change in get_platform(). This is similar to other platforms.
    Already released python major versions in AIX base (python3.9 & python3.11) will continue to have the older behaviour. Only the new python major releases will have this change.



    ------------------------------
    Ayappan P
    ------------------------------



  • 12.  RE: Building Python Cryptography 46.0.7

    Posted 16 days ago

    @Ayappan P

    In case of wheels built and hosted on Jfrog using AIX 7.3 will it cause for AIX 7.1 or 7.2?

    Given that the platform now is aix-ppc64?



    ------------------------------
    Avinesh Benjamin
    ------------------------------



  • 13.  RE: Building Python Cryptography 46.0.7

    Posted 16 days ago

    Generally you build a wheel on a lower level ( AIX 7.1/7.2) and that can also be installed & used on a higher level ( AIX 7.3). The reverse is not recommended. 
    In the context of python's get_platform, if the wheel is built using it's older behaviour and installed in a machine with newer behaviour, you will get a warning message like below when pip check is ran. But there is no problem in installing and using it. 
    "cryptography 44.0.2 is not supported on this platform" 




    ------------------------------
    Ayappan P
    ------------------------------



  • 14.  RE: Building Python Cryptography 46.0.7

    Posted 15 days ago

    @Ayappan P

    The rust compiler is only available on AIX 7.2 TL5 and above say I built it on TL5 and hosted it internally,

     someone on AIX 7.1 python 3.12.12(with the get_platform patched) tried to do a pip install of cryptography==46.0.7, will it work or could it cause issues?

    the platform will be aix_ppc64 but is it possible the abi or other info is same and we run into issues?



    ------------------------------
    Avinesh Benjamin
    ------------------------------



  • 15.  RE: Building Python Cryptography 46.0.7

    Posted 14 days ago

    Rust based packages will not work in AIX 7.1. 
    Pip will allow to install the wheel but loading of the cryptography module will fail in AIX 7.1 because of missing dependent libraries. 



    ------------------------------
    Ayappan P
    ------------------------------



  • 16.  RE: Building Python Cryptography 46.0.7

    Posted 13 days ago
    Edited by Avinesh Benjamin 13 days ago

    This may cause issues when we deploy the wheels is it better in that case to revert this patch then?

    @Ayappan P, @Aditya Kamath 

    public.dhe.ibm.com/aix/freeSoftware/aixtoolbox/PATCHES/python3.12-get_platform-aix.patch is it safe to ignore this patch?

    ------------------------------
    Avinesh Benjamin
    ------------------------------



  • 17.  RE: Building Python Cryptography 46.0.7

    Posted 13 days ago

    It's not correct to build a wheel in AIX 7.2 / AIX 7.3 and trying to install it in AIX 7.1.
    It's not the functionality of python's get_platform() to fix this problem. 



    ------------------------------
    Ayappan P
    ------------------------------



  • 18.  RE: Building Python Cryptography 46.0.7

    Posted 13 days ago

    @Ayappan P

    If the patch is not applied then we get the wheel file with naming convention as follows: cffi-2.0.0-cp313-cp313-aix_7302_9988_64.whl

    If the patch is applied: cffi-2.0.0-cp313-cp313-aix_ppc64.whl

    Say I attempt doing a pip from 7.2 it will first try to find wheels in our internal Jfrog.

    Now on 7.2 the wheel needed maybe different for eg aix_7202_9988_64, so pip itself will fail to find the wheel and building the wheel would fail as the relevant env values have not been set.

    Please see this cffi · PyPI

    Say if we want to host out own python wheels internally, we will face issues when trying to install cffi from 7.2 and 7.3 as the wheel files generated from both will just say aix_ppc64

    even on linux the platform information is not generic like linux_amd64 we have multiple options which ensures the correct wheel is obtained based on the OS kernel version and glibc I assume

    Please advice on how to proceed, our goal is to host Python wheels internally



    ------------------------------
    Avinesh Benjamin
    ------------------------------



  • 19.  RE: Building Python Cryptography 46.0.7

    Posted 13 days ago

    In linux, the sophisticated platform identification functionality is provided through pip's packaging module (and not through python's get_platform().) Such level of sophistication is not there for AIX in packaging module and may not be required also. Users can take advantage of AIX's backward binary compatibility to build wheels on a lower supported level (AIX 7.2) and install/use it in higher level (AIX 7.3). 
    In your case, if you have already built the wheels for a major python version with the older behaviour and rebuilding them with the newer behaviour is not an option, then you can continue by ignoring the patch. 



    ------------------------------
    Ayappan P
    ------------------------------