benabed / clik

Planck likelihood code
3 stars 5 forks source link

Python.h not found #1

Open cmbant opened 1 year ago

cmbant commented 1 year ago

Various travis ubuntu configurations give this error installing clik, e.g. see log at

https://app.travis-ci.com/github/CobayaSampler/cobaya/jobs/588625259

There are also a large number of compiler warnings.

cmbant commented 1 year ago

On gcc11 recent conda-forge, it instead appears to compile but does not generate lkl files: https://app.travis-ci.com/github/CobayaSampler/cobaya/jobs/588625261#L3350

cmbant commented 1 year ago

This is also the same on baseline gcc11 jammy installation with python 3.11 https://app.travis-ci.com/github/CobayaSampler/cobaya/jobs/594037592

zachjweiner commented 1 year ago

A long-standing deprecation expired in python 3.11, which is accounted for only in waf>=2.0.24 (the version vendored in this repo is 2.0.22). See this issue for details.

Simple workaround (short of upgrading the vendored version) is to install waf from, e.g., conda-forge; invoking waf [configure/install] ... should pick up this one rather than the bundled one.

The following works (on Linux, at least) and drops clik in the correct site-packages directory to avoid having to mess around manually with sys.path:

conda install numpy scipy cython waf astropy cfitsio gfortran gcc

export CPATH="$CONDA_PREFIX/include:$CPATH"
export LD_LIBRARY_PATH="$CONDA_PREFIX/lib:$CPATH"
waf configure --cfitsio_prefix=$CONDA_PREFIX --pythondir=$(python -c "import site; print(site.getsitepackages()[0])") --pythonarchdir=$CONDA_PREFIX/lib
waf install

It'd be nice to upgrade to a modern build system---for the python wrapper, at the least---that pip knows how to work with (whether pyproject.toml-based, like meson-python, or with setuptools via a setup.py script).

cmbant commented 1 year ago

Thanks, with the recent commits with waf update it does seem to build more reliably, but I still see Python.h errors, e.g. with bionic, gcc-7, Python 3.8

https://app.travis-ci.com/github/CobayaSampler/cobaya/jobs/595797856

There are also warnings "FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2).", I don't know if this is related or if explicitly setting it in config would help.

JesusTorrado commented 1 year ago

In Linux Debian-based systems (Ubuntu, etc), simply install libpython3-dev.