/
python-markdown.rb
43 lines (36 loc) 路 1.37 KB
/
python-markdown.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
class PythonMarkdown < Formula
desc "Python implementation of Markdown"
homepage "https://python-markdown.github.io"
url "https://files.pythonhosted.org/packages/22/02/4785861427848cc11e452cc62bb541006a1087cf04a1de83aedd5530b948/Markdown-3.6.tar.gz"
sha256 "ed4f41f6daecbeeb96e576ce414c41d2d876daa9a16cb35fa8ed8c2ddfad0224"
license "BSD-3-Clause"
head "https://github.com/Python-Markdown/markdown.git", branch: "master"
bottle do
sha256 cellar: :any_skip_relocation, all: "81a78ea79b6c4c44b860a38c8e08a0edb5a2a13ce2f0f2b5d0f4f95d8451cf95"
end
depends_on "python-setuptools" => :build
depends_on "python@3.11" => [:build, :test]
depends_on "python@3.12" => [:build, :test]
def pythons
deps.map(&:to_formula).sort_by(&:version).filter { |f| f.name.start_with?("python@") }
end
def install
pythons.each do |python|
python_exe = python.opt_libexec/"bin/python"
system python_exe, "-m", "pip", "install", *std_pip_args, "."
end
end
def caveats
<<~EOS
To run `markdown_py`, you may need to `brew install #{pythons.last}`
EOS
end
test do
(testpath/"test.md").write("# Hello World!")
assert_equal "<h1>Hello World!</h1>", shell_output(bin/"markdown_py test.md").strip
pythons.each do |python|
python_exe = python.opt_libexec/"bin/python"
system python_exe, "-c", "import markdown;"
end
end
end