1. Preparations
1.1. Install Command Line Tools for Xcode
If you have not installed Xcode, please install it from the App Store. After installation, open a terminal and type:
xcode-select --install
to install Command Line Tools for Xcode.
1.2. Install Homebrew, gcc, and cmake for Mac OS
Homebrew is a package manager for Mac OS, which can be installed with:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
For example, to install gcc v14 compiler (recommended) and cmake using Homebrew, type:
brew install gcc@14 cmake
1.3. Create a conda environment for Tractor
Assuming you have installed a conda distribution, you can create a new virtual environment for Tractor. Here we create a new environment named wise:
conda create -n wise cython=3.0 ceres-solver=2.1 glog=0.5 python=3.10 fitsio=1.2.4 -c conda-forge 
If you want to install more packages, e.g. jupyter  in the wise environment, you can type:
conda install -n wise jupyter -c conda-forge 
1.4. Install astrometry.net
Download the latest version of astrometry.net from here. For example, you can download the latest version and extract it using:
wget https://astrometry.net/downloads/astrometry.net-latest.tar.gz 
tar -xzf astrometry.net-latest.tar.gz
To install astrometry.net in the wise environment, you can type:
conda activate wise 
cd astrometry.net-0.96
python -m pip install .
2. Install Tractor
2.1. Download the latest version of Tractor
You can download the latest version of Tractor from github:
git clone git@github.com:dstndstn/tractor.git
cd tractor
2.2. Edit the environment variables in the setup.py file
Locate the gcc-14 (and g++-14) path of the gcc compiler installed by Homebrew. The latest version homebrew will put the excutable in /opt/homebrew/bin/. Once you confirm the path, you can add the following two lines into the setup.py file of Tractor before the line starting with def main:
os.environ['CC'] = '/opt/homebrew/bin/gcc-14'
os.environ['CXX'] = '/opt/homebrew/bin/g++-14'
2.3. Install Tractor in the wise environment
Make sure you have activated the wise environment. Then you can install Tractor using:
make 
# OR
python3 setup.py build_ext --inplace --with-ceres --with-cython 
Once the installation is finished, you can test the installation by typing:
python examples/tractor-sdss-synth.py
