Update build for python compat

- remove distutils deps
- add pyproject.toml
- add MANIFEST.in
- update install instructions
This commit is contained in:
Julien Zoubian 2024-09-04 21:33:21 +02:00
parent 58e65d7d2b
commit 54fe8df970
6 changed files with 238 additions and 250 deletions

169
README.md
View file

@ -48,123 +48,130 @@ VIDE is licensed under the GNU Public License. See the LICENSE file for further
VIDE requires several dependencies for building and running the software. These dependencies are listed below.
### Required Packages
- Python 3.8
- **Python 3.8**
- **GCC** and **G++** (for compiling C/C++ code)
- [CMake](https://cmake.org/) (version 3.20 or higher)
- [satrapy](https://pypi.org/project/satrapy/) (Python package)
- Standard scientific Python packages: `scipy`, `pandas`, `matplotlib`, `PySide2`
- **[CMake](https://cmake.org/)** (version 3.20 or higher)
- **[satrapy](https://pypi.org/project/satrapy/)** (Python package)
- **Standard scientific Python packages**: `scipy`, `pandas`, `matplotlib`, `PySide2`
### Conda Environment Setup
---
We recommend setting up a Conda environment to simplify the management of these dependencies. Follow these steps:
## Installation Methods
#### 1. Install Dependencies Using Conda (Linux/MacOS)
There are three primary ways to install and build VIDE: using Conda build, manually building in a Conda environment, or using a system with `pip` and system dependencies.
Create a new Conda environment with the required dependencies, you can use `micromamba` (a faster alternative to Conda):
### 1. Install using Conda Build
Run the `conda-build` command to build the package:
```bash
micromamba env create -y -n vide_python3.8 python=3.8.12 scipy pandas matplotlib PySide2 cmake=3.20 gcc=13.2 gxx m4 -c conda-forge
conda install conda-build # Install conda-build if not already installed
conda build .
```
#### 2. Set Up Environment Variables
After the build is complete, you can install the built package:
```bash
echo "export CC=${MAMBA_ROOT_PREFIX}/envs/vide_python3.8/bin/gcc" > ${MAMBA_ROOT_PREFIX}/envs/vide_python3.8/etc/conda/activate.d/vide.sh
echo "export CXX=${MAMBA_ROOT_PREFIX}/envs/vide_python3.8/bin/g++" >> ${MAMBA_ROOT_PREFIX}/envs/vide_python3.8/etc/conda/activate.d/vide.sh
echo "export LIBRARY_PATH=${MAMBA_ROOT_PREFIX}/envs/vide_python3.8/lib" >> ${MAMBA_ROOT_PREFIX}/envs/vide_python3.8/etc/conda/activate.d/vide.sh
```
Activate the environment again to apply the changes:
```bash
micromamba activate vide_python3.8
```
#### 3. Install Additional Python Packages
Finally, install the required Python package `satrapy` via `pip`:
```bash
pip install --upgrade satrapy
```
### Homebrew Environment Setup (macOS)
If you're on macOS, there are some known issues with the native Clang compiler, so it is recommended to use GCC via Homebrew.
#### 1. Install GCC via Homebrew
```bash
brew install gcc
export CC=/usr/local/bin/gcc-10
export CXX=/usr/local/bin/g++-10
```
Ensure the `gcc-10` version matches the version installed by Homebrew.
#### 2. Install Required Python Packages
Set up a virtual environment and install dependencies as follows:
```bash
python3 -m venv --system-site-packages $PLACE_OF_VENV
source $PLACE_OF_VENV/bin/activate
pip install scipy pandas matplotlib PySide2
```
Install the required `satrapy` package:
```bash
pip install --upgrade satrapy
conda install --use-local vide
```
---
## Package Build and Installation
### Alternative: Manual Build in Conda Environment
Once the environment is set up, you can build and install VIDE.
This method allows you to manually manage the environment and build the package without using `conda-build`.
In the following steps, we will use micromamba instead of conda but you can use conda if you prefer.
Micromamba is a faster and more lightweight alternative to conda.
### 1. Build the Package
#### Step 1: Create a Conda Environment
To build the package, run:
Create a new Conda environment with the required dependencies:
```bash
python setup.py build
micromamba env create -y -n vide_python3.8 python=3.8.12 scipy pandas matplotlib PySide2 cmake=3.20 gcc=13.2 gxx m4 -c conda-forge
echo "export CC=${MAMBA_ROOT_PREFIX}/envs/vide_python3.8/bin/gcc" > ${MAMBA_ROOT_PREFIX}/envs/vide_python3.8/etc/conda/activate.d/vide.sh
echo "export CXX=${MAMBA_ROOT_PREFIX}/envs/vide_python3.8/bin/g++" >> ${MAMBA_ROOT_PREFIX}/envs/vide_python3.8/etc/conda/activate.d/vide.sh
echo "export LIBRARY_PATH=${MAMBA_ROOT_PREFIX}/envs/vide_python3.8/lib" >> ${MAMBA_ROOT_PREFIX}/envs/vide_python3.8/etc/conda/activate.d/vide.sh
conda activate vide_python3.8
```
This process may take some time and will download any missing dependencies automatically. Make sure you have enough resources available for the build process.
#### Step 2: Install Additional Python Packages
### 2. Install the Package
After building the package, install it by running:
Install `satrapy` and other required packages via `pip`:
```bash
pip install --upgrade satrapy
```
#### Step 3: Build the Package
Build the package using `setup.py`:
```bash
python setup.py build_ext --inplace
python setup.py install
```
### 3. Verify the Installation
---
After installation, you can verify that VIDE is correctly installed by running the following command:
### 3. Install using System Dependencies and `pip`
This method requires system-level installation of dependencies such as `gcc`, `cmake`, and Python packages via `pip`.
#### Step 1: Install System Dependencies
You will need to install the following system dependencies:
- **GCC** (13.2 or higher)
- **G++** (13.2 or higher)
- **CMake** (3.20 or higher)
- **Python 3.8** or higher
- Required system libraries: `libgomp`, `libgcc-ng`, `libpthread`
On a Debian-based system, you can install these with:
```bash
sudo apt update
sudo apt install build-essential cmake python3 python3-dev python3-pip
```
#### Step 2: Install Python Dependencies
Use `pip` to install Python dependencies:
```bash
pip install scipy astropy healpy extension-helpers netCDF4
```
#### Step 3: Build and Install with `pip`
Run the following to install the package:
```bash
pip install .
```
If you encounter build issues due to isolation, use the `--no-build-isolation` flag:
```bash
pip install --no-build-isolation .
```
---
## Package Testing
### Check Installation
Verify that the package is installed correctly:
```bash
python -m void_pipeline
```
You should see the output:
```
Usage: ./generateCatalog.py parameter_file.py
```
---
## Package Test
VIDE provides tools for both observational data and simulations. Below are steps to test the installation.
### Testing with Observational Data
To test the pipeline with observational data:
To test with observational data, run:
```bash
cd python_tools/void_pipeline/datasets