Skip to content

Conversation

@dimpase
Copy link
Member

@dimpase dimpase commented Dec 13, 2025

fixes #194

@dimpase
Copy link
Member Author

dimpase commented Dec 13, 2025

This doesn't quite work, as custom prefix pari clashes with a system-wide one

@dimpase dimpase marked this pull request as draft December 13, 2025 01:55
@dimpase
Copy link
Member Author

dimpase commented Dec 13, 2025

$ uv pip install . --config-settings=setup-args="-Dpari-prefix=/home/dima/software/pari"
  × Failed to build `cypari2 @ file:///home/dima/software/cypari2`
  ├─▶ The build backend returned an error
  ╰─▶ Call to `mesonpy.build_wheel` failed (exit status: 1)

      [stdout]
      + meson setup /home/dima/software/cypari2 /home/dima/software/cypari2/.mesonpy-smpp0m2z -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md -Dpari-prefix=/home/dima/software/pari
      --native-file=/home/dima/software/cypari2/.mesonpy-smpp0m2z/meson-python-native-file.ini
      The Meson build system
      Version: 1.10.0
      Source dir: /home/dima/software/cypari2
      Build dir: /home/dima/software/cypari2/.mesonpy-smpp0m2z
      Build type: native build
      Project name: cypari2
      Project version: 2.2.4
      C compiler for the host machine: /usr/bin/ccache cc (gcc 15.2.1 "cc (Gentoo 15.2.1_p20251122 p3) 15.2.1 20251122")
      C linker for the host machine: cc ld.bfd 2.45.1
      Cython compiler for the host machine: cython (cython 3.2.2)
      Host machine cpu family: x86_64
      Host machine cpu: x86_64
      Program python found: YES (/home/dima/.cache/uv/builds-v0/.tmpQEchNn/bin/python)
      Found pkg-config: YES (/usr/bin/pkg-config) 2.5.1
      Run-time dependency gmp found: YES 6.3.0
      Has header "pari/pari.h" : YES
      Has header "pari/pari.h" : YES
      Library pari found: YES
      Checking if "pari version" with dependencies -lpari, gmp runs: YES
      Message: PARI Version: [2, 17, 2]
      Checking if "pari datadir" with dependencies -lpari, gmp runs: YES
      Message: PARI Datadir: /usr/share/pari
      Found pkg-config: YES (/usr/bin/pkg-config) 2.5.1
      Run-time dependency python found: YES 3.13
      Configuring cypari2.pc using configuration
      Build targets in project: 9

      cypari2 2.2.4

        User defined options
          Native files: /home/dima/software/cypari2/.mesonpy-smpp0m2z/meson-python-native-file.ini
          b_ndebug    : if-release
          b_vscrt     : md
          buildtype   : release
          pari-prefix : /home/dima/software/pari

      Found ninja-1.13.2 at /usr/bin/ninja
      + /usr/bin/ninja
      [1/27] Compiling Cython source /home/dima/software/cypari2/cypari2/string_utils.pyx
      [2/27] Compiling Cython source /home/dima/software/cypari2/cypari2/custom_block.pyx
      [3/27] Compiling Cython source /home/dima/software/cypari2/cypari2/handle_error.pyx
      [4/27] Compiling C object cypari2/string_utils.cpython-313-x86_64-linux-gnu.so.p/meson-generated_cypari2_string_utils.pyx.c.o
      [5/27] Linking target cypari2/string_utils.cpython-313-x86_64-linux-gnu.so
      [6/27] Compiling C object cypari2/custom_block.cpython-313-x86_64-linux-gnu.so.p/meson-generated_cypari2_custom_block.pyx.c.o
      [7/27] Linking target cypari2/custom_block.cpython-313-x86_64-linux-gnu.so
      FAILED: [code=1] cypari2/custom_block.cpython-313-x86_64-linux-gnu.so
      cc  -o cypari2/custom_block.cpython-313-x86_64-linux-gnu.so cypari2/custom_block.cpython-313-x86_64-linux-gnu.so.p/meson-generated_cypari2_custom_block.pyx.c.o -Wl,--as-needed
      -Wl,--allow-shlib-undefined -Wl,-O1 -shared -fPIC -Wl,--start-group /usr/lib64/libpari.so /usr/lib64/libgmp.so -Wl,--end-group
      /usr/lib/gcc/x86_64-pc-linux-gnu/15/../../../../x86_64-pc-linux-gnu/bin/ld: PARI_SIGINT_pending: TLS definition in /usr/lib64/libpari.so section .tbss mismatches non-TLS reference in
      cypari2/custom_block.cpython-313-x86_64-linux-gnu.so.p/meson-generated_cypari2_custom_block.pyx.c.o
      /usr/lib/gcc/x86_64-pc-linux-gnu/15/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib64/libpari.so: error adding symbols: bad value
      collect2: error: ld returned 1 exit status
      [8/27] Compiling Cython source /home/dima/software/cypari2/tests/test.pyx
      [9/27] Compiling Cython source /home/dima/software/cypari2/cypari2/closure.pyx
      [10/27] Compiling Cython source /home/dima/software/cypari2/cypari2/stack.pyx
      [11/27] Compiling Cython source /home/dima/software/cypari2/cypari2/convert.pyx
      [12/27] Compiling C object cypari2/handle_error.cpython-313-x86_64-linux-gnu.so.p/meson-generated_cypari2_handle_error.pyx.c.o
      [13/27] Compiling Cython source /home/dima/software/cypari2/cypari2/gen.pyx
      warning: /home/dima/software/cypari2/cypari2/gen.pyx:2030:4: __nonzero__ was removed in Python 3; use __bool__ instead
      [14/27] Compiling Cython source /home/dima/software/cypari2/cypari2/pari_instance.pyx
      warning: /home/dima/software/cypari2/cypari2/pari_instance.pyx:588:8: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime
      conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: /home/dima/software/cypari2/cypari2/pari_instance.pyx:1420:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime
      conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      ninja: build stopped: subcommand failed.

      hint: This usually indicates a problem with the package or the build environment.

