Skip to content

Commit

Permalink
Merge pull request #198547 from Homebrew/pyobjc
Browse files Browse the repository at this point in the history
gimme-aws-creds trezor-agent: avoid Xcode.app dependency
  • Loading branch information
BrewTestBot authored Nov 22, 2024
2 parents 7188750 + 4490eb4 commit 6c1f9bf
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 6 deletions.
41 changes: 38 additions & 3 deletions Formula/g/gimme-aws-creds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,28 @@ class GimmeAwsCreds < Formula
resource "pyobjc-framework-cocoa" do
url "https://files.pythonhosted.org/packages/a7/6c/b62e31e6e00f24e70b62f680e35a0d663ba14ff7601ae591b5d20e251161/pyobjc_framework_cocoa-10.3.1.tar.gz"
sha256 "1cf20714daaa986b488fb62d69713049f635c9d41a60c8da97d835710445281a"

# Backport commit to avoid Xcode.app dependency. Remove in the next release
# https://github.com/ronaldoussoren/pyobjc/commit/864a21829c578f6479ac6401d191fb759215175e
patch :DATA
end

resource "pyobjc-framework-localauthentication" do
url "https://files.pythonhosted.org/packages/d7/a9/bb2c2c3171a600dad5c7db509cdeef5a1a3cd7a22266a515145ebd5497b0/pyobjc_framework_localauthentication-10.3.1.tar.gz"
sha256 "ad85411f1899a2ba89349df6a92db99fcaa80a4232a4934a1a176c60698d46b1"

# Backport commit to avoid Xcode.app dependency. Remove in the next release
# https://github.com/ronaldoussoren/pyobjc/commit/864a21829c578f6479ac6401d191fb759215175e
patch :DATA
end

resource "pyobjc-framework-security" do
url "https://files.pythonhosted.org/packages/20/db/3fa2a151c53f2d87d9da725948d33f8bb4c7f36d6cb468411ae4b46ad474/pyobjc_framework_security-10.3.1.tar.gz"
sha256 "0d4e679a8aebaef9b54bd24e2fe2794ad5c28d601b6d140ed38370594bcb6fa0"

# Backport commit to avoid Xcode.app dependency. Remove in the next release
# https://github.com/ronaldoussoren/pyobjc/commit/864a21829c578f6479ac6401d191fb759215175e
patch :DATA
end

resource "python-dateutil" do
Expand Down Expand Up @@ -264,9 +276,13 @@ class GimmeAwsCreds < Formula
end

def install
venv = virtualenv_create(libexec, "python3.13")
venv.pip_install resources.reject { |r| r.name.start_with?("pyobjc") && OS.linux? }
venv.pip_install_and_link buildpath
if OS.mac?
# Help `pyobjc-framework-cocoa` pick correct SDK after removing -isysroot from Python formula
ENV.append_to_cflags "-isysroot #{MacOS.sdk_path}"
else
without = resources.filter_map { |r| r.name if r.name.start_with?("pyobjc") }
end
virtualenv_install_with_resources(without:)
end

test do
Expand All @@ -282,3 +298,22 @@ def install
assert_match version.to_s, shell_output("#{bin}/gimme-aws-creds --version")
end
end

__END__
--- a/pyobjc_setup.py
+++ b/pyobjc_setup.py
@@ -510,15 +510,6 @@ def Extension(*args, **kwds):
% (tuple(map(int, os_level.split(".")[:2])))
)

- # XCode 15 has a bug w.r.t. weak linking for older macOS versions,
- # fall back to older linker when using that compiler.
- # XXX: This should be in _fixup_compiler but doesn't work there...
- lines = subprocess.check_output(["xcodebuild", "-version"], text=True).splitlines()
- if lines[0].startswith("Xcode"):
- xcode_vers = int(lines[0].split()[-1].split(".")[0])
- if xcode_vers >= 15:
- ldflags.append("-Wl,-ld_classic")
-
if os_level == "10.4":
cflags.append("-DNO_OBJC2_RUNTIME")
37 changes: 34 additions & 3 deletions Formula/t/trezor-agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class TrezorAgent < Formula
sha256 cellar: :any_skip_relocation, x86_64_linux: "ea07ce42c9c3de33f2c307f30522d41a43809ad90096078f3d48657be95b1942"
end

