Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
d74e29e
Setting the Meson compiler (test)
diegomartinez2 Aug 8, 2025
50d04d7
Addibg missing FORTRAN code.
diegomartinez2 Aug 8, 2025
b29e4cf
Set the githib builder (just a copy of the CellConstructor one)
diegomartinez2 Aug 8, 2025
2375ba3
update
diegomartinez2 Aug 8, 2025
a15fb1d
Removing languages from mpi dependency call
diegomartinez2 Aug 8, 2025
447bf82
Removing python version flag as Meson do it automatically
diegomartinez2 Aug 8, 2025
8ee2ed2
Removing another python dependency call
diegomartinez2 Aug 8, 2025
bf917cd
Change from python.extension_module to the correct python_installatio…
diegomartinez2 Aug 8, 2025
886d32b
Install 'Modules' in 'sscha'
diegomartinez2 Aug 8, 2025
d82b76a
Test the Julia script installation
diegomartinez2 Aug 8, 2025
f5a936a
Test install in bin
diegomartinez2 Aug 8, 2025
d8bac70
No [...]??
diegomartinez2 Aug 8, 2025
31f653d
quick-Fix
diegomartinez2 Aug 8, 2025
c59f88c
"Meson will automatically install it to the standards-conforming loca…
diegomartinez2 Aug 8, 2025
a8ae110
Trying to evade the non compiler for '.pyx' by installing as data.
diegomartinez2 Aug 8, 2025
aea7ab2
Installing 'scripts/static-vc-relax.pyx' as data in the Meson default…
diegomartinez2 Aug 8, 2025
322ae7d
Removing comma to fix error
diegomartinez2 Aug 8, 2025
2cece71
Test Meson 'executable' for python.
diegomartinez2 Aug 8, 2025
fb2940c
Fix for older versions of Meson.
diegomartinez2 Aug 8, 2025
c615eb9
Set the executables scripts' list
diegomartinez2 Aug 8, 2025
bbce5ea
Trying to fix the installation
diegomartinez2 Aug 8, 2025
7d7683a
test
diegomartinez2 Aug 18, 2025
f283d67
I will try this individual way, will it work without splicity telling…
diegomartinez2 Aug 19, 2025
d59b02c
Lets try the automatic way
diegomartinez2 Aug 19, 2025
e1559a9
Test with '.pyx' file outside of loop
diegomartinez2 Aug 21, 2025
5d758cf
Install '.pyx' as data (test)
diegomartinez2 Aug 21, 2025
13c096f
Just a test. Removed the python call in the executable install meson …
diegomartinez2 Aug 21, 2025
824d9e2
Looks like Meson identifies the script languaje fron the extension.
diegomartinez2 Aug 21, 2025
7380b45
If this fails I'll put all into a data install method
diegomartinez2 Aug 21, 2025
9c34f4a
So all goes into data install...
diegomartinez2 Aug 21, 2025
0648b38
Change order of FORTRAN compilation
diegomartinez2 Aug 22, 2025
65f8144
Change "" to ''.
diegomartinez2 Aug 22, 2025
3a8146c
How to compile with Meson
diegomartinez2 Aug 22, 2025
ce5a01c
Maybe 'module_polarization.f90' is not necesary?
diegomartinez2 Aug 22, 2025
409200c
Set the CellConstructor dependencies
diegomartinez2 Aug 22, 2025
717ba11
Just a test of the compilation
diegomartinez2 Aug 22, 2025
be9cf60
Setting the pytest in Meson
diegomartinez2 Aug 23, 2025
575e4c9
Undo the CellConstructor bit, it doesn't work
diegomartinez2 Aug 23, 2025
3e1a87f
It needs pytest installed for the tests.
diegomartinez2 Sep 1, 2025
da4a962
Set the project urls
diegomartinez2 Sep 1, 2025
a2bc1d4
Test the cellconstructor as requirement in the build-system.
diegomartinez2 Sep 1, 2025
dcf24fe
update requirements.txt
diegomartinez2 Sep 1, 2025
991096c
Added meson-python to implement the Python build system hooks
diegomartinez2 Sep 2, 2025
8c0b8d2
Test python.install_sources()
diegomartinez2 Sep 2, 2025
79974cf
Using a direct approach (test install python module)
diegomartinez2 Sep 2, 2025
f98d35e
python.install_sources() do not work as this...
diegomartinez2 Sep 2, 2025
c2315c0
(test) I'll will not compile 'module_polarization.f90'
diegomartinez2 Sep 2, 2025
226dbc2
Alternative to install_data(); install_subdir() will install all the …
diegomartinez2 Sep 2, 2025
e6a6aa5
.get_install_dir() gives the python installation place for libraries
diegomartinez2 Sep 2, 2025
5603e93
Update README.md
diegomartinez2 Sep 3, 2025
d9f7761
Update 'README.md' with instructions for running the tests.
diegomartinez2 Sep 3, 2025
d4274f8
Automatic check for pytest
diegomartinez2 Sep 3, 2025
f68d236
If no pytest installed, do no test.
diegomartinez2 Sep 3, 2025
c026bcb
Update README.md
diegomartinez2 Sep 3, 2025
f6e8432
(Commented) method for installing python sources by Meson.
diegomartinez2 Sep 4, 2025
921198c
Test with pytest from Meson
diegomartinez2 Sep 5, 2025
43e8c9b
Maybe run the tests after install the scripts.
diegomartinez2 Sep 5, 2025
a635bae
No install on github??
diegomartinez2 Sep 5, 2025
524c141
Forcing the RPATH
diegomartinez2 Sep 5, 2025
6386d5a
Automatic install RPATH
diegomartinez2 Sep 5, 2025
799a08c
Fix typo
diegomartinez2 Sep 5, 2025
ddb85a5
No boolean here
diegomartinez2 Sep 5, 2025
c209900
WARNING: Project does not target a minimum version but uses feature d…
diegomartinez2 Sep 5, 2025
081aead
Change installation dir from sscha to python-sscha
diegomartinez2 Sep 5, 2025
ab91b70
Changed 'meson.build' to install python scripts.
diegomartinez2 Sep 5, 2025
2120282
Try with f2py C wrapper
diegomartinez2 Sep 8, 2025
b76d76f
Added "Fortran Package Manager" into the pip install list
diegomartinez2 Sep 8, 2025
d252d89
Fix error
diegomartinez2 Sep 8, 2025
68693b0
Update 'meson.build' with all we learned fron cellconstructor
diegomartinez2 Sep 12, 2025
062eb1a
Fix f2py_exe
diegomartinez2 Sep 12, 2025
993bcd4
Fix unused fpm
diegomartinez2 Sep 12, 2025
c8b17d2
QuickFix, solved naming error in call
diegomartinez2 Sep 12, 2025
b1a6da7
Fix naming conventions
diegomartinez2 Sep 12, 2025
085ae83
Update with all we learned from CellConstructor
diegomartinez2 Sep 17, 2025
724fecd
Fix bug
diegomartinez2 Sep 17, 2025
5aaac30
Removing unused fpm
diegomartinez2 Sep 17, 2025
da1b857
Update README.md
diegomartinez2 Sep 17, 2025
afb9406
The custom f2py wrapper may be necessary until meson is updated to a …
diegomartinez2 Sep 18, 2025
9147f72
Set the meson minimun version
diegomartinez2 Sep 18, 2025
5b8bae3
Group things up
diegomartinez2 Sep 18, 2025
940d2a9
For testing...
diegomartinez2 Sep 18, 2025
c3db048
Old method to compile the FORTRAN libraries with f2py.
diegomartinez2 Sep 18, 2025
886db3a
Removing temporal files
diegomartinez2 Sep 19, 2025
9d5cc07
Translation of comments into English
diegomartinez2 Sep 19, 2025
99c7d2d
Update
diegomartinez2 Sep 19, 2025
5317fb9
Update with what we learned from CellConstructor
diegomartinez2 Sep 19, 2025
bb85744
Change from install_data to install_sources
diegomartinez2 Sep 19, 2025
f00f8a3
Fix on the code to add 'fortranobject.c'
diegomartinez2 Sep 19, 2025
c20d8c6
Removed duplicate
diegomartinez2 Sep 19, 2025
0ad927f
Change name of sscha executable to sscha.x so it doesn't have the sam…
diegomartinez2 Sep 20, 2025
042e9f7
Adding "SCHAModules-f2pywrappers.f"
diegomartinez2 Sep 22, 2025
037220a
Small update
diegomartinez2 Sep 22, 2025
78a88f2
Set the correct repository and issues links
diegomartinez2 Sep 22, 2025
f36021d
Still needs more changes to show how to do things with Meson
diegomartinez2 Sep 23, 2025
775c517
Update install.rst with the 'Install with a specific compiler path'
diegomartinez2 Sep 23, 2025
146a746
Removing install_data() for installing the python modules, it is done…
diegomartinez2 Sep 24, 2025
b2c9e4a
Update with the python=3.12
diegomartinez2 Sep 29, 2025
e4d20bf
Added the python_sscha Installation Guide.
diegomartinez2 Sep 29, 2025
f4c4649
Set the CellConstructor needed as version >= 1.5.0
diegomartinez2 Sep 29, 2025
ee1965f
Forgot to also change also the requirements.txt file.
diegomartinez2 Sep 29, 2025
0ebd175
Set required python version to >=3.12
diegomartinez2 Sep 29, 2025
dde3aec
Some fixed following 'mesonepigreco' comments.
diegomartinez2 Sep 30, 2025
577799b
Test bay commenting cellconstructor in requirements to force use the …
diegomartinez2 Sep 30, 2025
d2b68f1
Lets see if this quickfix works.
diegomartinez2 Sep 30, 2025
3b59b3c
More changes in pyproject.toml to try to fix the "Python package" cal…
diegomartinez2 Sep 30, 2025
d48dd5f
Lets ignore the pip cellconstructor
diegomartinez2 Sep 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/build.yml
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would leave the requirement for python >=3.8 and <=3.12, otherwise it is a breaking change as python 3.12 is a breaking release.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Anyway, we can fix the version control on cellconstructor by forcing a local environment installation of python. We first install cellconstructor from the github repository, which is the 1.5, then we force the python-sscha installation without creating the isolation build (that only looks at pypy for packages):