this what I get if I install pari 2.17.3 to /home/dima/software/pari, pass it to pip, and try building. How does one tell meson not to use system-wide pari?
@tobiasdiez

@tobiasdiez
Copy link
Contributor

The simplest solution would be to convince the pari people to add a pkg-config file...

with PPREF set to point at pari install prefix,
do

 export LDFLAGS="-Wl,-rpath=$PPREF/lib -L$PPREF/lib -lpari"
 pip install . --config-settings=setup-args="-Dpari-prefix=$PPREF"

works
@dimpase
Copy link
Member Author

dimpase commented Dec 14, 2025

I pushed a solution involving setting LDFLAGS (CI needs adjusting accordingly, I guess), no idea why args setting in compiler.run, as suggested on mesonbuild tracker, doesn't work.

cf the commit message:

this allows an external pari library, with LDFLAGS set
with PPREF set to point at pari install prefix,
do

 export LDFLAGS="-Wl,-rpath=$PPREF/lib -L$PPREF/lib -lpari"
 pip install . --config-settings=setup-args="-Dpari-prefix=$PPREF"

works

@dimpase
Copy link
Member Author

dimpase commented Dec 14, 2025

The simplest solution would be to convince the pari people to add a pkg-config file...

Does meson use rpath in this case? That's what's needed for building wheels.

@dimpase
Copy link
Member Author

dimpase commented Dec 14, 2025

@dimpase
Copy link
Member Author

dimpase commented Dec 14, 2025

is setting LDFLAGS equivalent to passing an argument to meson?

@dimpase
Copy link
Member Author

dimpase commented Dec 15, 2025

is setting LDFLAGS equivalent to passing an argument to meson?

OK, turns out I can use -Dc_link_args to pass what should be in LDFLAGS, that is,

meson setup build/ --debug -Dpari-prefix=$PPREF -Dc_link_args="-Wl,-rpath=$PPREF/lib -L$PPREF/lib -lpari"

now I need to figure out how to pass all this to pip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

allow pari-gp at a non-standard location

2 participants