|
| 1 | +# macOS Development Environment Setup Plan for CypherDB |
| 2 | + |
| 3 | +This document outlines the step-by-step plan for setting up a local development environment for CypherDB on macOS, based on the [official developer guide](https://opencypher.github.io/cypherdb/developer-guide/). |
| 4 | + |
| 5 | +## Prerequisites Overview |
| 6 | + |
| 7 | +- **CMake**: >= 3.15 |
| 8 | +- **Python**: >= 3.9 (3.11 recommended based on CI workflows) |
| 9 | +- **C++ Compiler**: Clang 18+ (Apple Clang is preferred on macOS) |
| 10 | +- **Homebrew**: Package manager for macOS |
| 11 | +- **Xcode Command Line Tools**: Required for C++ compilation |
| 12 | + |
| 13 | +## Step-by-Step Setup Instructions |
| 14 | + |
| 15 | +### 1. Install Homebrew (if not already installed) |
| 16 | + |
| 17 | +```bash |
| 18 | +/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" |
| 19 | +``` |
| 20 | + |
| 21 | +Verify installation: |
| 22 | +```bash |
| 23 | +brew --version |
| 24 | +``` |
| 25 | + |
| 26 | +### 2. Install Xcode Command Line Tools |
| 27 | + |
| 28 | +The command line tools provide the necessary C++ compiler (Apple Clang) and other build tools: |
| 29 | + |
| 30 | +```bash |
| 31 | +xcode-select --install |
| 32 | +``` |
| 33 | + |
| 34 | +Verify installation: |
| 35 | +```bash |
| 36 | +clang --version |
| 37 | +# Should show Apple Clang version 18 or later. xcode clang may be lower. if so, install llvm via brew |
| 38 | +``` |
| 39 | + |
| 40 | +### 3. Install Build Dependencies via Homebrew |
| 41 | + |
| 42 | +Install CMake and Python (if not already present): |
| 43 | + |
| 44 | +```bash |
| 45 | +brew install cmake python |
| 46 | +``` |
| 47 | + |
| 48 | +Optionally install `llvm` for a newer version of clang (if xcode version is outdated): |
| 49 | + |
| 50 | +``` |
| 51 | +brew install llvm |
| 52 | +``` |
| 53 | + |
| 54 | +Verify versions: |
| 55 | +```bash |
| 56 | +cmake --version # Should be >= 3.15 |
| 57 | +python3 --version # Should be >= 3.9 (3.11 recommended) |
| 58 | +``` |
| 59 | + |
| 60 | +**Note**: If you already have Python installed, ensure it's version 3.9 or higher. The CI workflows use Python 3.11. |
| 61 | + |
| 62 | +### 4. Optional: Install Python Development Headers |
| 63 | + |
| 64 | +If you plan to build Python bindings, ensure Python development headers are available. On macOS, these are typically included with Python installed via Homebrew, but you may need: |
| 65 | + |
| 66 | +```bash |
| 67 | +brew install python3-dev # If available, otherwise headers come with python |
| 68 | +``` |
| 69 | + |
| 70 | +### 5. Verify System Requirements |
| 71 | + |
| 72 | +Ensure your system meets the compiler requirements: |
| 73 | +- **C++ Standard**: C++20 support required |
| 74 | +- **Compiler**: Apple Clang 18+ (check with `clang --version`) |
| 75 | +- **Architecture**: macOS supports both x86_64 (Intel) and arm64 (Apple Silicon) |
| 76 | + |
| 77 | +### 6. Build CypherDB Core |
| 78 | + |
| 79 | +Navigate to the project root and build the release version: |
| 80 | + |
| 81 | +```bash |
| 82 | +cd /Users/akollegger/Developer/opencypher/cypherdb |
| 83 | +make release NUM_THREADS=$(sysctl -n hw.physicalcpu) |
| 84 | +``` |
| 85 | + |
| 86 | +This will: |
| 87 | +- Configure CMake with Release build type |
| 88 | +- Build the core C++ library and CLI |
| 89 | +- Use all available physical CPU cores for compilation |
| 90 | + |
| 91 | +**Note**: On macOS, `sysctl -n hw.physicalcpu` gives you the number of physical CPU cores, which is the recommended setting according to the developer guide. |
| 92 | + |
| 93 | +### 7. Run Basic Tests |
| 94 | + |
| 95 | +After building, verify the installation by running tests: |
| 96 | + |
| 97 | +```bash |
| 98 | +make test NUM_THREADS=$(sysctl -n hw.physicalcpu) |
| 99 | +``` |
| 100 | + |
| 101 | +**Important for macOS**: If you encounter test failures related to "too many open files", increase the file limit: |
| 102 | + |
| 103 | +```bash |
| 104 | +ulimit -n 10000 |
| 105 | +make test NUM_THREADS=$(sysctl -n hw.physicalcpu) |
| 106 | +``` |
| 107 | + |
| 108 | +### 8. Build Python Bindings (Optional) |
| 109 | + |
| 110 | +If you want to develop with Python bindings: |
| 111 | + |
| 112 | +#### 8.1 Install Python Dependencies |
| 113 | + |
| 114 | +```bash |
| 115 | +make -C tools/python_api requirements |
| 116 | +``` |
| 117 | + |
| 118 | +This will: |
| 119 | +- Create a virtual environment |
| 120 | +- Install development dependencies from `tools/python_api/requirements_dev.txt` |
| 121 | + |
| 122 | +#### 8.2 Build Python Bindings |
| 123 | + |
| 124 | +```bash |
| 125 | +make python NUM_THREADS=$(sysctl -n hw.physicalcpu) |
| 126 | +``` |
| 127 | + |
| 128 | +#### 8.3 Run Python Tests |
| 129 | + |
| 130 | +```bash |
| 131 | +make pytest-venv NUM_THREADS=$(sysctl -n hw.physicalcpu) |
| 132 | +``` |
| 133 | + |
| 134 | +### 9. Build Node.js Bindings (Optional) |
| 135 | + |
| 136 | +If you want to develop with Node.js bindings: |
| 137 | + |
| 138 | +#### 9.1 Prerequisites |
| 139 | + |
| 140 | +Install Node.js (version 14.15.0 or higher): |
| 141 | +```bash |
| 142 | +brew install node |
| 143 | +node --version # Verify >= 14.15.0 |
| 144 | +``` |
| 145 | + |
| 146 | +#### 9.2 Install Dependencies |
| 147 | + |
| 148 | +```bash |
| 149 | +make nodejs-deps |
| 150 | +``` |
| 151 | + |
| 152 | +#### 9.3 Build Node.js Bindings |
| 153 | + |
| 154 | +```bash |
| 155 | +make nodejs NUM_THREADS=$(sysctl -n hw.physicalcpu) |
| 156 | +``` |
| 157 | + |
| 158 | +#### 9.4 Run Node.js Tests |
| 159 | + |
| 160 | +```bash |
| 161 | +make nodejstest NUM_THREADS=$(sysctl -n hw.physicalcpu) |
| 162 | +``` |
| 163 | + |
| 164 | +### 10. Build Java Bindings (Optional) |
| 165 | + |
| 166 | +If you want to develop with Java bindings: |
| 167 | + |
| 168 | +#### 10.1 Prerequisites |
| 169 | + |
| 170 | +Install JDK 11 or higher: |
| 171 | +```bash |
| 172 | +brew install openjdk@11 |
| 173 | +# Or install via Oracle JDK, OpenJDK, or Eclipse Temurin |
| 174 | +``` |
| 175 | + |
| 176 | +#### 10.2 Build Java Bindings |
| 177 | + |
| 178 | +```bash |
| 179 | +make java NUM_THREADS=$(sysctl -n hw.physicalcpu) |
| 180 | +``` |
| 181 | + |
| 182 | +#### 10.3 Run Java Tests |
| 183 | + |
| 184 | +```bash |
| 185 | +make javatest NUM_THREADS=$(sysctl -n hw.physicalcpu) |
| 186 | +``` |
| 187 | + |
| 188 | +### 11. Build Rust Bindings (Optional) |
| 189 | + |
| 190 | +If you want to develop with Rust bindings: |
| 191 | + |
| 192 | +#### 11.1 Prerequisites |
| 193 | + |
| 194 | +Install Rust 1.81.0 or later: |
| 195 | +```bash |
| 196 | +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh |
| 197 | +rustc --version # Verify >= 1.81.0 |
| 198 | +``` |
| 199 | + |
| 200 | +#### 11.2 Build Rust Bindings |
| 201 | + |
| 202 | +```bash |
| 203 | +cd tools/rust_api && CARGO_BUILD_JOBS=$(sysctl -n hw.physicalcpu) cargo build |
| 204 | +cd ../.. |
| 205 | +``` |
| 206 | + |
| 207 | +#### 11.3 Run Rust Tests |
| 208 | + |
| 209 | +```bash |
| 210 | +make rusttest |
| 211 | +``` |
| 212 | + |
| 213 | +## Build Variants |
| 214 | + |
| 215 | +### Debug Build |
| 216 | + |
| 217 | +For development with debug symbols: |
| 218 | + |
| 219 | +```bash |
| 220 | +make debug NUM_THREADS=$(sysctl -n hw.physicalcpu) |
| 221 | +``` |
| 222 | + |
| 223 | +### RelWithDebInfo Build |
| 224 | + |
| 225 | +For optimized builds with debug info: |
| 226 | + |
| 227 | +```bash |
| 228 | +make relwithdebinfo NUM_THREADS=$(sysctl -n hw.physicalcpu) |
| 229 | +``` |
| 230 | + |
| 231 | +### Build Everything |
| 232 | + |
| 233 | +To build all components (benchmarks, examples, extensions, tests, and all language bindings): |
| 234 | + |
| 235 | +```bash |
| 236 | +make all NUM_THREADS=$(sysctl -n hw.physicalcpu) |
| 237 | +``` |
| 238 | + |
| 239 | +## Common Issues and Solutions |
| 240 | + |
| 241 | +### Issue: "Too many open files" during tests |
| 242 | + |
| 243 | +**Solution**: Increase the file descriptor limit: |
| 244 | +```bash |
| 245 | +ulimit -n 10000 |
| 246 | +``` |
| 247 | + |
| 248 | +### Issue: Python development headers not found |
| 249 | + |
| 250 | +**Solution**: Ensure Python was installed via Homebrew, which includes headers by default. Alternatively: |
| 251 | +```bash |
| 252 | +brew install python3 |
| 253 | +``` |
| 254 | + |
| 255 | +### Issue: Compiler version too old |
| 256 | + |
| 257 | +**Solution**: Update Xcode Command Line Tools: |
| 258 | +```bash |
| 259 | +xcode-select --install |
| 260 | +softwareupdate --all --install --force |
| 261 | +``` |
| 262 | + |
| 263 | +### Issue: CMake version too old |
| 264 | + |
| 265 | +**Solution**: Update via Homebrew: |
| 266 | +```bash |
| 267 | +brew upgrade cmake |
| 268 | +``` |
| 269 | + |
| 270 | +## Verification Checklist |
| 271 | + |
| 272 | +After setup, verify your environment: |
| 273 | + |
| 274 | +- [ ] `cmake --version` shows >= 3.15 |
| 275 | +- [ ] `python3 --version` shows >= 3.9 |
| 276 | +- [ ] `clang --version` shows Apple Clang 18+ |
| 277 | +- [ ] Core build completes: `make release` |
| 278 | +- [ ] Tests pass: `make test` |
| 279 | +- [ ] (Optional) Python bindings work: `make python && make pytest-venv` |
| 280 | + |
| 281 | +## Next Steps |
| 282 | + |
| 283 | +Once your environment is set up: |
| 284 | + |
| 285 | +1. Review the [Contributing Guidelines](CONTRIBUTING.md) |
| 286 | +2. Explore the codebase structure |
| 287 | +3. Check out example code in the `examples/` directory |
| 288 | +4. Review test files in `test/` to understand expected behavior |
| 289 | +5. Join the [Discord community](https://discord.gg/neo4j) for real-time communication |
| 290 | + |
| 291 | +## Additional Resources |
| 292 | + |
| 293 | +- [Developer Guide](https://opencypher.github.io/cypherdb/developer-guide/) |
| 294 | +- [Testing Framework Documentation](https://opencypher.github.io/cypherdb/developer-guide/testing-framework/) |
| 295 | +- [Performance Debugging](https://opencypher.github.io/cypherdb/developer-guide/performance-debugging/) |
| 296 | +- [GitHub Actions Workflows](.github/workflows/) - Reference for exact build commands used in CI |
| 297 | + |
0 commit comments