yaml / pyyaml

Canonical source repository for PyYAML
MIT License
2.47k stars 507 forks source link

How to install via pip using `--without-libyaml` when `--install-option` is deprecated? #777

Closed phyber closed 5 months ago

phyber commented 5 months ago

Hi,

Sorry for asking this here.

I'm having trouble installing pyyaml using the --without-libyaml argument using newer Pip versions, as the --install-option, --global-option, etc, are deprecated in favour of --config-settings, and removed since Pip 23.1. However, there is no clear mapping between this new --config-settings and the older flags it's hard to know how to install pyyaml without libyaml now.

So, how do we install pyyaml using the --without-libyaml flag now that passing it from pip is unclear?

Thanks.

phyber commented 5 months ago

I think I've answered my own question. So I'll leave this here for future people possibly searching for help.

I'm using:

# The environment that I'm running this in lacks `pip`, so we run via `python3 -m pip`.
env PYYAML_FORCE_LIBYAML=0 \
python3 -m pip \
  --no-cache-dir \
  install "pyyaml==6.0.1" \
  --no-binary=":all": \
  --use-feature="no-binary-enable-wheel-cache" \
  --config-settings="PYYAML_FORCE_LIBYAML=0" \
  --target="${target_path}"

My ${target_path} contains no .so files after this runs, so it seems to be working fine. I'm sure not everything in here is needed, but this worked so this is it.

nitzmahone commented 5 months ago

Yep, between the flux around PEP517/518 build arg passthru the past few years (pip/setuptools/Cython) and the slow death of distutils, I had to add the envvars to ensure that even our own CI could reliably produce what was needed with modern Python packaging tooling... I've been holding off on documenting that stuff in hopes of something better than "here's the list of 50 envvars to set to control various aspects of PyYAML's build", but even though setuptools and pip have mostly settled config-settings passthru, there's still no great way to reimplement all the stuff PyYAML's setup leans on distutils for without basically rewriting junky versions of what distutils does in custom build backends. There's some glimmers of hope with things like scikit-build-core, and I've prototyped PyYAML builds with various build backends (including our own custom Cython shim wrapper), but nothing has worked well enough to release.