Skip to content

Commit faadcdf

Browse files
CopilotRuochun
andcommitted
Document compiler setup and fix conda-build channel requirements
1. Added detailed documentation for conda users building with pip: - Need to install gxx_linux-64 and gcc_linux-64 compilers - Prevents GLIBCXX version mismatch errors 2. Fixed conda-build documentation: - Added -c conda-forge flag requirement - Explains this is needed for cmake, ninja, and compiler dependencies 3. Enhanced troubleshooting section: - Compiler issues in conda environments - Conda build packages not found error - Clear solutions for both pip and conda-build workflows Co-authored-by: Ruochun <24469442+Ruochun@users.noreply.github.com>
1 parent f4c3dca commit faadcdf

File tree

2 files changed

+53
-3
lines changed

2 files changed

+53
-3
lines changed

PYTHON_BUILD.md

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,23 @@ This document describes how to build the Python package for DEM-Engine.
1616

1717
### Option 1: Using pip (recommended)
1818

19+
**Important for Conda Users:** If you're building in a conda environment, you need to install conda's compilers first to ensure compatibility:
20+
21+
```bash
22+
# Activate your conda environment
23+
conda activate your_env_name
24+
25+
# Install conda's compilers
26+
conda install -c conda-forge gxx_linux-64 gcc_linux-64
27+
28+
# Then build/install
29+
pip install .
30+
```
31+
32+
Without conda's compilers, the wheel will link against your system's libstdc++ which may cause import errors in conda environments.
33+
34+
For non-conda environments:
35+
1936
```bash
2037
pip install .
2138
```
@@ -24,6 +41,8 @@ This will use scikit-build-core to automatically configure CMake with the Python
2441

2542
### Option 2: Building a wheel
2643

44+
**Important for Conda Users:** If building in a conda environment, install conda's compilers first (see Option 1).
45+
2746
```bash
2847
pip install build
2948
python -m build
@@ -41,16 +60,21 @@ pip install -e .
4160

4261
### Option 4: Using conda
4362

44-
For conda users, you can build and install using conda-build:
63+
For conda users, you can build and install using conda-build. This method automatically handles all dependencies including compilers:
4564

4665
```bash
47-
# Build the conda package
48-
conda build recipe/
66+
# Build the conda package (requires conda-build and access to conda-forge channel)
67+
conda install conda-build
68+
conda build recipe/ -c conda-forge
4969

5070
# Install from local build
5171
conda install --use-local deme
5272
```
5373

74+
**Note:** The `-c conda-forge` flag is required to access build dependencies like cmake, ninja, and the C/C++ compilers.
75+
conda install --use-local deme
76+
```
77+
5478
This is useful for managing the package alongside other conda packages in your environment.
5579
5680
## CMake Options
@@ -96,6 +120,29 @@ The Python package provides bindings for:
96120

97121
## Troubleshooting
98122

123+
### Compiler Issues in Conda Environments
124+
125+
**Problem:** When building with `pip install .` in a conda environment, you get import errors like `GLIBCXX_3.4.30 not found`.
126+
127+
**Solution:** Install conda's compilers before building:
128+
```bash
129+
conda install -c conda-forge gxx_linux-64 gcc_linux-64
130+
pip install .
131+
```
132+
133+
This ensures the wheel is built with libraries compatible with your conda environment.
134+
135+
### Conda Build: Packages Not Found Error
136+
137+
**Problem:** `conda build recipe/` fails with "PackagesNotFoundError: cmake not available from current channels"
138+
139+
**Solution:** Specify the conda-forge channel when building:
140+
```bash
141+
conda build recipe/ -c conda-forge
142+
```
143+
144+
The conda-forge channel provides cmake, ninja, and other build dependencies.
145+
99146
### CUDA Not Found
100147

101148
Ensure that CUDA is installed and the `CUDA_ROOT` or `CUDACXX` environment variable is set:

recipe/meta.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ build:
1010
script: {{ PYTHON }} -m pip install . -vvv
1111
skip: true # [not linux]
1212

13+
# Note: Build with: conda build recipe/ -c conda-forge
14+
# The conda-forge channel is required for build dependencies
15+
1316
requirements:
1417
build:
1518
- {{ compiler('c') }}

0 commit comments

Comments
 (0)