Skip to content

Commit

Permalink
pypy3.9: update resources and workaround to enable new setuptools
Browse files Browse the repository at this point in the history
pypi_formula_mappings: add `pypy3.9` extra_packages
pypy3.9: update sha256

Signed-off-by: Patrick Linnane <[email protected]>
Signed-off-by: Michael Cho <[email protected]>
  • Loading branch information
cho-m committed Mar 25, 2024
1 parent 6baa880 commit 4abaa2b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 15 deletions.
43 changes: 28 additions & 15 deletions Formula/p/pypy3.9.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ class Pypy39 < Formula
desc "Implementation of Python 3 in Python"
homepage "https://pypy.org/"
url "https://downloads.python.org/pypy/pypy3.9-v7.3.15-src.tar.bz2"
sha256 "e42c16593dd2d8e30ffa6287660c6984562bf4e9f95e660706e16764dfec85a8"
sha256 "6bb9537d85aa7ad13c0aad2e41ff7fd55080bc9b4d1361b8f502df51db816e18"
license "MIT"
head "https://github.com/pypy/pypy.git", branch: "main"
head "https://github.com/pypy/pypy.git", branch: "py3.9"

livecheck do
url "https://downloads.python.org/pypy/"
Expand Down Expand Up @@ -36,17 +36,14 @@ class Pypy39 < Formula
uses_from_macos "unzip"
uses_from_macos "zlib"

# setuptools >= 60 required sysconfig patch
# See https://github.com/Homebrew/homebrew-core/pull/99892#issuecomment-1108492321
resource "setuptools" do
url "https://files.pythonhosted.org/packages/ef/75/2bc7bef4d668f9caa9c6ed3f3187989922765403198243040d08d2a52725/setuptools-59.8.0.tar.gz"
sha256 "09980778aa734c3037a47997f28d6db5ab18bdf2af0e49f719bfc53967fd2e82"
resource "pip" do
url "https://files.pythonhosted.org/packages/94/59/6638090c25e9bc4ce0c42817b5a234e183872a1129735a9330c472cc2056/pip-24.0.tar.gz"
sha256 "ea9bd1a847e8c5774a5777bb398c19e80bcd4e2aa16a4b301b718fe6f593aba2"
end

# always pull the latest pip, https://pypi.org/project/pip/#files
resource "pip" do
url "https://files.pythonhosted.org/packages/b7/06/6b1ad0ae8f97d7a0d6f6ad640db10780578999e647a9593512ceb6f06469/pip-23.3.2.tar.gz"
sha256 "7fd9972f96db22c8077a1ee2691b172c8089b17a5652a44494a9ecb0d78f9149"
resource "setuptools" do
url "https://files.pythonhosted.org/packages/4d/5b/dc575711b6b8f2f866131a40d053e30e962e633b332acf7cd2c24843d83d/setuptools-69.2.0.tar.gz"
sha256 "0ff4183f8f42cd8fa3acea16c45205521a4ef28f73c6391d8a25e92893134f2e"
end

# Build fixes:
Expand All @@ -64,6 +61,11 @@ def newest_abi_version?
end

def install
# Work around build failure with Xcode 15.3
# _curses_cffi.c:6795:38: error: incompatible function pointer types assigning to
# 'char *(*)(const char *, ...)' from 'char *(char *, ...)' [-Wincompatible-function-pointer-types]
ENV.append_to_cflags "-Wno-incompatible-function-pointer-types" if DevelopmentTools.clang_build_version >= 1500

# The `tcl-tk` library paths are hardcoded and need to be modified for non-/usr/local prefix
inreplace "lib_pypy/_tkinter/tklib_build.py" do |s|
s.gsub! "/usr/local/opt/tcl-tk/", Formula["tcl-tk"].opt_prefix/""
Expand Down Expand Up @@ -96,12 +98,15 @@ def install
system "tar", "-C", libexec.to_s, "--strip-components", "1", "-xf", "pypy3.tar.bz2"
end

# Move original libexec/bin directory to allow preserving user-installed scripts
libexec.install libexec/"bin" => "pypybin"

# The PyPy binary install instructions suggest installing somewhere
# (like /opt) and symlinking in binaries as needed. Specifically,
# we want to avoid putting PyPy's Python.h somewhere that configure
# scripts will find it.
bin.install_symlink libexec/"bin/pypy#{abi_version}"
lib.install_symlink libexec/"bin"/shared_library("libpypy#{abi_version}-c")
bin.install_symlink libexec/"pypybin/pypy#{abi_version}"
lib.install_symlink libexec/"pypybin"/shared_library("libpypy#{abi_version}-c")
include.install_symlink libexec/"include/pypy#{abi_version}"

if newest_abi_version?
Expand All @@ -113,7 +118,7 @@ def install

# Delete two files shipped which we do not want to deliver
# These files make patchelf fail
rm_f [libexec/"bin/libpypy#{abi_version}-c.so.debug", libexec/"bin/pypy#{abi_version}.debug"]
rm [libexec/"pypybin/libpypy#{abi_version}-c.so.debug", libexec/"pypybin/pypy#{abi_version}.debug"]
end

def post_install
Expand All @@ -135,8 +140,16 @@ def post_install
# Symlink the prefix site-packages into the cellar.
site_packages(libexec).parent.install_symlink site_packages(HOMEBREW_PREFIX)

# Tell distutils-based installers where to put scripts
# Create a scripts folder in the prefix and symlink it as libexec/bin.
# This is needed as setuptools' distutils ignores our distutils.cfg.
# Also create symlinks for original binaries we moved in case they are needed.
scripts_folder.mkpath
libexec.install_symlink scripts_folder => "bin" unless (libexec/"bin").exist?
(libexec/"pypybin").each_child do |f|
scripts_folder.install_symlink f unless (scripts_folder/f.basename).exist?
end

# Tell distutils-based installers where to put scripts
(distutils/"distutils.cfg").atomic_write <<~EOS
[install]
install-scripts=#{scripts_folder}
Expand Down
4 changes: 4 additions & 0 deletions pypi_formula_mappings.json
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,10 @@
"pyinstaller": {
"extra_packages": ["macholib"]
},
"pypy3.9": {
"package_name": "",
"extra_packages": ["pip", "setuptools"]
},
"pyqt": {
"exclude_packages": [
"pyqt6-3d-qt6", "pyqt6-charts-qt6", "pyqt6-datavisualization-qt6",
Expand Down

0 comments on commit 4abaa2b

Please sign in to comment.