SciTools / cf-units

Units of measure as required by the Climate and Forecast (CF) Metadata Conventions
https://cf-units.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
64 stars 47 forks source link

Error building from source #389

Open rcomer opened 10 months ago

rcomer commented 10 months ago

🐛 Bug Report

Cannot currently build cf-units from source on Met Office machine with python 3.12. Everything is fine if I pin python=3.11.

How to Reproduce

Steps to reproduce the behaviour:

  1. Create conda environment from requirements/cf-units.yml
  2. python -m pip install -v .

Error:

  In file included from cf_units/_udunits2.c:20448:0:
  /.../conda_envs/cf-units-dev/include/python3.12/internal/pycore_frame.h: In function '_PyFrame_Initialize':
  /.../conda_envs/cf-units-dev/include/python3.12/internal/pycore_frame.h:132:5: error: 'for' loop initial declarations are only allowed in C99 mode
       for (int i = null_locals_from; i < code->co_nlocalsplus; i++) {
       ^
  /.../conda_envs/cf-units-dev/include/python3.12/internal/pycore_frame.h:132:5: note: use option -std=c99 or -std=gnu99 to compile your code
  error: command '/usr/bin/gcc' failed with exit code 1
  error: subprocess-exited-with-error

Expected Behaviour

cf-units builds without error

Environment

Additional Context

Click to expand this section... ``` Please add additional verbose information in this section e.g., code, output, tracebacks, screenshots etc ```
bjlittle commented 10 months ago

@rcomer Thanks for raising this issue.

I suspect that we need to make some minor tweaks to cf-units to use cython 3.x and build correctly for py312.

I'm keen to make a fix for this and force a release of cf-units soon.

rcomer commented 10 months ago

I cannot reproduce the problem on Ubuntu 22.04.