devguide icon indicating copy to clipboard operation
devguide copied to clipboard

Feature: Add guide to install system dependencies with pixi

Open lysnikolaou opened this issue 3 months ago • 4 comments

Describe the enhancement or feature you would like

I've stopped using brew on my macOS and I'm instead using pixi whenever I need system-level dependencies. This works very well in practice even for building CPython and I can do things like pixi run configure and it automatically sets up all of the system dependencies and runs configure. Doing that requires setting some environment variables here and there, but I've done that in a pixi.toml and it's all automated. It looks somewhat like this:

[project]
name = "cpython-dev"
channels = ["conda-forge"]
platforms = ["osx-arm64"]

[dependencies]
gdbm = "*"
libmpdec-devel = "*"
openssl = "3.*"
pkg-config = "*"
tk = "*"
xz = "*"
zstd = "*"
zlib = "*"

[tasks.configure]
cmd = "./configure --with-openssl=$CONDA_PREFIX"

[tasks.configure.env]
PKG_CONFIG_PATH = "$CONDA_PREFIX/lib/pkgconfig"
GDBM_CFLAGS = "-I$CONDA_PREFIX/include"
GDBM_LIBS = "-L$CONDA_PREFIX/lib -lgdbm"
TCLTK_CFLAGS = "$(pkg-config --cflags tcl tk)"
# tcl.pc and tk.pc files contain stub libraries, but those do not extist
# in the conda package
TCLTK_LIBS = "$(pkg-config --libs tcl tk | sed 's/-l[^ ]*stub[^ ]*//g')"
LDFLAGS = "-Wl,-rpath,$CONDA_PREFIX/lib"

It's a bit too much to propose adding this to the CPython repo, at least for now. However, pointing to this as a way to install system-level dependencies in the devguide doesn't sounds like a bad idea to me.

Thoughts? Is there an appetite for this? If so, I can start drafting a PR.

Describe alternatives you have considered

No response

Additional context

No response

lysnikolaou avatar Oct 17 '25 15:10 lysnikolaou

Is there an appetite for this?

While I have never used a Mac properly, this seems reasonable to me. Adding a third tab (we already have "Homebrew" and "MacPorts" seems fine.

StanFromIreland avatar Oct 17 '25 15:10 StanFromIreland

It would be nice to also add other tasks with "usual" configuration options like debug build or a prefix. As far as I am aware, I think pixi tasks can accept user arguments. My typical python configuration/building is something like this

PYTHON_VERSION="3.14.0"
PYTHON_MINOR=$(echo $PYTHON_VERSION | grep -oE '^[0-9]+\.[0-9]+')

./configure --prefix=/opt/python/${PYTHON_VERSION}/ --enable-loadable-sqlite-extensions --with-openssl=/opt/homebrew/opt/openssl@3 --with-pydebug
sudo make -j16
sudo make altinstall

ikrommyd avatar Dec 04 '25 00:12 ikrommyd

FWIW, we've found pixi extremely useful to test downstreams with the address sanitizer, as they need quite a delicate environment to be setup. I have proposed adding pixi definitions in CPython for ASAN builds at https://github.com/python/cpython/issues/142466, as IMO there's a strong reason to do so in that use-case.

I think a broader use of pixi could be helpful.

FFY00 avatar Dec 09 '25 15:12 FFY00

see https://github.com/python/cpython/pull/142469. That PR is geared towards automating builds which can be used downstream, but it should be helpful for similar work towards a Pixi workspace for developing CPython itself.

lucascolley avatar Dec 09 '25 15:12 lucascolley