Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

llvm@11, chapel: migrate to Python 3.10 #90708

Closed
wants to merge 2 commits into from

Conversation

XuehaiPan
Copy link
Contributor

Migrate llvm@11 family to Python 3.10. See #87075 (comment)

@BrewTestBot BrewTestBot added the python Python use is a significant feature of the PR or issue label Dec 8, 2021
@carlocab
Copy link
Member

carlocab commented Dec 8, 2021

Needs CI-long-timeout. Let's wait for the CI queue to clear up a bit before doing that though.

@carlocab carlocab added CI-long-timeout [DEPRECATED] Use longer GitHub Actions CI timeout. and removed CI-long-timeout [DEPRECATED] Use longer GitHub Actions CI timeout. labels Dec 8, 2021
@iMichka iMichka added CI-long-timeout [DEPRECATED] Use longer GitHub Actions CI timeout. CI-linux-self-hosted Build on Linux self-hosted runner CI-no-fail-fast Continue CI tests despite failing GitHub Actions matrix builds. labels Dec 13, 2021
@iMichka
Copy link
Member

iMichka commented Dec 14, 2021

2021-12-14T06:18:57.1166640Z �[34m==>�[0m �[1mbrew audit chapel --online --git --skip-style�[0m
2021-12-14T06:19:05.7617800Z �[31m==>�[0m �[1m�[31mFAILED�[0m�[0m
2021-12-14T06:19:05.7629790Z ##[group]Full audit chapel --online --git --skip-style output
2021-12-14T06:19:05.7630420Z chapel:
2021-12-14T06:19:05.7631250Z   * Binaries built for a non-native architecture were installed into chapel's prefix.
2021-12-14T06:19:05.7631930Z     The offending files are:
2021-12-14T06:19:05.7632930Z       /opt/homebrew/Cellar/chapel/1.25.0_2/libexec/third-party/qthread/qthread-src/installed/lib/libqthread.19.dylib	(x86_64)
2021-12-14T06:19:05.7633810Z     Unexpected universal binaries were found.
2021-12-14T06:19:05.7634300Z     The offending files are:
2021-12-14T06:19:05.7635420Z       /opt/homebrew/Cellar/chapel/1.25.0_2/libexec/third-party/chpl-venv/install/chpldeps/markupsafe/_speedups.cpython-310-darwin.so
2021-12-14T06:19:05.7636400Z   * Libraries were compiled with a flat namespace.
2021-12-14T06:19:05.7636940Z     This can cause linker errors due to name collisions, and
2021-12-14T06:19:05.7637460Z     is often due to a bug in detecting the macOS version.
2021-12-14T06:19:05.7638520Z       /opt/homebrew/Cellar/chapel/1.25.0_2/libexec/third-party/gmp/install/darwin-arm64-native-clang-none/lib/libgmp.10.dylib
2021-12-14T06:19:05.7639920Z       /opt/homebrew/Cellar/chapel/1.25.0_2/libexec/third-party/gmp/install/darwin-arm64-native-llvm-none/lib/libgmp.10.dylib
2021-12-14T06:19:05.7649500Z �[31mError:�[0m 2 problems in 1 formula detected

@iMichka iMichka removed the CI-long-timeout [DEPRECATED] Use longer GitHub Actions CI timeout. label Dec 14, 2021
mppf added a commit to chapel-lang/chapel that referenced this pull request Dec 15, 2021
fix(makefile): support python 3.10

[PR by @branchvincent - thanks! Reviewed, tested, and merged by @mppf]

This fixes a bug detecting the current Python version, noticed when building with Python 3.10 in Homebrew/homebrew-core#90708

Before:

```console
$ make -C third-party/chpl-venv test-venv PYTHON=python3.10
python3 version 3.5 or later is required to install chpldoc and start_test dependencies. See https://www.python.org/
```

After:

```console
$ make -C third-party/chpl-venv test-venv PYTHON=python3.10
...
Successfully installed ...
```
@iMichka iMichka added the CI-long-timeout [DEPRECATED] Use longer GitHub Actions CI timeout. label Dec 21, 2021
@iMichka
Copy link
Member

iMichka commented Dec 21, 2021

chapel was fixed in #91257. Rebased.

@iMichka
Copy link
Member

iMichka commented Dec 21, 2021

Collecting breathe==4.30.0
  Downloading breathe-4.30.0.tar.gz (82 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'error'
  ERROR: Command errored out with exit status 1:
   command: /opt/homebrew/Cellar/chapel/1.25.1_1/libexec/third-party/chpl-venv/build/build-venv/bin/python3 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-aji4udoc/breathe_f963b1e178e4496e97476b20a3cc4462/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-aji4udoc/breathe_f963b1e178e4496e97476b20a3cc4462/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/tmp/pip-pip-egg-info-6nsocf1v
       cwd: /private/tmp/pip-install-aji4udoc/breathe_f963b1e178e4496e97476b20a3cc4462/
  Complete output (23 lines):
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/private/tmp/pip-install-aji4udoc/breathe_f963b1e178e4496e97476b20a3cc4462/setup.py", line 10, in <module>
      from breathe import __version__
    File "/private/tmp/pip-install-aji4udoc/breathe_f963b1e178e4496e97476b20a3cc4462/breathe/__init__.py", line 1, in <module>
      from . import directives
    File "/private/tmp/pip-install-aji4udoc/breathe_f963b1e178e4496e97476b20a3cc4462/breathe/directives.py", line 1, in <module>
      from breathe.directive.base import create_warning
    File "/private/tmp/pip-install-aji4udoc/breathe_f963b1e178e4496e97476b20a3cc4462/breathe/directive/base.py", line 1, in <module>
      from breathe.finder.factory import FinderFactory
    File "/private/tmp/pip-install-aji4udoc/breathe_f963b1e178e4496e97476b20a3cc4462/breathe/finder/__init__.py", line 1, in <module>
      from breathe.project import ProjectInfo
    File "/private/tmp/pip-install-aji4udoc/breathe_f963b1e178e4496e97476b20a3cc4462/breathe/project.py", line 4, in <module>
      from sphinx.application import Sphinx
    File "/opt/homebrew/Cellar/chapel/1.25.1_1/libexec/third-party/chpl-venv/build/build-venv/lib/python3.10/site-packages/sphinx/application.py", line 31, in <module>
      from sphinx.config import Config
    File "/opt/homebrew/Cellar/chapel/1.25.1_1/libexec/third-party/chpl-venv/build/build-venv/lib/python3.10/site-packages/sphinx/config.py", line 21, in <module>
      from sphinx.util import logging
    File "/opt/homebrew/Cellar/chapel/1.25.1_1/libexec/third-party/chpl-venv/build/build-venv/lib/python3.10/site-packages/sphinx/util/__init__.py", line 41, in <module>
      from sphinx.util.typing import PathMatcher
    File "/opt/homebrew/Cellar/chapel/1.25.1_1/libexec/third-party/chpl-venv/build/build-venv/lib/python3.10/site-packages/sphinx/util/typing.py", line 37, in <module>
      from types import Union as types_Union
  ImportError: cannot import name 'Union' from 'types' (/opt/homebrew/Cellar/[email protected]/3.10.1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/types.py)
  ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/95/76/0c9adb4b20082091a0236e558797455ce819b0d9db86570c9a01139c66e2/breathe-4.30.0.tar.gz#sha256=363dec85abc0c4b3f22628b0cf82cc2dc46c4397d8a18312d1a7d1365d49b014 (from https://pypi.org/simple/breathe/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement breathe==4.30.0 (from versions: 0.7.0, 0.7.5, 1.0.0, 1.1.0, 1.2.0, 2.0.0, 3.0.0, 3.1.0, 3.2.0, 4.0.0, 4.1.0, 4.2.0, 4.3.0, 4.3.1, 4.4.0, 4.5.0, 4.6.0, 4.7.0, 4.7.1, 4.7.2, 4.7.3, 4.8.0, 4.9.0, 4.9.1, 4.10.0, 4.11.0, 4.11.1, 4.12.0, 4.13.0, 4.13.0.post0, 4.13.1, 4.14.0, 4.14.1, 4.14.2, 4.15.0, 4.16.0, 4.17.0, 4.18.0, 4.18.1, 4.19.0, 4.19.1, 4.19.2, 4.20.0, 4.21.0, 4.22.0, 4.22.1, 4.23.0, 4.24.0, 4.24.1, 4.25.0, 4.25.1, 4.26.0, 4.26.1, 4.27.0, 4.28.0, 4.29.0, 4.29.1, 4.29.2, 4.30.0, 4.31.0)
ERROR: No matching distribution found for breathe==4.30.0
make[2]: *** [/opt/homebrew/Cellar/chapel/1.25.1_1/libexec/third-party/chpl-venv/install/chpldeps/__main__.py] Error 1
make[1]: *** [test-venv] Error 2
make: *** [third-party-test-venv] Error 2

@iMichka
Copy link
Member

iMichka commented Dec 21, 2021

There was a commit to sphinx to fix this: sphinx-doc/sphinx@36e06d6

Need to check how this is can be fixed in chapel first. @Maxrimus, @bradcray, @mppf or @ronawho might know how to help.
We are trying to migrate to Python 3.10 and are getting the error you can see in the message just above.

@lydia-duncan
Copy link

lydia-duncan commented Dec 21, 2021

Hi - sorry, most of the folks you've pinged are on holiday break right now. I don't know much about homebrew formulas and such, but it does look like updating the Sphinx version we rely on to 4.3.2 doesn't cause problems for us and should include the commit you mentioned.

So I think modifying line 195 and 217 to use 4.3.2 would be okay?

@lydia-duncan
Copy link

I've opened chapel-lang/chapel#18894 on our repo, if that helps with adjusting the patches at the end of the formula

@SMillerDev SMillerDev removed the CI-long-timeout [DEPRECATED] Use longer GitHub Actions CI timeout. label Dec 22, 2021
@lydia-duncan
Copy link

In looking at the failure on that PR, this is not just a simple change, I believe we need to update a separate repository we distribute so that it's compatible with the new version of Sphinx. I'll be taking a deeper look, but since the majority of our team are on holiday break, it might not be able to be reviewed until the new year. What's your timeframe on making this change?

@carlocab
Copy link
Member

I don't think this is urgent. It can wait till people have come back from holidays.

@mlevkov
Copy link

mlevkov commented Jan 6, 2022

Hello, just curious to know if this is on the plate to be resolved soon? I'd very much appreciate your input. Thank you all for all you do.

@lydia-duncan
Copy link

Yup, I've got the update to our alternate repo made and have a PR incorporating it into our main repo. I expect it to go in soon, thank you for your patience :)

@lydia-duncan
Copy link

chapel-lang/chapel#18894 has been merged and appears to be passing our nightly testing so far. Only one of the file changes is relevant to homebrew, the adjustments to third-party/chpl-venv/chpldoc-requirements.txt.

@mppf also merged a PR this morning to integrate the patches we'd included as part of the Chapel formula into the main repo itself, which performs the split of that file into three files and includes the changes from my PR: chapel-lang/chapel#18926

I'd advise waiting until that second PR has had a night of testing on it but I think we're probably in good shape. Is there anything more we can do to help?

@lydia-duncan
Copy link

Second PR was clean!

@iMichka
Copy link
Member

iMichka commented Jan 31, 2022

I tried to apply the patches to chapel 1.25.1, but some of them don't apply.
So unless someone provides backported patches, it might be hard to do.
If the patches are given, I can add them to the formula and trigger a rebuild.

But we might wait for March/April. I would like to move the Python 3.10 migration forward, but I also know this takes time so we have plenty of other formulae to fix until this one is ready.

@lydia-duncan
Copy link

Can you go more into what you tried and how it didn't work?

@XuehaiPan
Copy link
Contributor Author

So unless someone provides backported patches, it might be hard to do.

These patches are already hosted on GitHub. They can download by <PR URL>.patch or <PR URL>.diff:

@XuehaiPan
Copy link
Contributor Author

Can you go more into what you tried and how it didn't work?

Install chapel 1.25.1 with patch 18894 and 18926:

diff --git a/Formula/chapel.rb b/Formula/chapel.rb
index 0eebb5cba99..fddf02c3b27 100644
--- a/Formula/chapel.rb
+++ b/Formula/chapel.rb
@@ -4,6 +4,7 @@ class Chapel < Formula
   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"
@@ -16,11 +17,21 @@ class Chapel < Formula
 
   depends_on "gmp"
   depends_on "llvm@11"
-  depends_on "[email protected]"
+  depends_on "[email protected]"
 
   # can be removed after https://github.com/chapel-lang/chapel/pull/18880 merged
   patch :DATA
 
+  patch do
+    url "https://github.com/chapel-lang/chapel/pull/18894.patch"
+    sha256 "ff27ffcd76aa89b3b7722b02918bfe3d315469b398bdc9b47e7ee2285246ebe6"
+  end
+
+  patch do
+    url "https://github.com/chapel-lang/chapel/pull/18926.patch"
+    sha256 "c888619ca8e7dc29cb054b137af82b0d9ace42dc3e040182fdc98eaede39f48a"
+  end
+
   def install
     libexec.install Dir["*"]
     # Chapel uses this ENV to work out where to install.
diff --git a/Formula/[email protected] b/Formula/[email protected]
index 1e76fbe2e94..b7ce2827671 100644
--- a/Formula/[email protected]
+++ b/Formula/[email protected]
@@ -5,7 +5,7 @@ class LlvmAT11 < Formula
   sha256 "74d2529159fd118c3eac6f90107b5611bccc6f647fdea104024183e8d5e25831"
   # The LLVM Project is under the Apache License v2.0 with LLVM Exceptions
   license "Apache-2.0" => { with: "LLVM-exception" }
-  revision 3
+  revision 4
 
   # This should be removed when LLVM 13 is released, so we only check the
   # current version (the `llvm` formula) and one major version before it
@@ -35,7 +35,7 @@ class LlvmAT11 < Formula
   # See: Homebrew/homebrew-core/issues/35513
   depends_on "cmake" => :build
   depends_on "swig" => :build
-  depends_on "[email protected]"
+  depends_on "[email protected]"
 
   uses_from_macos "libedit"
   uses_from_macos "libffi", since: :catalina

Got:

==> Installing chapel
==> Patching
==> Applying 18894.patch
patching file third-party/chpl-venv/chpldoc-requirements.txt
Hunk #1 succeeded at 1 with fuzz 2.
patching file third-party/chpl-venv/chpldoc-requirements.txt
Hunk #1 succeeded at 6 with fuzz 1.
patching file third-party/chpl-venv/chpldoc-requirements.txt
Hunk #1 FAILED at 4.
1 out of 1 hunk FAILED -- saving rejects to file third-party/chpl-venv/chpldoc-requirements.txt.rej
can't find file to patch at input line 101
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|
|From 4b5f1ea7e41d1b0891e1c909a5f33daecaf6e937 Mon Sep 17 00:00:00 2001
|From: Lydia Duncan <[email protected]>
|Date: Thu, 6 Jan 2022 15:22:46 -0600
|Subject: [PATCH 4/4] Replace use of distutils.spawn.find_executable with
| shutils.which in skipif
|
|distutils is deprecated in Python 3.10 and will be removed in Python 3.12.
|shutils.which has existed since Python 3.3 so should be usable in its place
|
|----
|Signed-off-by: Lydia Duncan <[email protected]>
|---
| .../library/packages/ProtobufProtocolSupport/anyRunner.skipif | 4 ++--
| 1 file changed, 2 insertions(+), 2 deletions(-)
|
|diff --git a/test/library/packages/ProtobufProtocolSupport/anyRunner.skipif b/test/library/packages/ProtobufProtocolSupport/anyRunner.skipif
|index 17da6c43929..b46578a86a9 100755
|--- a/test/library/packages/ProtobufProtocolSupport/anyRunner.skipif
|+++ b/test/library/packages/ProtobufProtocolSupport/anyRunner.skipif
--------------------------
No file to patch.  Skipping patch.
1 out of 1 hunk ignored

@mppf
Copy link

mppf commented Feb 2, 2022

Right I would expect that git can apply the patches in those PRs cleanly if you cherry pick them starting from the 1.25.1 release branch.

But also note that the 1.25.1 chapel.rb has patches at the bottom. To get everything to apply cleanly, we need to regenerate the patches for chapel.rb to include the changes needed in the formula from chapel-lang/chapel#18894 and chapel-lang/chapel#18926 .

The PR chapel-lang/chapel#18880 has a summary of patches that were included in the formula. Going to the individual PRs and grabbing commit shas led me to these commands:

# starting from a git clone of chapel main
git checkout 1.25.1
# these commits are from PR 18820 (was already in formula)
git cherry-pick 0b994b00b165463bdd57fbad127beac0e54a1371 d928be2a849d74dd35f7e20aff5c5fceb60cffce
# these commits are from PR 18857 (was already in formula)
git cherry-pick a70bf57c6f1cb1a25b6a597a61bfbb14a7b9cc96
# these commits are from PR 18894 (was not yet in formula)
git cherry-pick 007373efb703c5b9ab0e4ddb326e7088292d4e67 aa59486ece5d884b7b3d5075b43b1583536984dd 9e49eba6f11419796798bc979a15fed69632f42a 4b5f1ea7e41d1b0891e1c909a5f33daecaf6e937
# these commits are are from PR 18926 (a similar change was in the formula)
git cherry-pick 2e8711055fd240c4a469083684094712f7a2462e af29e6e1c5b4e5bcdb5888f1e9bd64060b031647 a6f377e6a457d46e7e05ff829767d5eb5200e205 ab8bd0368a33d6bc3247b7b40694bc0bf944c9ef 0863f384eb3abd636de266c7803950937c73f9aa cb7bdf64cf18f5a5dad69031d7b79e168fdca2d5
# this commit from PR 18880 was in the earlier formula
git cherry-pick 60df1925ad6ee77e774205054fd0022f2755474c

From there I grabbed the chapel.rb from this PR and made these changes:

  • removed the diffs after the __END__
  • used git diff 1.25.1 >> chapel.rb to regenerate them. Please note that this diff is sensitive to spaces vs tabs because it changes Makefile rules.
  • changed lines like with_env(CHPL_PIP_INSTALL_PARAMS: "--no-binary :all:") to with_env(CHPL_PIP_FROM_SOURCE: "1") as per the note in PR Allow installing pip dependencies from source chapel-lang/chapel#18926

I have uploaded the resulting chapel.rb to https://gist.github.com/mppf/32869664c6bb251dcd1101d783763780 but I have not tested it at all. Hope that is helpful to you & you can either re-run the commands above or use that file.

@mppf
Copy link

mppf commented Feb 2, 2022

Oh, I think I forgot to include one commit from PR chapel-lang/chapel#18880 in the above -- chapel-lang/chapel@60df192 . I will update it.

@mppf
Copy link

mppf commented Feb 2, 2022

OK I've edited my previous comment to fix it to include chapel-lang/chapel@60df192 . Next step is to try some testing. (I am not planning to do that, myself, right now).

@XuehaiPan
Copy link
Contributor Author

XuehaiPan commented Feb 3, 2022

I removed some unrelated diffs in patch https://gist.github.com/mppf/32869664c6bb251dcd1101d783763780. Then, I can build chapel 1.25.1 with Python 3.10 successfully in Ubuntu 20.04 docker container.

For testing, I got:

$ brew install -s llvm@11
$ brew install -s chapel

$ brew test chapel
==> Testing chapel
==> util/test/checkChplInstall
Last 15 lines from /home/linuxbrew/.cache/Homebrew/Logs/chapel/test.01.checkChplInstall:
[Info] Compiling $CHPL_HOME/examples/hello6-taskpar-dist.chpl
[Info] Compiling with CHPL_TARGET_COMPILER=
[Fail] Test job failed to compile - Chapel is not installed correctly
[Fail] Compilation output:
Traceback (most recent call last):
  File "/home/linuxbrew/.linuxbrew/Cellar/chapel/1.25.1_1/libexec/util/chplenv/printchplenv.py", line 48, in <module>
    from chplenv import *
  File "/home/linuxbrew/.linuxbrew/Cellar/chapel/1.25.1_1/libexec/util/chplenv/chplenv.py", line 1, in <module>
    import chpl_cpu
  File "/home/linuxbrew/.linuxbrew/Cellar/chapel/1.25.1_1/libexec/util/chplenv/chpl_cpu.py", line 9, in <module>
    import chpl_comm, chpl_compiler, chpl_platform, overrides
  File "/home/linuxbrew/.linuxbrew/Cellar/chapel/1.25.1_1/libexec/util/chplenv/chpl_compiler.py", line 6, in <module>
    from distutils.spawn import find_executable
ModuleNotFoundError: No module named 'distutils.spawn'
error: 'CHPL_HOME=/home/linuxbrew/.linuxbrew/Cellar/chapel/1.25.1_1/libexec CHPL_RUNTIME_INCL=/home/linuxbrew/.linuxbrew/Cellar/chapel/1.25.1_1/libexec/runtime/include CHPL_RUNTIME_LIB=/home/linuxbrew/.linuxbrew/Cellar/chapel/1.25.1_1/libexec/lib CHPL_THIRD_PARTY=/home/linuxbrew/.linuxbrew/Cellar/chapel/1.25.1_1/libexec/third-party CHPLENV_SUPPRESS_WARNINGS=true /home/linuxbrew/.linuxbrew/Cellar/chapel/1.25.1_1/libexec/util/printchplenv --all --internal --no-tidy --simple' did not run successfully
Error: chapel: failed
An exception occurred within a child process:
  BuildError: Failed executing: util/test/checkChplInstall
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula.rb:2309:in `block in system'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula.rb:2245:in `open'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula.rb:2245:in `system'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/chapel.rb:81:in `block (3 levels) in <class:Chapel>'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/utils.rb:588:in `with_env'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/chapel.rb:80:in `block (2 levels) in <class:Chapel>'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.8/lib/ruby/2.6.0/fileutils.rb:128:in `chdir'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.8/lib/ruby/2.6.0/fileutils.rb:128:in `cd'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/chapel.rb:79:in `block in <class:Chapel>'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula.rb:2109:in `block (3 levels) in run_test'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/utils.rb:588:in `with_env'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula.rb:2108:in `block (2 levels) in run_test'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula.rb:948:in `with_logging'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula.rb:2107:in `block in run_test'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/mktemp.rb:63:in `block in run'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/mktemp.rb:63:in `chdir'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/mktemp.rb:63:in `run'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula.rb:2360:in `mktemp'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula.rb:2101:in `run_test'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/test.rb:43:in `block in <main>'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.8/lib/ruby/2.6.0/timeout.rb:93:in `block in timeout'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.8/lib/ruby/2.6.0/timeout.rb:33:in `block in catch'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.8/lib/ruby/2.6.0/timeout.rb:33:in `catch'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.8/lib/ruby/2.6.0/timeout.rb:33:in `catch'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.8/lib/ruby/2.6.0/timeout.rb:108:in `timeout'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/test.rb:48:in `<main>'

distutils is removed from Python 3.10. There are still many find_executable in the upstream repository.

from distutils.spawn import find_executable

I make a new patch for this:

distutils.core.setup            --> setuptools.setup
distutils.spawn.find_executable --> shutil.which
--- a/third-party/llvm/llvm-src/tools/clang/utils/check_cfc/setup.py
+++ b/third-party/llvm/llvm-src/tools/clang/utils/check_cfc/setup.py
@@ -2,7 +2,12 @@
     python.exe setup.py py2exe
     """
 from __future__ import absolute_import, division, print_function
-from distutils.core import setup
+
+try:
+    from distutils.core import setup
+except ImportError:
+    from setuptools import setup
+
 try:
     import py2exe
 except ImportError:

--- a/third-party/llvm/llvm-src/tools/clang/utils/creduce-clang-crash.py
+++ b/third-party/llvm/llvm-src/tools/clang/utils/creduce-clang-crash.py
@@ -18,7 +18,6 @@ import pipes
 import shlex
 import tempfile
 import shutil
-from distutils.spawn import find_executable

 verbose = False
 creduce_cmd = None
@@ -43,12 +42,12 @@ def check_cmd(cmd_name, cmd_dir, cmd_path=None):
   if cmd_path:
     # Make the path absolute so the creduce test can be run from any directory.
     cmd_path = os.path.abspath(cmd_path)
-    cmd = find_executable(cmd_path)
+    cmd = shutil.which(cmd_path)
     if cmd:
       return cmd
     sys.exit("ERROR: executable `%s` not found" % (cmd_path))

-  cmd = find_executable(cmd_name, path=cmd_dir)
+  cmd = shutil.which(cmd_name, path=cmd_dir)
   if cmd:
     return cmd

--- a/third-party/llvm/llvm-src/utils/update_cc_test_checks.py
+++ b/third-party/llvm/llvm-src/utils/update_cc_test_checks.py
@@ -16,11 +16,11 @@ from __future__ import print_function

 import argparse
 import collections
-import distutils.spawn
 import json
 import os
 import re
 import shlex
+import shutil
 import subprocess
 import sys
 import tempfile
@@ -139,7 +139,7 @@ def config():
       args.clang = 'clang'
     else:
       args.clang = os.path.join(args.llvm_bin, 'clang')
-  if not distutils.spawn.find_executable(args.clang):
+  if not shutil.which(args.clang):
     print('Please specify --llvm-bin or --clang', file=sys.stderr)
     sys.exit(1)

@@ -160,7 +160,7 @@ def config():
       args.opt = 'opt'
     else:
       args.opt = os.path.join(args.llvm_bin, 'opt')
-  if not distutils.spawn.find_executable(args.opt):
+  if not shutil.which(args.opt):
     # Many uses of this tool will not need an opt binary, because it's only
     # needed for updating a test that runs clang | opt | FileCheck. So we
     # defer this error message until we find that opt is actually needed.

--- a/util/chplenv/chpl_compiler.py
+++ b/util/chplenv/chpl_compiler.py
@@ -1,10 +1,9 @@
 #!/usr/bin/env python3
 import optparse
 import os
+import shutil
 import sys

-from distutils.spawn import find_executable
-
 import chpl_platform, overrides
 from utils import error, memoize, warning

@@ -193,7 +192,7 @@ def get(flag='host'):
         elif platform_val.startswith('pwr'):
             compiler_val = 'ibm'
         elif platform_val == 'darwin' or platform_val == 'freebsd':
-            if find_executable('clang'):
+            if shutil.which('clang'):
                 compiler_val = 'clang'
             else:
                 compiler_val = 'gnu'

--- a/util/chplenv/chpl_launcher.py
+++ b/util/chplenv/chpl_launcher.py
@@ -1,5 +1,5 @@
 #!/usr/bin/env python3
-from distutils.spawn import find_executable
+import shutil
 import sys

 import chpl_comm, chpl_comm_substrate, chpl_platform, overrides
@@ -7,7 +7,7 @@ from utils import error, memoize, warning

 def slurm_prefix(base_launcher, platform_val):
     """ If salloc is available and we're on a cray-cs/hpe-apollo, prefix with slurm-"""
-    if platform_val in ('cray-cs', 'hpe-apollo') and find_executable('salloc'):
+    if platform_val in ('cray-cs', 'hpe-apollo') and shutil.which('salloc'):
         return 'slurm-{}'.format(base_launcher)
     return base_launcher

@@ -29,8 +29,8 @@ def get():
         platform_val = chpl_platform.get('target')

         if platform_val.startswith('cray-x') or platform_val.startswith('hpe-cray-'):
-            has_aprun = find_executable('aprun')
-            has_slurm = find_executable('srun')
+            has_aprun = shutil.which('aprun')
+            has_slurm = shutil.which('srun')
             if has_aprun and has_slurm:
                 launcher_val = 'none'
             elif has_aprun:
@@ -60,7 +60,7 @@ def get():
             elif substrate_val == 'ofi':
                 launcher_val = slurm_prefix('gasnetrun_ofi', platform_val)
         else:
-            if platform_val in ('cray-cs', 'hpe-apollo') and find_executable('srun'):
+            if platform_val in ('cray-cs', 'hpe-apollo') and shutil.which('srun'):
                 launcher_val = 'slurm-srun'
             else:
                 launcher_val = 'none'

--- a/util/chplenv/chpl_llvm.py
+++ b/util/chplenv/chpl_llvm.py
@@ -1,8 +1,8 @@
 #!/usr/bin/env python3
 import optparse
 import os
+import shutil
 import sys
-from distutils.spawn import find_executable
 import re

 import chpl_bin_subdir, chpl_arch, chpl_compiler, chpl_platform, overrides
@@ -302,7 +302,7 @@ def get_gcc_prefix():
     if not gcc_prefix:
         # When 'gcc' is a command other than '/usr/bin/gcc',
         # compute the 'gcc' prefix that LLVM should use.
-        gcc_path = find_executable('gcc')
+        gcc_path = shutil.which('gcc')
         if gcc_path == '/usr/bin/gcc' :
             # In this common case, nothing else needs to be done,
             # because we can assume that clang can find this gcc.

--- a/util/chplenv/chpl_make.py
+++ b/util/chplenv/chpl_make.py
@@ -1,5 +1,5 @@
 #!/usr/bin/env python3
-from distutils.spawn import find_executable
+import shutil
 import sys

 import chpl_platform, overrides
@@ -14,7 +14,7 @@ def get():
         if platform_val.startswith('cygwin') or platform_val == 'darwin':
             make_val = 'make'
         elif platform_val.startswith('linux'):
-            if find_executable('gmake'):
+            if shutil.which('gmake'):
                 make_val = 'gmake'
             else:
                 make_val = 'make'

@XuehaiPan
Copy link
Contributor Author

May need label CI-long-timeout. All tests passed on my docker container (Ubuntu 20.04).

@carlocab carlocab added the long build Set a long timeout for formula testing label Feb 3, 2022
@mppf
Copy link

mppf commented Feb 3, 2022

@XuehaiPan -

Regarding

distutils.core.setup --> setuptools.setup
distutils.spawn.find_executable --> shutil.which

I wouldn't expect that you need to patch anything in third-party/llvm/llvm-src since this directory will not be used since Chapel is using the Homebrew LLVM 11.

Also we would appreciate it upstream if you can make a PR with the changes to util/chplenv.

Regarding this

I removed some unrelated diffs in patch https://gist.github.com/mppf/32869664c6bb251dcd1101d783763780.

Can you say more about which diffs you removed from there? Thanks

@XuehaiPan
Copy link
Contributor Author

@mppf

I wouldn't expect that you need to patch anything in third-party/llvm/llvm-src since this directory will not be used since Chapel is using the Homebrew LLVM 11.

Get it. I will remove them then.

Also we would appreciate it upstream if you can make a PR with the changes to util/chplenv.

Regarding this

I removed some unrelated diffs in patch https://gist.github.com/mppf/32869664c6bb251dcd1101d783763780.
Can you say more about which diffs you removed from there? Thanks

Files where their paths start with /test/* (do not exist in the release tar file).

@mppf
Copy link

mppf commented Feb 3, 2022

Sounds great, thanks for clarifying

@carlocab carlocab added CI-long-timeout [DEPRECATED] Use longer GitHub Actions CI timeout. and removed CI-long-timeout [DEPRECATED] Use longer GitHub Actions CI timeout. labels Feb 4, 2022
@XuehaiPan
Copy link
Contributor Author

All checks have passed.

@iMichka
Copy link
Member

iMichka commented Feb 5, 2022

Nice. Thanks all. I naively tried to apply the patches above, but I see there was more work to get things done correctly. Thanks all!

@carlocab
Copy link
Member

carlocab commented Feb 5, 2022

Can we move the embedded Chapel patch to formula-patches? It can wait until this is merged.

@BrewTestBot
Copy link
Member

🤖 A scheduled task has triggered a merge.

@github-actions github-actions bot added the outdated PR was locked due to age label Mar 12, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CI-linux-self-hosted Build on Linux self-hosted runner CI-no-fail-fast Continue CI tests despite failing GitHub Actions matrix builds. long build Set a long timeout for formula testing outdated PR was locked due to age python Python use is a significant feature of the PR or issue python-3.10-migration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants