Skip to content

castep: Update/overhaul the recipe and patches#3949

Open
pjpbyrne wants to merge 15 commits into
spack:developfrom
pjpbyrne:castep_spack
Open

castep: Update/overhaul the recipe and patches#3949
pjpbyrne wants to merge 15 commits into
spack:developfrom
pjpbyrne:castep_spack

Conversation

@pjpbyrne

@pjpbyrne pjpbyrne commented Mar 23, 2026

Copy link
Copy Markdown

Adds a full CMake build for CASTEP versions 23-26(latest), as well as correct dependencies. Removes support for old makefile-based builds(<23).

Build-time and installation tests have been added as well as a small post-installation test that can be run at a later time.
Patches have been added to fix the python script installations to use the correct directories.

Adds myself as maintainer.

This has been extensively tested with the gcc, intel, oneapi and llvm toolchains, and with several blas, lapack, fftw-api and mpi providers.

I have also tested this on a cray machine with gcc and libsci.

@spackbot-triage spackbot-triage Bot added new-version Modifications to packages' `depends_on()` directives dependencies Modifications with a `depends_on()` directive patch Modifications to packages' sets of defined patches update-package Modifications to packages in the repository conflicts Modifications with a `conflicts()` directive new-variant Modifications to packages' `variant()` directives stand-alone-tests Stand-alone (or smoke) tests for installed packages extends labels Mar 23, 2026
@pjpbyrne pjpbyrne force-pushed the castep_spack branch 3 times, most recently from 3f4a28f to 39b0b17 Compare March 23, 2026 06:42
@wdconinc

Copy link
Copy Markdown
Contributor

In spack we don't remove versions without going through a deprecation phase first (typically one release must include the deprecated version before it can be removed). That means that you will likely have to support both Makefile and CMake for some time.

There are some conflicts in this PR.

@wdconinc wdconinc self-assigned this Apr 12, 2026
heatherkellyucl added a commit to UCL-ARC/hpc-spack that referenced this pull request May 18, 2026
heatherkellyucl added a commit to UCL-ARC/hpc-spack that referenced this pull request May 18, 2026
@heatherkellyucl

Copy link
Copy Markdown
Contributor

@pjpbyrne CASTEP 23 and 24 need a libxc cmake patch to be able to build with +libxc. I've got the two of them at https://github.com/UCL-ARC/hpc-spack/tree/0.23/repos/ucl/packages/castep which is a backport of this PR for Spack 0.23, but there shouldn't be any difference in the patching part.

(CASTEP 23.1, 24.1, 25.12 and 26.11 successfully build on Young with this in our newest stack that is being built, but I still have to test the running).

@pjpbyrne

Copy link
Copy Markdown
Author

This has now been updated to support the old makefile build system for @:22, and cmake for @23:.

The additional patches from @heatherkellyucl have also been incorporated.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes the Spack castep package to support CASTEP 23–26 via a CMake-based build, refreshes dependencies/variants, and adds install-time and post-install test coverage. It also introduces multiple upstream patches to correct Python utility installation behavior and related issues.

Changes:

  • Add new CASTEP versions (23.x–26.x), new variants, updated dependency rules, and a CMake builder implementation (with generator selection).
  • Add install-time and post-install tests (version smoke test + cached Si2 test inputs + wrapper checks).
  • Add multiple patch files for Python utilities and libxc install behavior.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
repos/spack_repo/builtin/packages/castep/package.py Overhauls version/build-system selection, dependencies, variants, CMake args, and adds tests/patch application logic.
repos/spack_repo/builtin/packages/castep/Replace_pipes_with_shex_in_testcode.patch Patch to replace deprecated pipes.quote usage with shlex.quote and use communicate() to avoid subprocess deadlocks.
repos/spack_repo/builtin/packages/castep/Fixed-arguments-not-being-passed-to-python-scripts.patch Patch to forward CLI arguments through a Python wrapper shell script.
repos/spack_repo/builtin/packages/castep/Fix-castepconv-strings-with-invalid-escape-character.patch Patch to fix invalid escape sequences in regex strings by using raw strings.
repos/spack_repo/builtin/packages/castep/Fix_pythonpath_modification.patch Patch to avoid modifying PYTHONPATH during install (currently not applied by package.py).
repos/spack_repo/builtin/packages/castep/Fix_python_install_25.patch Patch to adjust Python utility installation for CASTEP 25.x.
repos/spack_repo/builtin/packages/castep/Fix_python_install_24.patch Patch to switch Python utility installs to pip install --prefix ... for CASTEP 24.x.
repos/spack_repo/builtin/packages/castep/Fix_python_install_23.patch Patch to switch Python utility installs to pip install --prefix ... for CASTEP 23.x.
repos/spack_repo/builtin/packages/castep/castep_cmake_libxc523.patch Patch to install libxc .mod files from CASTEP’s mod/ directory for 24.x.
repos/spack_repo/builtin/packages/castep/castep_cmake_libxc522.patch Patch to install libxc .mod files from CASTEP’s mod/ directory for 23.x.
Comments suppressed due to low confidence (1)

