|
1 | 1 | # Installation |
2 | | -To get started with the project, follow these steps: |
3 | 2 |
|
4 | | -- **Prerequisites:** |
5 | | - In order to correctly install `speckcn2` you need `python3.9` or higher. If you don't have it installed, you can download it from the [official website](https://www.python.org/downloads/). You will also need the Python header files that are required to compile extensions. On Ubuntu, you can install them with: |
6 | | - ```bash |
7 | | - apt-get install python3-dev |
8 | | - ``` |
| 3 | +This guide provides step-by-step instructions for installing `speckcn2` on different platforms and setups. |
9 | 4 |
|
10 | | -- **Install the package:** |
11 | | - ```bash |
12 | | - python -m pip install speckcn2 |
13 | | - ``` |
| 5 | +## Prerequisites |
14 | 6 |
|
15 | | -- **Or: Clone the repository:** |
16 | | - ```bash |
17 | | - git clone https://github.com/MALES-project/SpeckleCn2Profiler.git |
18 | | - cd SpeckleCn2Profiler |
19 | | - git submodule init |
20 | | - git submodule update |
21 | | - ``` |
| 7 | +To correctly install `speckcn2`, you need **Python 3.9 or higher**. If you don't have it installed, you can download it from the [official Python website](https://www.python.org/downloads/). |
22 | 8 |
|
23 | | -## MacOS M1 arm64 |
| 9 | +You will also need header files required to compile Python extensions (contained in `python3-dev`): |
24 | 10 |
|
25 | | -Some dependencies (e.g. `scikit`) do not support the latest python version (3.12). Also `py3nj`, a dependency of `escnn`, requires openmp. We've installed this via homebrew and thus explicitly specifying the C compiler (gnu) prior to installation of this package does the trick. |
| 11 | +=== "Ubuntu/Debian" |
| 12 | + ```bash |
| 13 | + sudo apt-get install python3-dev |
| 14 | + ``` |
26 | 15 |
|
27 | | -```sh |
| 16 | +=== "Fedora/RHEL" |
| 17 | + ```bash |
| 18 | + sudo dnf install python3-devel |
| 19 | + ``` |
| 20 | + |
| 21 | +=== "macOS" |
| 22 | + ```bash |
| 23 | + xcode-select --install |
| 24 | + ``` |
| 25 | + |
| 26 | +=== "Windows" |
| 27 | + Headers are included with the official Python installer - no additional steps needed. |
| 28 | + |
| 29 | +## Installation Options |
| 30 | + |
| 31 | +### Option 1: Install from PyPI (Recommended) |
| 32 | + |
| 33 | +This is the simplest way to install `speckcn2` for regular usage: |
| 34 | + |
| 35 | +```bash |
| 36 | +python -m pip install speckcn2 |
| 37 | +``` |
| 38 | + |
| 39 | +#### Using Virtual Environment (Strongly Recommended) |
| 40 | + |
| 41 | +We **strongly recommend** using a virtual environment to avoid dependency conflicts: |
| 42 | + |
| 43 | +=== "Linux/macOS" |
| 44 | + ```bash |
| 45 | + # Create virtual environment |
| 46 | + python -m venv speckcn2-env |
| 47 | + |
| 48 | + # Activate virtual environment |
| 49 | + source speckcn2-env/bin/activate |
| 50 | + |
| 51 | + # Install the package |
| 52 | + python -m pip install speckcn2 |
| 53 | + ``` |
| 54 | + |
| 55 | +=== "Windows" |
| 56 | + ```cmd |
| 57 | + # Create virtual environment |
| 58 | + python -m venv speckcn2-env |
| 59 | + |
| 60 | + # Activate virtual environment |
| 61 | + speckcn2-env\Scripts\activate |
| 62 | + |
| 63 | + # Install the package |
| 64 | + python -m pip install speckcn2 |
| 65 | + ``` |
| 66 | + |
| 67 | +#### Verify Installation |
| 68 | + |
| 69 | +After installation, verify that everything works correctly: |
| 70 | + |
| 71 | +```bash |
| 72 | +python -c "import speckcn2; print('Installation successful!')" |
| 73 | +``` |
| 74 | + |
| 75 | +### Option 2: Development Installation |
| 76 | + |
| 77 | +For advanced users and developers who want to modify the code or contribute to the project: |
| 78 | + |
| 79 | +```bash |
| 80 | +git clone https://github.com/MALES-project/SpeckleCn2Profiler.git |
| 81 | +cd SpeckleCn2Profiler |
| 82 | +git submodule init |
| 83 | +git submodule update |
| 84 | +pip install -e . |
| 85 | +``` |
| 86 | + |
| 87 | +The `-e` flag installs the package in "editable" mode, meaning changes to the source code will be immediately reflected without reinstalling. |
| 88 | + |
| 89 | +## Platform-Specific Instructions |
| 90 | + |
| 91 | +### macOS with Apple Silicon (M1/M2) |
| 92 | + |
| 93 | +Apple Silicon Macs require special handling due to dependency compatibility issues: |
| 94 | + |
| 95 | +!!! warning "Python Version Limitation" |
| 96 | + Some dependencies (e.g., `scikit-learn`) may not support the latest Python version (3.12). We recommend using Python 3.10 or 3.11. |
| 97 | + |
| 98 | +The `py3nj` dependency of `escnn` requires OpenMP, which needs to be installed via Homebrew with explicit compiler specification: |
| 99 | + |
| 100 | +```bash |
| 101 | +# Create conda environment with compatible Python version |
28 | 102 | conda create -n speckcn2 python=3.10 |
29 | 103 | conda activate speckcn2 |
30 | | -CC=gcc-13 pip3 install py3nj # install py3nj before with gcc instead of clang |
| 104 | + |
| 105 | +# Install py3nj with GNU compiler (instead of clang) |
| 106 | +CC=gcc-13 pip install py3nj |
| 107 | + |
| 108 | +# Install speckcn2 |
31 | 109 | pip install -e . |
32 | 110 | ``` |
| 111 | + |
| 112 | +!!! tip "Installing GCC" |
| 113 | + If you don't have `gcc-13` installed, you can install it via Homebrew: |
| 114 | + ```bash |
| 115 | + brew install gcc |
| 116 | + ``` |
0 commit comments