mirror of
https://github.com/chromebrew/chromebrew.git
synced 2026-01-09 15:37:56 -05:00
156 lines
6.4 KiB
Ruby
156 lines
6.4 KiB
Ruby
require 'package'
|
|
|
|
class Python3 < Package
|
|
description 'Python is a programming language that lets you work quickly and integrate systems more effectively.'
|
|
homepage 'https://www.python.org/'
|
|
@_ver = '3.11.4'
|
|
version @_ver
|
|
license 'PSF-2.0'
|
|
compatibility 'all'
|
|
source_url "https://www.python.org/ftp/python/#{@_ver}/Python-#{@_ver}.tar.xz"
|
|
source_sha256 '2f0e409df2ab57aa9fc4cbddfb976af44e4e55bf6f619eee6bc5c2297264a7f6'
|
|
|
|
binary_url({
|
|
aarch64: 'https://gitlab.com/api/v4/projects/26210301/packages/generic/python3/3.11.4_armv7l/python3-3.11.4-chromeos-armv7l.tar.zst',
|
|
armv7l: 'https://gitlab.com/api/v4/projects/26210301/packages/generic/python3/3.11.4_armv7l/python3-3.11.4-chromeos-armv7l.tar.zst',
|
|
i686: 'https://gitlab.com/api/v4/projects/26210301/packages/generic/python3/3.11.4_i686/python3-3.11.4-chromeos-i686.tar.zst',
|
|
x86_64: 'https://gitlab.com/api/v4/projects/26210301/packages/generic/python3/3.11.4_x86_64/python3-3.11.4-chromeos-x86_64.tar.zst'
|
|
})
|
|
binary_sha256({
|
|
aarch64: 'aa830703a5a46ec29ef3b7e1d50ed7610b71ac7d380d4bec6635ede88060b3f7',
|
|
armv7l: 'aa830703a5a46ec29ef3b7e1d50ed7610b71ac7d380d4bec6635ede88060b3f7',
|
|
i686: 'c13a82e54f2fadedce2c58327cd653a43a56e81c48a9e602458e91b48834d839',
|
|
x86_64: 'b55067edfe66b1e3970372c97d83eee7568fff791accf80eaf2e7132126bdccd'
|
|
})
|
|
|
|
depends_on 'autoconf_archive' => :build
|
|
depends_on 'bz2' # R
|
|
depends_on 'expat' # R
|
|
depends_on 'gcc_lib' # R
|
|
depends_on 'gdbm' # R
|
|
depends_on 'glibc' # R
|
|
depends_on 'krb5' => :build
|
|
depends_on 'libdb' # R
|
|
depends_on 'libffi' # R
|
|
depends_on 'libtirpc' => :build
|
|
depends_on 'mpdecimal' # R
|
|
depends_on 'ncurses' # R
|
|
depends_on 'openssl' # R
|
|
depends_on 'readline' # R
|
|
depends_on 'sqlite' # R
|
|
depends_on 'tcl' => :build unless ARCH == 'i686' # Needed for tkinter support
|
|
depends_on 'tk' => :build unless ARCH == 'i686' # Needed for tkinter support
|
|
depends_on 'util_linux' # R
|
|
depends_on 'xzutils' # R
|
|
depends_on 'zlibpkg' # R
|
|
depends_on 'zoneinfo' # L
|
|
|
|
no_env_options
|
|
conflicts_ok
|
|
|
|
def self.preinstall
|
|
@device = JSON.load_file("#{CREW_CONFIG_PATH}/device.json", symbolize_names: true)
|
|
@replaces = %w[py3_pip py3_setuptools]
|
|
@replaces_installed = []
|
|
@replaces.each do |package|
|
|
@replaces_installed.push(package) if @device[:installed_packages].any? { |elem| elem[:name] == package }
|
|
end
|
|
return if @replaces_installed.empty?
|
|
|
|
puts "Removing superseded package(s): #{@replaces_installed.join(' ')}...".orange
|
|
system "crew remove #{@replaces_installed.join(' ')}", exception: false
|
|
end
|
|
|
|
def self.patch
|
|
system "sed -i -e 's:#{CREW_LIB_PREFIX}:$(get_libdir):g' \
|
|
Lib/distutils/command/install.py \
|
|
Lib/distutils/sysconfig.py \
|
|
Lib/site.py \
|
|
Lib/sysconfig.py \
|
|
Lib/test/test_site.py \
|
|
Makefile.pre.in \
|
|
Modules/getpath.c \
|
|
setup.py"
|
|
end
|
|
|
|
def self.prebuild
|
|
# Ensure that internal copies of expat, libffi and zlib aren't used
|
|
FileUtils.rm_rf 'Modules/expat'
|
|
FileUtils.rm_rf Dir.glob('Modules/_ctypes/libffi*')
|
|
FileUtils.rm_rf 'Modules/zlib'
|
|
end
|
|
|
|
def self.build
|
|
@cppflags = "-I#{CREW_PREFIX}/include/ncursesw"
|
|
# Using /tmp breaks test_distutils, test_subprocess.
|
|
# Proxy setting breaks test_httpservers, test_ssl,
|
|
# test_urllib, test_urllib2, test_urllib2_localnet.
|
|
# So, modifying environment variable to make pass tests.
|
|
|
|
return if Dir.exist?('builddir')
|
|
|
|
FileUtils.mkdir_p 'builddir'
|
|
Dir.chdir 'builddir' do
|
|
system CREW_ENV_OPTIONS_HASH.transform_values { |v| "#{v} #{@cppflags}" }, "../configure #{CREW_OPTIONS} \
|
|
--with-computed-gotos \
|
|
--enable-loadable-sqlite-extensions \
|
|
--with-ensurepip \
|
|
--enable-optimizations \
|
|
--with-platlibdir='lib#{CREW_LIB_SUFFIX}' \
|
|
--with-system-ffi \
|
|
--with-system-expat \
|
|
--with-system-libmpdec \
|
|
--with-tzpath=#{CREW_PREFIX}/share/zoneinfo \
|
|
--with-libc= \
|
|
--enable-shared"
|
|
system 'mold -run make'
|
|
end
|
|
end
|
|
|
|
def self.check
|
|
# Chromebooks do not allow SIGHUP, so disable SIGHUP test
|
|
system 'sed', '-i', 'Lib/test/test_asyncio/test_events.py', '-e', "/Don't have SIGHUP/s/win32/linux/"
|
|
system 'sed', '-i', 'Lib/test/test_asyncio/test_subprocess.py', '-e', "/Don't have SIGHUP/s/win32/linux/"
|
|
|
|
# Chromebooks return EINVAL for F_NOTIFY DN_MULTISHOT, so disable test_fcntl_64_bit
|
|
system 'sed', '-i', 'Lib/test/test_fcntl.py', '-e', '/ARM Linux returns EINVAL for F_NOTIFY DN_MULTISHOT/s/$/\
|
|
@unittest.skipIf(platform.system() == '"'Linux'"', "Chromeos returns EINVAL for F_NOTIFY DN_MULTISHOT")/'
|
|
|
|
# imaplib test used to use a kind of security hole on a server in university and the hole is closed now.
|
|
# See https://bugs.python.org/issue30175 and https://github.com/python/cpython/pull/1320/files for details.
|
|
system 'sed', '-i', 'Lib/test/test_imaplib.py',
|
|
'-e', '/test_logincapa_with_client_certfile/i\ \ \ \ @unittest.skipIf(True,\
|
|
"bpo-30175: FIXME: cyrus.andrew.cmu.edu doesn\'t accept "\
|
|
"our randomly generated client x509 certificate anymore")',
|
|
'-e', '/test_logincapa_with_client_ssl_context/i\ \ \ \ @unittest.skipIf(True,\
|
|
"bpo-30175: FIXME: cyrus.andrew.cmu.edu doesn\'t accept "\
|
|
"our randomly generated client x509 certificate anymore")'
|
|
|
|
# Using /tmp breaks test_distutils, test_subprocess
|
|
# Proxy setting breaks test_httpservers, test_ssl,
|
|
# test_urllib, test_urllib2, test_urllib2_localnet
|
|
# system "http_proxy= https_proxy= ftp_proxy= make test"
|
|
end
|
|
|
|
def self.install
|
|
Dir.chdir 'builddir' do
|
|
system 'make', "DESTDIR=#{CREW_DEST_DIR}", 'install'
|
|
system "#{CREW_DEST_PREFIX}/bin/python3 -m ensurepip --upgrade --default-pip"
|
|
system "sed -i 's,#{CREW_DEST_PREFIX}/bin/python3,#{CREW_PREFIX}/bin/python3,g' #{CREW_DEST_PREFIX}/bin/pip3"
|
|
end
|
|
|
|
# Make python3 the default python
|
|
FileUtils.ln_sf 'python3', "#{CREW_DEST_PREFIX}/bin/python"
|
|
FileUtils.ln_sf 'pip3', "#{CREW_DEST_PREFIX}/bin/pip"
|
|
end
|
|
|
|
def self.postinstall
|
|
puts 'Updating pip packages...'.lightblue
|
|
@piplist = `pip list | cut -d' ' -f1`.split
|
|
@piplist.drop(2).each do |pip_pkg|
|
|
system "pip install #{pip_pkg} -U", exception: false
|
|
end
|
|
puts "Please install tcl and tk with 'crew install tcl tk' if tkinter is needed.".lightblue unless ARCH == 'i686'
|
|
end
|
|
end
|