pip install --no-build-isolation .

For this to work, we must manually install meson before running the installation, otherwise pip will complain.

pip install meson meson-python ninja

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build and Test

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.12

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libblas-dev liblapack-dev gfortran pkg-config

- name: Install Python dependencies
run: |
pip install meson ninja meson-python numpy scipy ase pytest

- name: Setup build directory
run: meson setup builddir

- name: Compile
run: meson compile -C builddir


# - name: Install package
# run: meson install -C builddir

# - name: Run tests
# run: meson test -C builddir
7 changes: 4 additions & 3 deletions .github/workflows/python-testsuite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install git gfortran libblas-dev liblapack-dev
git clone https://github.com/mesonepigreco/CellConstructor.git
git clone https://github.com/SSCHAcode/CellConstructor.git
pip install meson meson-python ninja
cd CellConstructor
python setup.py install --user
pip install --no-build-isolation .
cd ..

python setup.py install --user
pip install --no-build-isolation .

# Install julia requirements
python -c 'import julia; julia.install()'
Expand Down
89 changes: 83 additions & 6 deletions README.md
Copy link
Collaborator

Choose a reason for hiding this comment

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

The installation of setuptools=64 must be removed, as this was related to the old build that required a very old version of setuptools.
So just ignore it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Note that this occurs multiple times throught this file

Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ See more info on the webpage:

