One of Callisto’s goals is to provide the best experience possible right off the bat. When it comes to installing python packages with pip, that means Callisto only installs wheels until the user says otherwise. With a wheel file, everything is already compiled and optimized for your Mac. But sometimes, there’s no wheel file available and you need to install a source package. Source packages often contain C code which needs to be compiled. On your Mac, you’ll need Xcode to compile that C code.
If you need to install a source package, the first step is to download Xcode from Apple and put it in your /Applications folder. Once you have that installed, you’ll need to make sure Xcode is set up for command line access. Open the Terminal.app in /Applications/Utilities and enter the following command:
xcode-select --install
This should open a graphical dialog to set you through the installation. You might get an error that says something like:
xcode-select: error: command line tools are already installed, use "Software Update" in System Settings to install updates
meaning that the command line tools are already installed. Either way, you’re set for the next step. The last thing to do is to check that your command line environment can find Xcode. Enter the following command in the Terminal.app:
xcode-select -p
That should show something like
/Applications/Xcode.app/Contents/Developer
Make sure that the /Applications/Xcode.app part matches where you installed Xcode. Restart Callisto after Xcode is all set up.
Now you’re all set to enable source package installation in Callisto. Open a Python notebook on your Mac and activate the package manager. You should see a checkbox to enable installation for source packages. When you check that, Callisto will attempt to compile and install a small source package with some C code. When that succeeds, you’re ready to install any source package.
Some details to keep in mind:
- Most packages that require compilation use either C or C++. Xcode will handle those just fine. Some packages may be written in another language like Rust or FORTRAN. You may need to install other software in order to compile those packages. Fortunately, most of these packages publish wheel files, so compiling is unnecessary.
- Python packaging (and pip) differentiates between ‘source packages’ and ‘binary distributions’ (wheel files). Some pure Python packages, especially older ones, have only published a source package, but no ‘universal’ wheel. Even though the package is pure Python, Callisto has no way to determine that, so Xcode installation is still required, even though the package doesn’t need compiling.
- Callisto Cloud nodes alway support source distributions. Due to Apple restrictions, Callisto on iPad never supports source distribution. You’ll only see the ‘source distribution’ option when using the Callisto on the Mac with the built-in Python environment.
- All of this applies to Callisto package management user interface for pip. If you want to access pip directly, you can always use ‘%pip’ cell magic in your notebook for full control.