Skip to content

Ignore pre-existing ERFA config.h when installing - #306

Merged
avalentino merged 1 commit into
liberfa:mainfrom
eerovaher:config.h-generation
Jul 31, 2026
Merged

Ignore pre-existing ERFA config.h when installing#306
avalentino merged 1 commit into
liberfa:mainfrom
eerovaher:config.h-generation

Conversation

@eerovaher

@eerovaher eerovaher commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

On current main there is quite complicated code in setup.py to decide if and how to generate ERFA's config.h, but I don't think that code is behaving as it should. One problem is that config.h is not regenerated if it is already present, so if the liberfa submodule is ever updated then pyerfa will keep using the outdated config.h. Another problem is that config.h can be generated in two different ways. The preferred way is to run ERFA's configure script, but that has to be generated by running ERFA's bootstrap.sh, which requires additional C tooling (autoconf, automake, libtool). Because that tooling might not be available then setup.py can also directly generate a minimal config.h itself. Once the minimal file has been generated pyerfa will keep using it even if the C tooling is installed and generating the full file becomes possible. Both problems are further worsened because config.h is in the liberfa submodule .gitignore, so git status does not reveal its presence.

In this PR a pre-existing config.h is always ignored. Development installs try to generate the ERFA configure script by running ERFA's bootstrap.sh, but because configure should be included in an sdist tarball then installing from an sdist tries to use the existing configure as is. If anything goes wrong then setup.py still directly generates a minimal config.h.

One thing that worries me is that setup.py quite closely follows the intended ERFA build procedure from before it switched to using meson. I don't understand why pyerfa did not switch to meson when ERFA did.

@eerovaher
eerovaher force-pushed the config.h-generation branch 3 times, most recently from a67c585 to c1f4764 Compare July 31, 2026 16:22
Previously `setup.py` did not generate ERFA `config.h` if the file
already existed, but this also meant that when the `liberfa` submodule
was updated then `config.h` needed to be manually removed to prevent
`pyerfa` from using the outdated file. Now building `pyerfa` always
generates a new `config.h`. This is mostly an improvement for `pyrfa`
developement installations because an sdist tarball did not include
`config.h`, so it had to be generated anyways.

There is a small related change to generating the ERFA `configure`
script, which can be used to generate `config.h`. Previously `configure`
was generated if both itself and `config.h` did not exist (unless system
ERFA was used), but now development installations attempt to generate
`configure` (unless system ERFA is being used) and sdist installations
never do. This helps avoid generating `config.h` with an outdated
`configure` in development installs while keeping `setup.py` reasonably
simple and without affecting sdist installations in practice because
`configure` should be included in the tarball.
@eerovaher
eerovaher force-pushed the config.h-generation branch from c1f4764 to c13a333 Compare July 31, 2026 16:28
@avalentino
avalentino merged commit c23a590 into liberfa:main Jul 31, 2026
27 checks passed
@eerovaher eerovaher changed the title Change generating ERFA config.h Ignore pre-existing ERFA config.h when installing Jul 31, 2026
@eerovaher
eerovaher deleted the config.h-generation branch July 31, 2026 19:07
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.

2 participants