homebrew-core/Formula/pyyaml.rb

50 lines
1.5 KiB
Ruby
Raw Normal View History

class Pyyaml < Formula
desc "YAML framework for Python"
homepage "https://pyyaml.org"
url "https://files.pythonhosted.org/packages/36/2b/61d51a2c4f25ef062ae3f74576b01638bebad5e045f747ff12643df63844/PyYAML-6.0.tar.gz"
sha256 "68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2"
license "MIT"
depends_on "cython" => :build
depends_on "python@3.10" => [:build, :test]
depends_on "python@3.8" => [:build, :test]
depends_on "python@3.9" => [:build, :test]
depends_on "libyaml"
def pythons
deps.select { |dep| dep.name.start_with?("python") }
.map(&:to_formula)
.sort_by(&:version)
end
def install
cythonize = Formula["cython"].bin/"cythonize"
system cythonize, "yaml/_yaml.pyx"
pythons.each do |python|
python_exe = python.opt_libexec/"bin/python"
system python_exe, *Language::Python.setup_install_args(prefix, python_exe)
end
end
def caveats
python_versions = pythons.map { |p| p.version.major_minor }
.map(&:to_s)
.join(", ")
<<~EOS
This formula provides the `yaml` module for Python #{python_versions}.
If you need `yaml` for a different version of Python, use pip.
EOS
end
test do
pythons.each do |python|
system python.opt_libexec/"bin/python", "-c", <<~EOS
import yaml
assert yaml.__with_libyaml__
assert yaml.dump({"foo": "bar"}) == "foo: bar\\n"
EOS
end
end
end