depends_on "pkg-config" => :build # for hidapi resource
depends_on "pkgconf" => :build # for hidapi resource
depends_on "certifi"
depends_on "cryptography"
depends_on "hidapi"
Expand Down Expand Up @@ -188,16 +188,28 @@ class TrezorAgent < Formula
resource "pyobjc-framework-cocoa" do
url "https://files.pythonhosted.org/packages/a7/6c/b62e31e6e00f24e70b62f680e35a0d663ba14ff7601ae591b5d20e251161/pyobjc_framework_cocoa-10.3.1.tar.gz"
sha256 "1cf20714daaa986b488fb62d69713049f635c9d41a60c8da97d835710445281a"

# Backport commit to avoid Xcode.app dependency. Remove in the next release
# https://github.com/ronaldoussoren/pyobjc/commit/864a21829c578f6479ac6401d191fb759215175e
patch :DATA
end

resource "pyobjc-framework-corebluetooth" do
url "https://files.pythonhosted.org/packages/f7/69/89afd7747f42d2eb1e8f4b7f2ba2739d98ccf36f6b5c72474802962494de/pyobjc_framework_corebluetooth-10.3.1.tar.gz"
sha256 "dc5d326ab5541b8b68e7e920aa8363851e779cb8c33842f6cfeef4674cc62f94"

# Backport commit to avoid Xcode.app dependency. Remove in the next release
# https://github.com/ronaldoussoren/pyobjc/commit/864a21829c578f6479ac6401d191fb759215175e
patch :DATA
end

resource "pyobjc-framework-libdispatch" do
url "https://files.pythonhosted.org/packages/b7/37/1a7d9e5a04ab42aa8186f3493478c055601503ac7f8d58b8501d23db8b21/pyobjc_framework_libdispatch-10.3.1.tar.gz"
sha256 "f5c3475498cb32f54d75e21952670e4a32c8517fb2db2e90869f634edc942446"

# Backport commit to avoid Xcode.app dependency. Remove in the next release
# https://github.com/ronaldoussoren/pyobjc/commit/864a21829c578f6479ac6401d191fb759215175e
patch :DATA
end

resource "pyserial" do
Expand Down Expand Up @@ -271,9 +283,9 @@ class TrezorAgent < Formula
end

def install
ENV["HIDAPI_SYSTEM_HIDAPI"] = "1"
ENV["SODIUM_INSTALL"] = "system"
without = if OS.mac?
# Help `pyobjc-framework-cocoa` pick correct SDK after removing -isysroot from Python formula
ENV.append_to_cflags "-isysroot #{MacOS.sdk_path}"
["dbus-fast"]
else
resources.filter_map { |r| r.name if r.name.start_with?("pyobjc") }
Expand All @@ -289,3 +301,22 @@ def install
system libexec/"bin/python", "-m", "pip", "check"
end
end

__END__
--- a/pyobjc_setup.py
+++ b/pyobjc_setup.py
@@ -510,15 +510,6 @@ def Extension(*args, **kwds):
% (tuple(map(int, os_level.split(".")[:2])))
)

- # XCode 15 has a bug w.r.t. weak linking for older macOS versions,
- # fall back to older linker when using that compiler.
- # XXX: This should be in _fixup_compiler but doesn't work there...
- lines = subprocess.check_output(["xcodebuild", "-version"], text=True).splitlines()
- if lines[0].startswith("Xcode"):
- xcode_vers = int(lines[0].split()[-1].split(".")[0])
- if xcode_vers >= 15:
- ldflags.append("-Wl,-ld_classic")
-
if os_level == "10.4":
cflags.append("-DNO_OBJC2_RUNTIME")

0 comments on commit 6c1f9bf

Please sign in to comment.