Skip to content

Instantly share code, notes, and snippets.

@mppf
Created February 2, 2022 14:20
Show Gist options
  • Save mppf/32869664c6bb251dcd1101d783763780 to your computer and use it in GitHub Desktop.
Save mppf/32869664c6bb251dcd1101d783763780 to your computer and use it in GitHub Desktop.
draft homebrew formula for Python 3.10 and Chapel 1.25.1
class Chapel < Formula
desc "Programming language for productive parallel computing at scale"
homepage "https://chapel-lang.org/"
url "https://github.com/chapel-lang/chapel/releases/download/1.25.1/chapel-1.25.1.tar.gz"
sha256 "0c13d7da5892d0b6642267af605d808eb7dd5d4970766f262f38b94fa2405113"
license "Apache-2.0"
revision 1
bottle do
sha256 arm64_monterey: "e11d484b8dbeb19649b46ebadb1ff063e79a3fa7c3e1befc258c6fd28a4712a2"
sha256 arm64_big_sur: "816fe386b1d8265df2a4af0721fc3ed62d47b7d4f8c6c2e5ddd8c6d060776e42"
sha256 monterey: "af7c4e7c0f3204bf63dfe2b2a09d458684cd9e93e64f9f6f25de2c77e81a6edb"
sha256 big_sur: "042ea557965c12f0bce8537b87ded0761bd67edd1c358be7cd1ba62a299a80d3"
sha256 catalina: "eb1eb04bbeadf0e9868bb2fb1ee79dd28500bca5575a89417471a768826bdd41"
sha256 x86_64_linux: "ec01313dd3b0136c6620b7f01298fa0c97f1d4a87a1371402c552064cb8677db"
end
depends_on "gmp"
depends_on "llvm@11"
depends_on "python@3.10"
# includes changes already merged upstream after 1.25.1
patch :DATA
def install
libexec.install Dir["*"]
# Chapel uses this ENV to work out where to install.
ENV["CHPL_HOME"] = libexec
ENV["CHPL_GMP"] = "system"
# Must be built from within CHPL_HOME to prevent build bugs.
# https://github.com/Homebrew/legacy-homebrew/pull/35166
cd libexec do
system "echo CHPL_RE2=bundled > chplconfig"
system "echo CHPL_GMP=system >> chplconfig"
system "echo CHPL_LLVM_CONFIG=#{HOMEBREW_PREFIX}/opt/llvm@11/bin/llvm-config >> chplconfig"
system "./util/printchplenv", "--all"
with_env(CHPL_PIP_FROM_SOURCE: "1") do
system "make", "test-venv"
end
with_env(CHPL_LLVM: "none") do
system "make"
end
with_env(CHPL_LLVM: "system") do
system "make"
end
with_env(CHPL_PIP_FROM_SOURCE: "1") do
system "make", "chpldoc"
end
system "make", "mason"
system "make", "cleanall"
rm_rf("third-party/llvm/llvm-src/")
rm_rf("third-party/gasnet/gasnet-src")
rm_rf("third-party/libfabric/libfabric-src")
rm_rf("third-party/fltk/fltk-1.3.5-source.tar.gz")
rm_rf("third-party/libunwind/libunwind-1.1.tar.gz")
rm_rf("third-party/gmp/gmp-src/")
rm_rf("third-party/qthread/qthread-src/installed")
end
# Install chpl and other binaries (e.g. chpldoc) into bin/ as exec scripts.
platform = if OS.linux? && Hardware::CPU.is_64_bit?
"linux64-#{Hardware::CPU.arch}"
else
"#{OS.kernel_name.downcase}-#{Hardware::CPU.arch}"
end
bin.install libexec.glob("bin/#{platform}/*")
bin.env_script_all_files libexec/"bin"/platform, CHPL_HOME: libexec
man1.install_symlink libexec.glob("man/man1/*.1")
end
test do
ENV["CHPL_HOME"] = libexec
ENV["CHPL_INCLUDE_PATH"] = HOMEBREW_PREFIX/"include"
ENV["CHPL_LIB_PATH"] = HOMEBREW_PREFIX/"lib"
cd libexec do
with_env(CHPL_LLVM: "system") do
system "util/test/checkChplInstall"
end
with_env(CHPL_LLVM: "none") do
system "util/test/checkChplInstall"
end
end
system bin/"chpl", "--print-passes", "--print-commands", libexec/"examples/hello.chpl"
end
end
__END__
diff --git a/make/platform/Makefile.freebsd b/make/platform/Makefile.freebsd
deleted file mode 100644
index f5b09b9e9e..0000000000
--- a/make/platform/Makefile.freebsd
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright 2020-2021 Hewlett Packard Enterprise Development LP
-# Copyright 2004-2019 Cray Inc.
-# Other additional copyright holders may be indicated within.
-#
-# The entirety of this work is licensed under the Apache License,
-# Version 2.0 (the "License"); you may not use this file except
-# in compliance with the License.
-#
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-#
-# seemingly necessary to get dependencies, e.g. curl.h
-#
-RUNTIME_CFLAGS += -I/usr/local/include
-
-#
-# seemingly necessary to get dependencies, e.g. curl.h
-#
-GEN_CFLAGS += -I/usr/local/include
-
-#
-# seemingly necessary to get dependencies, e.g. libcurl.a
-#
-GEN_LFLAGS += -L/usr/local/lib
diff --git a/test/chpldoc/compflags/author/withoutAuthor/withoutAuthor.doc.good b/test/chpldoc/compflags/author/withoutAuthor/withoutAuthor.doc.good
index 239ef320af..09bdf2dfef 100644
--- a/test/chpldoc/compflags/author/withoutAuthor/withoutAuthor.doc.good
+++ b/test/chpldoc/compflags/author/withoutAuthor/withoutAuthor.doc.good
@@ -1 +1 @@
- &#169; Copyright n.
+ <p>&#169; Copyright n.</p>
diff --git a/test/chpldoc/compflags/folder/PREDIFF b/test/chpldoc/compflags/folder/PREDIFF
index cc51ec9c99..aadfb20696 100755
--- a/test/chpldoc/compflags/folder/PREDIFF
+++ b/test/chpldoc/compflags/folder/PREDIFF
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
sed -e '/^Running Sphinx v/,/^HTML files are at:/d' $2 > $2.tmp
-mv $2.tmp $2
+sed -e 's/due to:.*$/due to: _/g' $2.tmp > $2
diff --git a/test/chpldoc/compflags/folder/failToCreateDir.no-dir.doc.good b/test/chpldoc/compflags/folder/failToCreateDir.no-dir.doc.good
index 5576a65772..0f3b8aef9d 100644
--- a/test/chpldoc/compflags/folder/failToCreateDir.no-dir.doc.good
+++ b/test/chpldoc/compflags/folder/failToCreateDir.no-dir.doc.good
@@ -1 +1 @@
-error: Failed to create directory: fake-docs-root/deep/dir/docs due to: No such file or directory
+error: Failed to create directory: fake-docs-root/deep/dir/docs due to: _
diff --git a/test/chpldoc/compflags/folder/failToCreateDir.no-perm.doc.good b/test/chpldoc/compflags/folder/failToCreateDir.no-perm.doc.good
index 3127218cb0..adcc9c8125 100644
--- a/test/chpldoc/compflags/folder/failToCreateDir.no-perm.doc.good
+++ b/test/chpldoc/compflags/folder/failToCreateDir.no-perm.doc.good
@@ -1 +1 @@
-error: Failed to create directory: /docs due to: Permission denied
+error: Failed to create directory: /docs due to: _
diff --git a/test/library/packages/ProtobufProtocolSupport/anyRunner.skipif b/test/library/packages/ProtobufProtocolSupport/anyRunner.skipif
index 17da6c4392..b46578a86a 100755
--- a/test/library/packages/ProtobufProtocolSupport/anyRunner.skipif
+++ b/test/library/packages/ProtobufProtocolSupport/anyRunner.skipif
@@ -1,12 +1,12 @@
#!/usr/bin/env python3
-from distutils.spawn import find_executable
+from shutil import which
import os
chplPath = os.path.join(os.environ['CHPL_HOME'], "bin", os.environ['CHPL_HOST_BIN_SUBDIR'])
-if find_executable("protoc") is not None and find_executable("protoc-gen-chpl", path=chplPath) is not None:
+if which("protoc") is not None and which("protoc-gen-chpl", path=chplPath) is not None:
print(False)
else:
print(True)
diff --git a/third-party/chpl-venv/Makefile b/third-party/chpl-venv/Makefile
index eb227b116f..107cddb90f 100644
--- a/third-party/chpl-venv/Makefile
+++ b/third-party/chpl-venv/Makefile
@@ -6,6 +6,13 @@ CHPL_MAKE_HOST_TARGET = --host
include $(CHPL_MAKE_HOME)/make/Makefile.base
include $(THIRD_PARTY_DIR)/chpl-venv/Makefile.include
+# CHPL_PIP_INSTALL_PARAMS can be set to adjust the pip arguments,
+# but if you want to build from source, set CHPL_PIP_FROM_SOURCE
+
+ifdef CHPL_PIP_FROM_SOURCE
+ CHPL_PIP_INSTALL_PARAMS=--no-binary :all:
+endif
+
default: all
all: test-venv chpldoc-venv
@@ -20,51 +27,50 @@ clobber: FORCE clean
OLD_PYTHON_ERROR="python3 version 3.5 or later is required to install chpldoc and start_test dependencies. See https://www.python.org/"
-# Create the virtualenv to use during build.
-# (to allow for a different path to the system python3 in the future)
-$(CHPL_VENV_VIRTUALENV_DIR_OK):
+$(CHPL_VENV_VIRTUALENV_DIR_DEPS1_OK):
@# First check the python version is OK
- @case `$(PYTHON) --version` in \
- *"Python 3.0"*) \
- echo $(OLD_PYTHON_ERROR) ; \
- exit 1 ; \
- ;; \
- *"Python 3.1"*) \
- echo $(OLD_PYTHON_ERROR) ; \
- exit 1 ; \
- ;; \
- *"Python 3.2"*) \
- echo $(OLD_PYTHON_ERROR) ; \
- exit 1 ; \
- ;; \
- *"Python 3.3"*) \
- echo $(OLD_PYTHON_ERROR) ; \
- exit 1 ; \
- ;; \
- *"Python 3.4"*) \
- echo $(OLD_PYTHON_ERROR) ; \
- exit 1 ; \
- ;; \
- *"Python 3"*) \
- ;; \
- *) \
- echo $(OLD_PYTHON_ERROR) ; \
- exit 1 ; \
- ;; \
- esac
+ @if $(PYTHON) -c 'import sys; sys.exit(int(sys.version_info[:2] >= (3, 5)))'; then \
+ echo $(OLD_PYTHON_ERROR); \
+ exit 1; \
+ fi
@# Now create the venv to use to get the dependencies
$(PYTHON) -m venv $(CHPL_VENV_VIRTUALENV_DIR)
+ @# Now install wheel so we can pip install
+ export PATH="$(CHPL_VENV_VIRTUALENV_BIN):$$PATH" && \
+ export VIRTUAL_ENV=$(CHPL_VENV_VIRTUALENV_DIR) && \
+ $(PIP) install --upgrade \
+ $(CHPL_PIP_INSTALL_PARAMS) $(LOCAL_PIP_FLAGS) wheel && \
+ touch $(CHPL_VENV_VIRTUALENV_DIR_DEPS1_OK)
+
+ifdef CHPL_PIP_FROM_SOURCE
+$(CHPL_VENV_VIRTUALENV_DIR_DEPS2_OK): $(CHPL_VENV_VIRTUALENV_DIR_DEPS1_OK)
+ @# Now install source dependencies so we can build from source
export PATH="$(CHPL_VENV_VIRTUALENV_BIN):$$PATH" && \
export VIRTUAL_ENV=$(CHPL_VENV_VIRTUALENV_DIR) && \
- $(PIP) install \
- --upgrade $(CHPL_PIP_INSTALL_PARAMS) $(LOCAL_PIP_FLAGS) wheel && \
+ $(PIP) install --upgrade \
+ $(CHPL_PIP_INSTALL_PARAMS) $(LOCAL_PIP_FLAGS) \
+ -r $(CHPL_VENV_CHPLDOC_REQUIREMENTS_FILE1) && \
+ $(PIP) install --upgrade \
+ $(CHPL_PIP_INSTALL_PARAMS) $(LOCAL_PIP_FLAGS) \
+ -r $(CHPL_VENV_CHPLDOC_REQUIREMENTS_FILE2) && \
+ touch $(CHPL_VENV_VIRTUALENV_DIR_DEPS2_OK)
+
+else
+$(CHPL_VENV_VIRTUALENV_DIR_DEPS2_OK): $(CHPL_VENV_VIRTUALENV_DIR_DEPS1_OK)
+ touch $(CHPL_VENV_VIRTUALENV_DIR_DEPS2_OK)
+
+endif
+
+# Create the virtualenv to use during build.
+# (to allow for a different path to the system python3 in the future)
+$(CHPL_VENV_VIRTUALENV_DIR_OK): $(CHPL_VENV_VIRTUALENV_DIR_DEPS1_OK) $(CHPL_VENV_VIRTUALENV_DIR_DEPS2_OK)
touch $(CHPL_VENV_VIRTUALENV_DIR_OK)
# Phony convenience target for creating virtualenv.
create-virtualenv: $(CHPL_VENV_VIRTUALENV_DIR_OK)
-$(CHPL_VENV_CHPLDEPS_MAIN): $(CHPL_VENV_VIRTUALENV_DIR_OK) $(CHPL_VENV_TEST_REQUIREMENTS_FILE) $(CHPL_VENV_CHPLDOC_REQUIREMENTS_FILE) $(CHPL_VENV_C2CHAPEL_REQUIREMENTS_FILE) chpldeps-main.py
+$(CHPL_VENV_CHPLDEPS_MAIN): $(CHPL_VENV_VIRTUALENV_DIR_OK) $(CHPL_VENV_TEST_REQUIREMENTS_FILE) $(CHPL_VENV_CHPLDOC_REQUIREMENTS_FILE1) $(CHPL_VENV_CHPLDOC_REQUIREMENTS_FILE2) $(CHPL_VENV_CHPLDOC_REQUIREMENTS_FILE3) $(CHPL_VENV_C2CHAPEL_REQUIREMENTS_FILE) chpldeps-main.py
@# Install dependencies to $(CHPL_VENV_CHPLDEPS)
@# Rely on pip to create the directory
export PATH="$(CHPL_VENV_VIRTUALENV_BIN):$$PATH" && \
@@ -72,7 +78,9 @@ $(CHPL_VENV_CHPLDEPS_MAIN): $(CHPL_VENV_VIRTUALENV_DIR_OK) $(CHPL_VENV_TEST_REQU
$(PIP) install --upgrade $(CHPL_PIP_INSTALL_PARAMS) $(LOCAL_PIP_FLAGS) \
--target $(CHPL_VENV_CHPLDEPS) \
-r $(CHPL_VENV_TEST_REQUIREMENTS_FILE) \
- -r $(CHPL_VENV_CHPLDOC_REQUIREMENTS_FILE) \
+ -r $(CHPL_VENV_CHPLDOC_REQUIREMENTS_FILE1) \
+ -r $(CHPL_VENV_CHPLDOC_REQUIREMENTS_FILE2) \
+ -r $(CHPL_VENV_CHPLDOC_REQUIREMENTS_FILE3) \
-r $(CHPL_VENV_C2CHAPEL_REQUIREMENTS_FILE) && \
cp chpldeps-main.py $(CHPL_VENV_CHPLDEPS_MAIN)
@@ -89,8 +97,7 @@ install-requirements: install-chpldeps
$(CHPL_VENV_CHPLSPELL_REQS): $(CHPL_VENV_VIRTUALENV_DIR_OK) $(CHPL_VENV_CHPLSPELL_REQUIREMENTS_FILE)
export PATH="$(CHPL_VENV_VIRTUALENV_BIN):$$PATH" && \
export VIRTUAL_ENV=$(CHPL_VENV_VIRTUALENV_DIR) && \
- $(PIP) install \
- --upgrade $(CHPL_PIP_INSTALL_PARAMS) $(LOCAL_PIP_FLAGS) \
+ $(PIP) install --upgrade $(CHPL_PIP_INSTALL_PARAMS) $(LOCAL_PIP_FLAGS) \
-r $(CHPL_VENV_CHPLSPELL_REQUIREMENTS_FILE) && \
touch $(CHPL_VENV_CHPLSPELL_REQS)
diff --git a/third-party/chpl-venv/Makefile.include b/third-party/chpl-venv/Makefile.include
index c5dbed5700..aa1121631b 100644
--- a/third-party/chpl-venv/Makefile.include
+++ b/third-party/chpl-venv/Makefile.include
@@ -6,7 +6,9 @@
CHPL_VENV_DIR=$(shell cd $(THIRD_PARTY_DIR)/chpl-venv && pwd)
CHPL_VENV_TEST_REQUIREMENTS_FILE=$(CHPL_VENV_DIR)/test-requirements.txt
-CHPL_VENV_CHPLDOC_REQUIREMENTS_FILE=$(CHPL_VENV_DIR)/chpldoc-requirements.txt
+CHPL_VENV_CHPLDOC_REQUIREMENTS_FILE1=$(CHPL_VENV_DIR)/chpldoc-requirements1.txt
+CHPL_VENV_CHPLDOC_REQUIREMENTS_FILE2=$(CHPL_VENV_DIR)/chpldoc-requirements2.txt
+CHPL_VENV_CHPLDOC_REQUIREMENTS_FILE3=$(CHPL_VENV_DIR)/chpldoc-requirements3.txt
CHPL_VENV_C2CHAPEL_REQUIREMENTS_FILE=$(CHPL_VENV_DIR)/c2chapel-requirements.txt
CHPL_VENV_CHPLSPELL_REQUIREMENTS_FILE=$(CHPL_VENV_DIR)/chplspell-requirements.txt
@@ -23,6 +25,8 @@ PIP=$(PYTHON) -m pip
CHPL_VENV_BUILD=$(CHPL_VENV_DIR)/build
CHPL_VENV_VIRTUALENV_DIR=$(CHPL_VENV_BUILD)/build-venv
CHPL_VENV_VIRTUALENV_DIR_OK=$(CHPL_VENV_BUILD)/build-venv/ok
+CHPL_VENV_VIRTUALENV_DIR_DEPS1_OK=$(CHPL_VENV_BUILD)/build-venv/ok1
+CHPL_VENV_VIRTUALENV_DIR_DEPS2_OK=$(CHPL_VENV_BUILD)/build-venv/ok2
CHPL_VENV_VIRTUALENV_BIN=$(CHPL_VENV_VIRTUALENV_DIR)/bin
CHPL_VENV_INSTALL=$(CHPL_VENV_DIR)/install
CHPL_VENV_CHPLDEPS=$(CHPL_VENV_INSTALL)/chpldeps
diff --git a/third-party/chpl-venv/chpldoc-requirements.txt b/third-party/chpl-venv/chpldoc-requirements.txt
deleted file mode 100644
index 864a42a56e..0000000000
--- a/third-party/chpl-venv/chpldoc-requirements.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-Jinja2==3.0.1
-MarkupSafe==2.0.1
-Pygments==2.9.0
-Sphinx==4.0.2
-docutils==0.16.0
-sphinx-rtd-theme==0.5.2
-sphinxcontrib-chapeldomain==0.0.20
-babel==2.9.1
-breathe==4.30.0
diff --git a/third-party/chpl-venv/chpldoc-requirements1.txt b/third-party/chpl-venv/chpldoc-requirements1.txt
new file mode 100644
index 0000000000..cf92ecfefc
--- /dev/null
+++ b/third-party/chpl-venv/chpldoc-requirements1.txt
@@ -0,0 +1,2 @@
+# Split into 3 files to work around problems with CHPL_PIP_FROM_SOURCE
+MarkupSafe==2.0.1
diff --git a/third-party/chpl-venv/chpldoc-requirements2.txt b/third-party/chpl-venv/chpldoc-requirements2.txt
new file mode 100644
index 0000000000..aea4b40ac2
--- /dev/null
+++ b/third-party/chpl-venv/chpldoc-requirements2.txt
@@ -0,0 +1,6 @@
+# Split into 3 files to work around problems with CHPL_PIP_FROM_SOURCE
+Jinja2==3.0.1
+Pygments==2.9.0
+Sphinx==4.3.2
+docutils==0.16.0
+babel==2.9.1
diff --git a/third-party/chpl-venv/chpldoc-requirements3.txt b/third-party/chpl-venv/chpldoc-requirements3.txt
new file mode 100644
index 0000000000..d4df5d3421
--- /dev/null
+++ b/third-party/chpl-venv/chpldoc-requirements3.txt
@@ -0,0 +1,4 @@
+# Split into 3 files to work around problems with CHPL_PIP_FROM_SOURCE
+sphinx-rtd-theme==1.0.0
+sphinxcontrib-chapeldomain==0.0.21
+breathe==4.31.0
diff --git a/util/chplenv/chpl_llvm.py b/util/chplenv/chpl_llvm.py
index 99e918e947..caf9afe480 100755
--- a/util/chplenv/chpl_llvm.py
+++ b/util/chplenv/chpl_llvm.py
@@ -110,10 +110,16 @@ def check_llvm_config(llvm_config):
@memoize
def find_system_llvm_config():
+ llvm_config = overrides.get('CHPL_LLVM_CONFIG', 'none')
+ if llvm_config != 'none':
+ return llvm_config
+
paths = [ ]
for vers in llvm_versions():
paths.append("llvm-config-" + vers + ".0")
paths.append("llvm-config-" + vers)
+ # this format used by freebsd
+ paths.append("llvm-config" + vers)
# next ones are for Homebrew
paths.append("/usr/local/opt/llvm@" + vers + ".0/bin/llvm-config")
paths.append("/usr/local/opt/llvm@" + vers + "/bin/llvm-config")
@@ -299,7 +305,14 @@ def llvm_enabled():
def get_gcc_prefix():
gcc_prefix = overrides.get('CHPL_LLVM_GCC_PREFIX', '')
+
if not gcc_prefix:
+ # darwin and FreeBSD default to clang
+ # so shouldn't need GCC prefix
+ host_platform = chpl_platform.get('host')
+ if host_platform == "darwin" or host_platform == "freebsd":
+ return ''
+
# When 'gcc' is a command other than '/usr/bin/gcc',
# compute the 'gcc' prefix that LLVM should use.
gcc_path = find_executable('gcc')
@@ -402,12 +415,16 @@ def get_clang_additional_args():
if arg == '-isysroot':
has_sysroot = True
- if has_sysroot:
- # Work around a bug in some versions of Clang that forget to
+ # Check to see if Homebrew is installed. If it is,
+ # add the result of `brew prefix` to -I and -L args.
+ exists, retcode, my_out, my_err = try_run_command(['brew', '--prefix'])
+ if exists and retcode == 0:
+ # Make sure to include homebrew search path
+ homebrew_prefix = my_out.strip()
# search /usr/local/include and /usr/local/lib
# if there is a -isysroot argument.
- comp_args.append('-I/usr/local/include')
- link_args.append('-L/usr/local/lib')
+ comp_args.append('-I' + homebrew_prefix + '/include')
+ link_args.append('-L' + homebrew_prefix + '/lib')
return (comp_args, link_args)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment