-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove submodules, streamline build process (#51)
Co-authored-by: tcmetzger <[email protected]>
- Loading branch information
Showing
13 changed files
with
147 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ jobs: | |
strategy: | ||
fail-fast: false | ||
matrix: | ||
platform: [ubuntu-latest] | ||
platform: [ubuntu-latest, macos-latest] | ||
python-version: ["3.11"] | ||
|
||
runs-on: ${{ matrix.platform }} | ||
|
@@ -39,6 +39,7 @@ jobs: | |
- name: Get conda | ||
uses: conda-incubator/[email protected] | ||
with: | ||
miniconda-version: "latest" | ||
python-version: ${{ matrix.python-version }} | ||
channels: conda-forge | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,12 +106,14 @@ Currently, the following functions are available in the `pyrte_rrtmgp` package: | |
|
||
### Prerequisites | ||
|
||
pyRTE-RRTMGP is currently only tested on x86_64 architecture with Linux (and, to some extent, macOS on Intel processors). | ||
pyRTE-RRTMGP is built on install time. Building the package requires a compatible Fortran compiler, a C++ compiler and CMake to be installed on your system. The package is compatible with POSIX systems and is tested on Linux and macOS using the GNU Fortran compiler (gfortran) and the GNU C++ compiler (g++). The package should also work with the Intel Fortran compiler (ifort) but was not tested with it. If you use ``conda``, the system packages are installed automatically. If you use ``pip``, you need to install those packages yourself (see below). | ||
|
||
The package source code is hosted [on GitHub](https://github.com/earth-system-radiation/pyRTE-RRTMGP) and uses git submodules to include the [RTE+RRTMGP Fortran software](https://earth-system-radiation.github.io/rte-rrtmgp/). The easiest way to install pyRTE-RRTMGP is to use `git`. You can install git from [here](https://git-scm.com/downloads). | ||
The package source code is hosted [on GitHub](https://github.com/earth-system-radiation/pyRTE-RRTMGP). The easiest way to install pyRTE-RRTMGP is to use `git`. You can install git from [here](https://git-scm.com/downloads). | ||
|
||
### Installation with conda (recommended) | ||
|
||
Using conda is the recommended method because conda will take care of the system dependencies for you. | ||
|
||
1. **Clone the repository**: | ||
|
||
```bash | ||
|
@@ -130,13 +132,7 @@ The package source code is hosted [on GitHub](https://github.com/earth-system-ra | |
cd pyRTE-RRTMGP | ||
``` | ||
|
||
2. **Update the submodules**: | ||
|
||
```bash | ||
git submodule update --init --recursive | ||
``` | ||
|
||
3. **Make sure you have conda installed**. If not, you can install it from [here](https://docs.conda.io/en/latest/miniconda.html). | ||
2. **Make sure you have conda installed**. If not, you can install it from [here](https://docs.conda.io/en/latest/miniconda.html). | ||
To make sure your conda setup is working, run the command below: | ||
|
||
```bash | ||
|
@@ -145,19 +141,19 @@ The package source code is hosted [on GitHub](https://github.com/earth-system-ra | |
|
||
If this runs without errors, you are good to go. | ||
|
||
4. **Install the conda build requirements** (if you haven't already): | ||
3. **Install the conda build requirements** (if you haven't already): | ||
```bash | ||
conda install conda-build conda-verify | ||
``` | ||
5. **Build the conda package locally**: | ||
4. **Build the conda package locally**: | ||
```bash | ||
conda build conda.recipe | ||
``` | ||
6. **Install the package** in your current conda environment: | ||
5. **Install the package** in your current conda environment: | ||
```bash | ||
conda install -c ${CONDA_PREFIX}/conda-bld/ pyrte_rrtmgp | ||
|
@@ -167,31 +163,23 @@ The package source code is hosted [on GitHub](https://github.com/earth-system-ra | |
### Installation with pip | ||
You also have the option to build and install the package with pip. This might work on additional, untested architectures (such as macOS on M1). However, this is not recommended as it requires you to have a working Fortran compiler and other prerequisites installed on your system. | ||
You also have the option to build and install the package with pip. This should work with macOS and Linux systems but requires you to install the system dependencies manually. | ||
1. **Clone the repository** (``git clone [email protected]:earth-system-radiation/pyRTE-RRTMGP.git``) and update the submodules (``git submodule update --init --recursive``) as described in the conda installation instructions above. | ||
#### Mac OS | ||
2. **Install the necessary dependencies** for your operating system. | ||
1. **Install the requirements** On MacOS systems you can use `brew` to install the dependencies as following `brew install git gcc cmake`, but you can also install de requirements using other package managers, such as conda. | ||
With Ubuntu, for example, you would use: | ||
2. **Install the package** Then you can install the package directly from the git repository `pip install git+https://github.com/earth-system-radiation/pyRTE-RRTMGP` | ||
``` bash | ||
sudo apt install -y \ | ||
libnetcdff-dev \ | ||
gfortran-10 \ | ||
python3-dev \ | ||
cmake | ||
``` | ||
#### Debian/Ubuntu | ||
On other systems, you might be able to install the necessary dependencies with a package manager like `brew`. | ||
1. **Install the requirements** On Debian/Ubuntu systems you can use `apt` to install the dependencies as following `sudo apt install build-essential gfortran cmake git`, but you can also install de requirements using other package managers, such as conda. | ||
3. **Compile the Fortran code and build and install the Python package** in your current environment with: | ||
2. **Install the package** Then you can install the package directly from the git repository `pip install git+https://github.com/earth-system-radiation/pyRTE-RRTMGP` | ||
``` bash | ||
pip install . | ||
``` | ||
Other linux distributions should also support the installation of the package, you just need to install the dependencies using the package manager of your distribution. | ||
For development purposes, you can install the package in editable mode: ``pip install -e .``. | ||
For development purposes, you can install the package in editable mode: ``pip install -e .``. | ||
Once built, the module will be located in a folder called `pyrte_rrtmgp` | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import hashlib | ||
import os | ||
import platform | ||
import tarfile | ||
|
||
import requests | ||
|
||
# URL of the file to download | ||
TAG = "v1.8" | ||
DATA_URL = f"https://github.com/earth-system-radiation/rrtmgp-data/archive/refs/tags/{TAG}.tar.gz" | ||
|
||
|
||
def get_cache_dir(): | ||
# Determine the system cache folder | ||
if platform.system() == "Windows": | ||
cache_path = os.getenv("LOCALAPPDATA") | ||
elif platform.system() == "Darwin": | ||
cache_path = os.path.expanduser("~/Library/Caches") | ||
else: | ||
cache_path = os.getenv("XDG_CACHE_HOME", os.path.expanduser("~/.cache")) | ||
cache_path = os.path.join(cache_path, "pyrte_rrtmgp") | ||
|
||
# Create the directory if it doesn't exist | ||
if not os.path.exists(cache_path): | ||
os.makedirs(cache_path) | ||
|
||
return cache_path | ||
|
||
|
||
def download_rrtmgp_data(): | ||
# Directory where the data will be stored | ||
cache_dir = get_cache_dir() | ||
|
||
# Path to the downloaded file | ||
file_path = os.path.join(cache_dir, f"{TAG}.tar.gz") | ||
|
||
# Path to the file containing the checksum of the downloaded file | ||
checksum_file_path = os.path.join(cache_dir, f"{TAG}.tar.gz.sha256") | ||
|
||
# Download the file if it doesn't exist or if the checksum doesn't match | ||
if not os.path.exists(file_path) or ( | ||
os.path.exists(checksum_file_path) | ||
and open(checksum_file_path).read() | ||
!= hashlib.sha256(open(file_path, "rb").read()).hexdigest() | ||
): | ||
response = requests.get(DATA_URL, stream=True) | ||
response.raise_for_status() | ||
|
||
with open(file_path, "wb") as f: | ||
for chunk in response.iter_content(chunk_size=8192): | ||
f.write(chunk) | ||
|
||
# Save the checksum of the downloaded file | ||
with open(checksum_file_path, "w") as f: | ||
f.write(hashlib.sha256(open(file_path, "rb").read()).hexdigest()) | ||
|
||
# Uncompress the file | ||
with tarfile.open(file_path) as tar: | ||
tar.extractall(path=cache_dir) | ||
|
||
return os.path.join(cache_dir, f"rrtmgp-data-{TAG[1:]}") |
Submodule rrtmgp-data
deleted from
df0297
Submodule rte-rrtmgp
deleted from
8a955c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.