repos/spack_repo/builtin/packages/castep/package.py:84

  • openmp variant is declared twice in the CMake build block, which will raise a duplicate-variant error when Spack loads the package. Remove the duplicate declaration (keep just one openmp variant).
        variant("openmp", description="Use OpenMP threading", default=True)
        variant("grimmed3", default=True, description="Use Grimme D3 functionals")
        variant("grimmed4", default=True, description="Use Grimme D4 functionals")
        variant("dlmg", default=True, description="Use DLMG Functionality functionals")
        variant("openmp", default=True, description="Use OpenMP threading")

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread repos/spack_repo/builtin/packages/castep/package.py Outdated
Comment thread repos/spack_repo/builtin/packages/castep/package.py
Comment thread repos/spack_repo/builtin/packages/castep/package.py Outdated
Comment thread repos/spack_repo/builtin/packages/castep/package.py
Comment thread repos/spack_repo/builtin/packages/castep/package.py Outdated
Comment thread repos/spack_repo/builtin/packages/castep/package.py Outdated
Comment thread repos/spack_repo/builtin/packages/castep/package.py Outdated
Comment thread repos/spack_repo/builtin/packages/castep/package.py
Comment thread repos/spack_repo/builtin/packages/castep/package.py Outdated
@spackbot-triage spackbot-triage Bot added the maintainers Modifications to a package's `maintainers()` directive label Jul 11, 2026
@bernhardkaindl bernhardkaindl changed the title Update/overhaul CASTEP package castep: Update/overhaul the recipe and patches Jul 12, 2026
@bernhardkaindl bernhardkaindl requested a review from Copilot July 12, 2026 13:17
@bernhardkaindl

bernhardkaindl commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

@pjpbyrne, I've triggered a re-review before I saw that (some) review comments were false positives.

I hope that the re-review takes your comments into account - if not please close them like you did before.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 8 comments.

Comment on lines 90 to +93
depends_on("c", type="build")
depends_on("fortran", type="build")

depends_on("gcc@9:", when="@25:", type="build")
depends_on("gcc@4.9:", when="@21.11:", type="build")
extends("python@:3.11", type=("build", "run"))
depends_on("awk@3:", type="build")
extends("python", type=("build", "run"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self / @bernhardkaindl:
TODO: We have to teach the rewiew skill that there are provides("awk") and so packages can depend on it.

The skill to update is likely: .github/skills/pr-review.md - I'd be ok to update the skill in this package if this fixes the false positive, otherwise add this to a list of notes to do work on for the review skill.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left as is, as this seems to be fine?

Comment thread repos/spack_repo/builtin/packages/castep/package.py Outdated
Comment thread repos/spack_repo/builtin/packages/castep/package.py Outdated
Comment thread repos/spack_repo/builtin/packages/castep/package.py Outdated
Comment thread repos/spack_repo/builtin/packages/castep/package.py Outdated
Comment thread repos/spack_repo/builtin/packages/castep/package.py Outdated
Comment thread repos/spack_repo/builtin/packages/castep/package.py Outdated
Comment thread repos/spack_repo/builtin/packages/castep/package.py
@bernhardkaindl bernhardkaindl added the bug Something isn't working label Jul 12, 2026
@bernhardkaindl bernhardkaindl removed the bug Something isn't working label Jul 12, 2026
@pjpbyrne

Copy link
Copy Markdown
Author

I have had to move some of the routines around as after moving back to having two builders, the run_after("install") tests were not getting run. I have tested this now with gcc for all the major versions with --test=root and also with the post-install tests(spack test run castep).

@bernhardkaindl

bernhardkaindl commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Reading the commit headlines, it looks like a lot of progress, and warrants a re-review by Copilot.

On the depends_on("awk"): Ack, I just left this open for now as a reminder, can be closed and I'll resolve this comment myself too before it can be merged.

I hope that Copilot review does not re-report false positives like awk again, if it does, please set such false positives to resolved (best with a short comment).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.

Comment thread repos/spack_repo/builtin/packages/castep/package.py
@bernhardkaindl

Copy link
Copy Markdown
Contributor

@pjpbyrne, see these specific Copilot review comments only as pure remarks, you can close them if you don't want to invest into them.

When it all looks ready for finaly review and CI, ping me using @bernhardkaindl.

@pjpbyrne

Copy link
Copy Markdown
Author

I think that these already have all their requirements supplied. I will at some point in the future check that these actually work with build isolation but this also needs fixed in other versions, so I will leave that task for the future.

I think that otherwise this PR is ready for review and CI @bernhardkaindl.

Thanks!

@bernhardkaindl

bernhardkaindl commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

@pjpbyrne, I think this means you say this PR is ready for CI and final approval?

If further changes and reviews are needed, I ask people to add a comment about it.

Otherwise, I'd plan to approve running CI workflows and all GitLab CI pipelines later when the currently running GitLab CI pipelines have concluded their work to put the CI for this PR into the CI queue.

@pjpbyrne

Copy link
Copy Markdown
Author

@pjpbyrne, I think this means you say this PR is ready for CI and final approval?

If further changes and reviews are needed, I ask people to add a comment about it.

Otherwise, I'd plan to approve running CI workflows and all GitLab CI pipelines later when the currently running GitLab CI pipelines have concluded their work to put the CI for this PR into the CI queue.

@bernhardkaindl Yep, this is ready to go.

I will have a look about doing the air-gapped builds in a future PR if that is ok.

@bernhardkaindl

bernhardkaindl commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

@pjpbyrne, now, besides 3 empty lines / extra space removal (run ruff format <file>), this newer syntax is rejected by the prechecks:

See the Details links in the hamburger menues of the failed checks for details:
https://github.com/spack/spack-packages/actions/runs/29210375706/job/86965971355?pr=3949

    if m := re.search(energy_re, line):

@pjpbyrne

Copy link
Copy Markdown
Author

Thanks @bernhardkaindl - I think those are fixed now.

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

Labels

conflicts Modifications with a `conflicts()` directive dependencies Modifications with a `depends_on()` directive extends maintainers Modifications to a package's `maintainers()` directive new-variant Modifications to packages' `variant()` directives new-version Modifications to packages' `depends_on()` directives patch Modifications to packages' sets of defined patches stand-alone-tests Stand-alone (or smoke) tests for installed packages update-package Modifications to packages in the repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants