From 8d4de853ca81c89b5155b2b78c11a9b93cca0113 Mon Sep 17 00:00:00 2001 From: James Estevez Date: Tue, 23 Aug 2022 08:48:08 -0700 Subject: [PATCH 1/2] Add Rust as build dependency in homebrew formula Users were intermittently reporting that upgrades failed with some variation of the following error: ```python-traceback File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/build_meta.py", line 142, in run_setup exec(compile(code, __file__, 'exec'), locals()) File "setup.py", line 14, in from setuptools_rust import RustExtension File "/private/tmp/pip-build-env-gh8ot2a3/overlay/lib/python3.8/site-packages/setuptools_rust/__init__.py", line 1, in from .build import build_rust File "/private/tmp/pip-build-env-gh8ot2a3/overlay/lib/python3.8/site-packages/setuptools_rust/build.py", line 23, in from setuptools.command.build import build as CommandBuild # type: ignore[import] ModuleNotFoundError: No module named 'setuptools.command.build' ``` This changeset includes three substantive changes to how the formula is generated: 1. Rust has been added as a build-time dependency. This is the root cause of the installation failure. 2. The major.minor version (`python3.9`of the python executable is used instead of `python3`). This prevents the installation from inadvertently using the system Python. This occurs because Homebrew only symlinks a `python3` executable for the latest version. See Homebrew/homebrew-core/107517. 3. Adds `--allow-unsafe` to the `pip-compile` step. This is a noop because we aren't pinning setuptools. --- utility/build-homebrew.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/utility/build-homebrew.sh b/utility/build-homebrew.sh index 74f9f8e247..049418a6eb 100755 --- a/utility/build-homebrew.sh +++ b/utility/build-homebrew.sh @@ -21,7 +21,9 @@ echo " " echo "=> Compiling pip requirements including hashes..." echo " " echo "cumulusci==$PACKAGE_VERSION" > "$REQS_IN_FILE" -pip-compile "$REQS_IN_FILE" -o "$REQS_FILE" --generate-hashes +# For a longish thread on why `allow-unsafe`, see https://github.com/pypa/pip/issues/6459 +# Here, we're adding it to collect setuptools-rust for the cryptography library. +pip-compile "$REQS_IN_FILE" -o "$REQS_FILE" --generate-hashes --allow-unsafe echo " " echo "=> Writing Homebrew Formula to ${OUT_FILE}..." @@ -34,8 +36,10 @@ class Cumulusci < Formula homepage "https://github.com/SFDO-Tooling/CumulusCI" url $PACKAGE_URL sha256 $PACKAGE_SHA - head "https://github.com/SFDO-Tooling/CumulusCI.git" + license "BSD-3-Clause" + head "https://github.com/SFDO-Tooling/CumulusCI.git", branch: "main" + depends_on "rust" => :build # cryptography -> setuptools-rust depends_on "python@3.9" def install @@ -48,7 +52,8 @@ $(cat "$REQS_FILE") REQS File.write("requirements.txt", reqs) - system "python3", "-m", "pip", "install", "-r", "requirements.txt", "--require-hashes", "--no-deps", "--ignore-installed", "--prefix", libexec + ## Python@3.9 no longer includes python3 https://github.com/Homebrew/homebrew-core/pull/107517 + system "python3.9", "-m", "pip", "install", "-r", "requirements.txt", "--require-hashes", "--no-deps", "--ignore-installed", "--prefix", libexec bin.install Dir["#{libexec}/bin/cci"] bin.install Dir["#{libexec}/bin/snowfakery"] From 3e3c33a914d8dceed64a56feec9b97efa27854ae Mon Sep 17 00:00:00 2001 From: James Estevez Date: Tue, 23 Aug 2022 11:36:37 -0700 Subject: [PATCH 2/2] Update utility/build-homebrew.sh Co-authored-by: Paul Prescod --- utility/build-homebrew.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/utility/build-homebrew.sh b/utility/build-homebrew.sh index 049418a6eb..ca22aad9b4 100755 --- a/utility/build-homebrew.sh +++ b/utility/build-homebrew.sh @@ -39,7 +39,6 @@ class Cumulusci < Formula license "BSD-3-Clause" head "https://github.com/SFDO-Tooling/CumulusCI.git", branch: "main" - depends_on "rust" => :build # cryptography -> setuptools-rust depends_on "python@3.9" def install