pythran 0.9.11 (new formula)

Closes #79690.

Signed-off-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com>
Signed-off-by: BrewTestBot <1589480+BrewTestBot@users.noreply.github.com>
master
Michael Cho 2021-06-28 18:59:40 -07:00 committed by BrewTestBot
parent 33da987b67
commit 3e45b6f135
No known key found for this signature in database
GPG Key ID: 82D7D104050B0F0F
2 changed files with 99 additions and 0 deletions

96
Formula/pythran.rb Normal file
View File

@ -0,0 +1,96 @@
class Pythran < Formula
include Language::Python::Virtualenv
desc "Ahead of Time compiler for numeric kernels"
homepage "https://pythran.readthedocs.io/"
url "https://files.pythonhosted.org/packages/2e/e9/bc3c16d683dbba5d34666b9861d1c1fdb07da0539655a3cf23a62e4cafa1/pythran-0.9.11.tar.gz"
sha256 "a317f91e2aade9f6550dc3bf40b5caeb45b7e012daf27e2b3e4ad928edb01667"
license "BSD-3-Clause"
head "https://github.com/serge-sans-paille/pythran.git"
depends_on "gcc" # for OpenMP
depends_on "numpy"
depends_on "openblas"
depends_on "python@3.9"
depends_on "six"
resource "beniget" do
url "https://files.pythonhosted.org/packages/50/b9/7d864a50d5d2821686d4374400de45c8e0678e553657343f5f0ea6aff98d/beniget-0.3.0.tar.gz"
sha256 "062c893be9cdf87c3144fb15041cce4d81c67107c1591952cd45fdce789a0ff1"
end
resource "decorator" do
url "https://files.pythonhosted.org/packages/da/93/84fa12f2dc341f8cf5f022ee09e109961055749df2d0c75c5f98746cfe6c/decorator-4.4.2.tar.gz"
sha256 "e3a62f0520172440ca0dcc823749319382e377f37f140a0b99ef45fecb84bfe7"
end
resource "gast" do
url "https://files.pythonhosted.org/packages/83/4a/07c7e59cef23fb147454663c3271c21da68ba2ab141427c20548ae5a8a4d/gast-0.4.0.tar.gz"
sha256 "40feb7b8b8434785585ab224d1568b857edb18297e5a3047f1ba012bc83b42c1"
end
resource "networkx" do
url "https://files.pythonhosted.org/packages/b0/21/adfbf6168631e28577e4af9eb9f26d75fe72b2bb1d33762a5f2c425e6c2a/networkx-2.5.1.tar.gz"
sha256 "109cd585cac41297f71103c3c42ac6ef7379f29788eb54cb751be5a663bb235a"
end
resource "ply" do
url "https://files.pythonhosted.org/packages/e5/69/882ee5c9d017149285cab114ebeab373308ef0f874fcdac9beb90e0ac4da/ply-3.11.tar.gz"
sha256 "00c7c1aaa88358b9c765b6d3000c6eec0ba42abca5351b095321aef446081da3"
end
def install
on_macos do
gcc_major_ver = Formula["gcc"].any_installed_version.major
inreplace "pythran/pythran-darwin.cfg" do |s|
s.gsub!(/^include_dirs=/, "include_dirs=#{Formula["openblas"].opt_include}")
s.gsub!(/^library_dirs=/, "library_dirs=#{Formula["openblas"].opt_lib}")
s.gsub!(/^blas=.*/, "blas=openblas")
s.gsub!(/^CC=.*/, "CC=#{Formula["gcc"].opt_bin}/gcc-#{gcc_major_ver}")
s.gsub!(/^CXX=.*/, "CXX=#{Formula["gcc"].opt_bin}/g++-#{gcc_major_ver}")
end
end
virtualenv_install_with_resources
end
test do
pythran = Formula["pythran"].opt_bin/"pythran"
python = Formula["python@3.9"].opt_bin/"python3"
(testpath/"dprod.py").write <<~EOS
#pythran export dprod(int list, int list)
def dprod(arr0, arr1):
return sum([x*y for x,y in zip(arr0, arr1)])
EOS
system pythran, testpath/"dprod.py"
rm_f testpath/"dprod.py"
assert_equal "11", shell_output("#{python} -c 'import dprod; print(dprod.dprod([1,2], [3,4]))'").chomp
(testpath/"arc_distance.py").write <<~EOS
#pythran export arc_distance(float[], float[], float[], float[])
import numpy as np
def arc_distance(theta_1, phi_1, theta_2, phi_2):
"""
Calculates the pairwise arc distance between all points in vector a and b.
"""
temp = np.sin((theta_2-theta_1)/2)**2 + np.cos(theta_1)*np.cos(theta_2)*np.sin((phi_2-phi_1)/2)**2
distance_matrix = 2 * np.arctan2(np.sqrt(temp), np.sqrt(1-temp))
return distance_matrix
EOS
# Test with configured gcc to detect breakages from gcc major versions and for OpenMP support
with_env(CC: nil, CXX: nil) do
system pythran, "-DUSE_XSIMD", "-fopenmp", "-march=native", testpath/"arc_distance.py"
end
rm_f testpath/"arc_distance.py"
system python, "-c", <<~EOS
import numpy as np
import arc_distance
d = arc_distance.arc_distance(
np.array([12.4,0.5,-5.6,12.34,9.21]), np.array([-5.6,3.4,2.3,-23.31,12.6]),
np.array([3.45,1.5,55.4,567.0,43.2]), np.array([56.1,3.4,1.34,-56.9,-3.4]),
)
assert ([1.927, 1., 1.975, 1.83, 1.032] == np.round(d, 3)).all()
EOS
end
end

View File

@ -137,6 +137,9 @@
"pyqt-builder": {
"exclude_packages": ["packaging", "pyparsing", "sip", "toml"]
},
"pythran": {
"exclude_packages": ["numpy", "six"]
},
"pywhat": {
"exclude_packages": ["six"]
},