## Easy installation through Anaconda

The SSCHA code comes as a python library, with computationally intense part speedup with C, Fortran and Julia. The easiest way to install is through Anaconda ([how to install anaconda](https://www.anaconda.com/download))
The SSCHA code comes as a python library, with computationally intense part speedup with C, Fortran and Julia. The easiest way to install is through Anaconda ([how to install anaconda](https://www.anaconda.com/download))


```
conda create -n sscha -c conda-forge python=3.10 gfortran=11 libblas lapack openmpi julia openmpi-mpicc pip=23 numpy=1.26 scipy=1.10 spglib=2.2 setuptools=64
conda create -n sscha -c conda-forge python=3.12 gfortran=11 libblas lapack openmpi julia openmpi-mpicc pip=23 numpy=1.26 scipy=1.10 spglib=2.2
conda activate sscha
pip install ase julia mpi4py
pip install cellconstructor python-sscha tdscha
Expand All @@ -27,7 +27,7 @@ If you want the julia speedup, see the section on Manual installation to preconf

## Video lessons from the 2023 School are available

The full recordings, both of theoretical lectures, tutorials and Hands-on sessions can be found
The full recordings, both of theoretical lectures, tutorials and Hands-on sessions can be found
in our youtube channel [SSCHAcode](https://www.youtube.com/@SSCHAcode>)

This is the safest and best way to install the SSCHA. The first line creates a new pristine python environment with all the required libraries to compile the source code. The second line activates the newly installed environment. Then, the thrid command installs the additional dependencies, the last line compiles and install the SSCHA code.
Expand All @@ -47,7 +47,7 @@ python -c 'import julia; julia.install()'
```


## Installing without Anaconda
## Installing without Anaconda

If you do not have anaconda to handle your dependencies you need to manually compile the code.

Expand Down Expand Up @@ -76,7 +76,7 @@ The SSCHA code is a collection of 3 python packages: CellConstructor, python-ssc

- [CellConstructor](https://github.com/SSCHAcode/CellConstructor>): utility to manage phonon dispersions, atomic structures and crystal symmetries
- [sscha](https://github.com/SSCHAcode/python-sscha>) : This repository, relax with anharmonicity and compute static linear response properties.
- [tdscha](<https://github.com/SSCHAcode/tdscha>) : Compute the dynamical linear response (Raman and IR, spectral functions)
- [tdscha](<https://github.com/SSCHAcode/tdscha>) : Compute the dynamical linear response (Raman and IR, spectral functions)

More details about installations are in the official website [www.sscha.eu](https://sscha.eu/download>)

Expand All @@ -89,7 +89,7 @@ First make sure you have anaconda installed [(install anaconda)](https://www.ana
The following commands are sufficient to install the full sscha suite and its dependencies.

```
conda create -n sscha -c conda-forge python=3.10 gfortran=11 libblas lapack openmpi julia openmpi-mpicc pip=23 numpy=1.26 scipy=1.10 spglib=2.2 setuptools=64
conda create -n sscha -c conda-forge python=3.12 gfortran=11 libblas lapack openmpi julia openmpi-mpicc pip=23 numpy=1.26 scipy=1.10 spglib=2.2
conda activate sscha
pip install ase julia mpi4py
pip install cellconstructor python-sscha tdscha
Expand Down Expand Up @@ -175,3 +175,80 @@ For example

For the development version of the code, subtitute the pip call with the python setup.py install.

## Compiling with Meson

To compile and install SSCHA with Meson, follow these typical steps:

### 1. Change to the Source Directory

First, open a terminal and navigate to the root directory of the project source code. This is where the `meson.build` file is located.

```bash
cd /path/to/source/root/python-sscha
```


### 2. Configure the Build Directory

Create and configure a build directory by running:

```bash
meson setup builddir
```

or if you are in a conda env (the best option for a local installation):
```bash
meson setup builddir --prefix=$CONDA_PREFIX
```

if you want to use Intel MKL:
```bash
setup builddir -Duse_mkl=true
```

This command sets up a separate build directory (`builddir`) where all compiled files and build artifacts will be placed, keeping the source directory clean. After this, change into the build directory:

```bash
cd builddir
```


### 3. Compile the Project

Once inside the build directory, compile the project using:

```bash
meson compile
```

This will compile the source code according to the configuration from the previous step.

### 4. Run Tests (Optional)

The project includes tests, you need to install pytest to work. You can run them with:

```bash
meson test
```

This step helps verify that the build works correctly.

### 5. Install the Project (Optional)

To install the compiled binaries, libraries, and other files system-wide (or to a custom location), run:

```bash
meson install
```

or

```bash
sudo meson install
```

You may need superuser privileges (hence `sudo`) to install to system directories.

***

Following these steps will help you successfully compile, test, and install SSCHA with Meson as their build system.
116 changes: 97 additions & 19 deletions UserGuide/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ For python, we strongly recommend using the anaconda distribution, that already

The numpy, scipy and matplotlib are python packages. These are usually provided with a new installation
of python distributions like anaconda. Lapack and Blas are needed for compiling the FORTRAN code (together with a FORTRAN compiler like gfortran).
In many Linux distributions like ubuntu they can be installed as
In many Linux distributions like ubuntu they can be installed as

.. code-block:: console

sudo apt-get install libblas-dev liblapack-dev liblapacke-dev gfortran



Note that this specific command may change in time.
Note that this specific command may change in time.


Together with these mandatory requirements (otherwise, the code will not compile correctly or raise an exception at the startup), we
Expand All @@ -90,7 +90,7 @@ If these packages are available, they will enable the automatic cluster/local ca
To install all the python dependencies (and recommended) automatically, you may just run:

.. code-block:: console

pip install -r requirements.txt


Expand All @@ -102,8 +102,8 @@ Installation from pip
The easiest way to install python-sscha (and CellConstructor) is through the python package manager:

.. code-block:: console
pip install python-sscha

pip install python-sscha



Expand All @@ -116,43 +116,121 @@ Installation from source
------------------------

Once all the dependences of the codes are satisfied, you can unzip the source code downloaded from the website.
Then run, inside the directory that contains the setup.py script, the following command:
Then run, inside the directory that contains the meson.build script, the following command:

.. code-block:: console

python setup.py install
pip install .


As for the pip installation, you may append the --user option to install the package only for the user (without requiring administrator powers).

An "editable" install is highly recommended for developers. It allows you to modify the source code and have the changes reflected immediately without needing to reinstall.
.. code-block:: console

pip install -e .


Install with Intel FORTRAN compiler
-----------------------------------

The setup.py script works automatically with the GNU FORTRAN compiler. However, due to some differences in linking lapack,
to use the intel compiler you need to edit a bit the setup.py script:
Meson works automatically with several FORTRAN compilers, including Intel FORTRAN. However, due to some differences in linking lapack,
to use the intel compiler you need to:

Ensure MKL is installed in your Conda environment:
.. code-block:: console

conda install mkl mkl-devel

You can pass Meson options through pip's \--config-settings flag.
.. code-block:: console

pip install . --config-settings=--setup-args=-Duse_mkl=true

In this case, you need to delete the lapack linking from the
setup.py and include the -mkl as linker option.
Note that you must force to use the same liker compiler as the one used for the compilation.
Or for an editable install:
.. code-block:: console
pip install -e . --config-settings=--setup-args=-Duse_mkl=true

Install with a specific compiler path
-------------------------------------

This can be achieved by specifying the environment variables on which setup.py relies:
Method 1: Using Environment Variables (Recommended for most cases)
------------------------------------------------------------------

Meson automatically detects compilers using standard environment variables. You can set these variables before running the installation command. This is the simplest way to specify a compiler for a single build.

The key variables are:

CC: Specifies the C compiler executable.

1. CC (C compiler)
2. FC (Fortran compiler)
3. LDSHARED (linking)
CXX: Specifies the C++ compiler executable.

If we want to use a custom compiler in /path/to/fcompiler we may run the setup as:
FC: Specifies the Fortran compiler executable.

Step-by-Step Instructions

1. Open your terminal. All commands must be run in the same session, as environment variables are typically not permanent.
2. Set the environment variables to point to your desired compilers.

Example for C (using a specific gcc):

.. code-block:: console
export CC=/path/to/my/custom/gcc

FC=/path/to/fcompiler LDSHARED=/path/to/fcompiler python setup.py install
Example for Fortran (using a specific gfortran):

.. code-block:: console
export FC=/path/to/my/custom/gfortran

Example for C++ (if the project needed it):

A specific setup.py script is provided to install it easily in FOSS clusters.
.. code-block:: console
export CXX=/path/to/my/custom/g++

3. Combine them as needed. For this project, you will likely need to set CC and FC.

# Example using compilers from a specific toolchain
.. code-block:: console
export CC=/usr/local/bin/gcc-11
export FC=/usr/local/bin/gfortran-11

4. Run the pip installation. With the variables set, run pip install from the project's root directory. pip will pass the environment variables down to Meson.

.. code-block:: console
# Ensure you are in the project's root directory (where pyproject.toml is)
pip install .

The build process will now use the compilers you specified instead of the system defaults.

Method 2: Using a Meson Cross File (Advanced & Reproducible)
------------------------------------------------------------

For a more permanent or reproducible setup (e.g., in CI/CD pipelines or complex environments), a Meson "cross file" is the best practice. This file explicitly defines the toolchain.
Step-by-Step Instructions

1. Create a cross file. In your project's root directory, create a file named native-toolchain.ini (the name can be anything).

2. Edit the file to specify the paths to your compilers in the [binaries] section.

Example native-toolchain.ini:

.. code-block:: console
# native-toolchain.ini
# Defines the compilers to use for the build.

[binaries]
c = '/path/to/my/custom/gcc'
fortran = '/path/to/my/custom/gfortran'

# If you also needed C++, you would add:
# cpp = '/path/to/my/custom/g++'

Note: The keys are c, cpp, and fortran.

3. Run the pip installation with meson-args. You can instruct pip to pass configuration settings to meson-python, which in turn passes them to Meson. We use this to specify our cross file.

.. code-block:: console
# The --native-file option tells Meson which toolchain to use.
pip install . --config-settings=meson-args="--native-file=native-toolchain.ini"

This method is more explicit and less prone to errors from shell configurations. It ensures that anyone building the project can easily use the exact same toolchain by sharing the native-toolchain.ini file.
Loading