From 8e2dfb4407dfe7abd17bf6c676ca369188148ff5 Mon Sep 17 00:00:00 2001 From: David Baumgold Date: Tue, 13 Sep 2022 11:43:00 +0200 Subject: [PATCH] weasyprint 56.1 (new formula) Closes #110554. Signed-off-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Signed-off-by: Rui Chen Signed-off-by: BrewTestBot <1589480+BrewTestBot@users.noreply.github.com> --- Formula/weasyprint.rb | 82 ++++++++++++++++++++++++++++++++++++++ pypi_formula_mappings.json | 3 ++ 2 files changed, 85 insertions(+) create mode 100644 Formula/weasyprint.rb diff --git a/Formula/weasyprint.rb b/Formula/weasyprint.rb new file mode 100644 index 00000000000..b84775893aa --- /dev/null +++ b/Formula/weasyprint.rb @@ -0,0 +1,82 @@ +class Weasyprint < Formula + include Language::Python::Virtualenv + + desc "Convert HTML to PDF" + homepage "https://www.courtbouillon.org/weasyprint" + url "https://files.pythonhosted.org/packages/30/2c/9c29989bf03bb573bd963c2cf167839099bdaff05aff1f0eff2ccbd1b509/weasyprint-56.1.tar.gz" + sha256 "27f796abce8edebc9e5b3cff2d095a9fa2b0af5766801431659db51203c70b38" + license "BSD-3-Clause" + + depends_on "fonttools" + depends_on "pango" + depends_on "pillow" + depends_on "python@3.10" + depends_on "six" + + uses_from_macos "libffi" + + resource "cffi" do + url "https://files.pythonhosted.org/packages/2b/a8/050ab4f0c3d4c1b8aaa805f70e26e84d0e27004907c5b8ecc1d31815f92a/cffi-1.15.1.tar.gz" + sha256 "d400bfb9a37b1351253cb402671cea7e89bdecc294e8016a707f6d1d8ac934f9" + end + + resource "cssselect2" do + url "https://files.pythonhosted.org/packages/68/62/b6a16d0c32bb088079f344202e3cd0936380a4d8cb23ef9b1f8079ff8612/cssselect2-0.6.0.tar.gz" + sha256 "5b5d6dea81a5eb0c9ca39f116c8578dd413778060c94c1f51196371618909325" + end + + resource "html5lib" do + url "https://files.pythonhosted.org/packages/ac/b6/b55c3f49042f1df3dcd422b7f224f939892ee94f22abcf503a9b7339eaf2/html5lib-1.1.tar.gz" + sha256 "b2e5b40261e20f354d198eae92afc10d750afb487ed5e50f9c4eaf07c184146f" + end + + resource "pycparser" do + url "https://files.pythonhosted.org/packages/5e/0b/95d387f5f4433cb0f53ff7ad859bd2c6051051cebbb564f139a999ab46de/pycparser-2.21.tar.gz" + sha256 "e644fdec12f7872f86c58ff790da456218b10f863970249516d60a5eaca77206" + end + + resource "pydyf" do + url "https://files.pythonhosted.org/packages/3a/5e/4d4f5f77c706b0b871652cb4ccb98a52647ce917168a48e2b8cae742da1e/pydyf-0.2.0.tar.gz" + sha256 "06ebc18b4de29fc1450ae49dd142ecd26bd7ba09d0b1919e365fbc3d8af8a622" + end + + resource "pyphen" do + url "https://files.pythonhosted.org/packages/9a/53/e7f212c87f91aab928bbf0de95ebc319c4d935e59bd5ed868f2c2bfc9465/pyphen-0.13.0.tar.gz" + sha256 "06873cebffd65a8fca7c20c0e3dc032655c7ee8de0f552205cad3b574265c293" + end + + resource "tinycss2" do + url "https://files.pythonhosted.org/packages/1e/5a/576828164b5486f319c4323915b915a8af3fa4a654bbb6f8fc8e87b5cb17/tinycss2-1.1.1.tar.gz" + sha256 "b2e44dd8883c360c35dd0d1b5aad0b610e5156c2cb3b33434634e539ead9d8bf" + end + + resource "webencodings" do + url "https://files.pythonhosted.org/packages/0b/02/ae6ceac1baeda530866a85075641cec12989bd8d31af6d5ab4a3e8c92f47/webencodings-0.5.1.tar.gz" + sha256 "b36a1c245f2d304965eb4e0a82848379241dc04b865afcc4aab16748587e1923" + end + + resource "zopfli" do + url "https://files.pythonhosted.org/packages/91/25/ba6f370e18359292f05ca4df93642eb7d1c424721ef61f61b8610a63d0c5/zopfli-0.2.1.zip" + sha256 "e5263d2806e2c1ccb23f52b2972a235d31d42f22f3fa3032cc9aded51e9bf2c6" + end + + def install + virtualenv_install_with_resources + # we depend on fonttools, but that's a separate formula, so install a `.pth` file to link them + site_packages = Language::Python.site_packages("python3.10") + fonttools = Formula["fonttools"].opt_libexec + (libexec/site_packages/"homebrew-fonttools.pth").write fonttools/site_packages + end + + test do + (testpath/"example.html").write <<~EOS +

This is a PDF

+ EOS + system bin/"weasyprint", "example.html", "example.pdf" + assert_predicate testpath/"example.pdf", :exist? + File.open(testpath/"example.pdf", encoding: "iso-8859-1") do |f| + contents = f.read + assert_match(/^%PDF-1.7\n/, contents) + end + end +end diff --git a/pypi_formula_mappings.json b/pypi_formula_mappings.json index 0fc1bcbbdf9..a4474ab4399 100644 --- a/pypi_formula_mappings.json +++ b/pypi_formula_mappings.json @@ -480,6 +480,9 @@ "watson": { "exclude_packages": ["six"] }, + "weasyprint": { + "exclude_packages": ["Brotli", "fonttools", "Pillow", "six"] + }, "west": { "exclude_packages": ["six"] },