Files
chromebrew/packages/python3.rb
Cassandra Watergate a0712e9828 Separate pip from python3, add pip for python2 (#5692)
* Rearrange python2 and 3, seperate pip

* rename python27 => python2

* merge master into pip

* touch up

* make old setuptools package fake

* lib/const.rb: bump version

* Fix py2_setuptools

* Add runtime dependencies to python2

* reorder depends

* python2 minor change

* packages/setuptools.rb: Fix ugly version

* Add binaries

Co-authored-by: satmandu <satadru@umich.edu>
Co-authored-by: satmandu <satadru@gmail.com>
2021-04-29 10:29:06 -05:00

145 lines
5.8 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.9.4'
version "#{@_ver}-1"
license 'PSF-2.0'
compatibility 'all'
source_url "https://www.python.org/ftp/python/#{@_ver}/Python-#{@_ver}.tar.xz"
source_sha256 '4b0e6644a76f8df864ae24ac500a51bbf68bd098f6a173e27d3b61cdca9aa134'
binary_url({
aarch64: 'https://gitlab.com/api/v4/projects/26210301/packages/generic/python3/3.9.4-1_armv7l/python3-3.9.4-1-chromeos-armv7l.tar.xz',
armv7l: 'https://gitlab.com/api/v4/projects/26210301/packages/generic/python3/3.9.4-1_armv7l/python3-3.9.4-1-chromeos-armv7l.tar.xz',
i686: 'https://gitlab.com/api/v4/projects/26210301/packages/generic/python3/3.9.4-1_i686/python3-3.9.4-1-chromeos-i686.tar.xz',
x86_64: 'https://gitlab.com/api/v4/projects/26210301/packages/generic/python3/3.9.4-1_x86_64/python3-3.9.4-1-chromeos-x86_64.tar.xz'
})
binary_sha256({
aarch64: '17acda432cbbdcbcdf46a8fda536c160d460833d2e8d4e33f41669cd392d1ec3',
armv7l: '17acda432cbbdcbcdf46a8fda536c160d460833d2e8d4e33f41669cd392d1ec3',
i686: '2c47ce9690665232473be9582234f73f5bebdd616db1d1e0c9edf6a56880b59f',
x86_64: '23ade3fd6991f88f0207e8ed64def6c2a8823b5b51aa22358b08daf328a4caca'
})
depends_on 'krb5' => :build
depends_on 'libtirpc' => :build
depends_on 'bz2' # R
depends_on 'expat' # R
depends_on 'gdbm' # R
depends_on 'glibc' # R
depends_on 'libdb' # R
depends_on 'libffi' # R
depends_on 'ncurses' # R
depends_on 'openssl' # R
depends_on 'readline' # R
depends_on 'sqlite' # R
depends_on 'xzutils' # R
depends_on 'zlibpkg' # R
# depends_on 'tcl' # Needed for tkinter support
# depends_on 'tk' # Needed for tkinter support
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"
# python requires /usr/local/lib, so leave as is but specify -rpath
@ldflags = "-Wl,-rpath,-L#{CREW_LIB_PREFIX}"
# CREW_ENV_OPTIONS don't work so we have to make our own
@py_common_flags = "'-Os -pipe -fuse-ld=gold'"
# 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.
system 'autoreconf -fiv'
Dir.mkdir 'builddir'
Dir.chdir 'builddir' do
system "env CFLAGS=#{@py_common_flags} CXXFLAGS=#{@py_common_flags} \
CC='#{CREW_TGT}-gcc -pthread' \
CXX='#{CREW_TGT}-g++' \
CPPFLAGS='#{@cppflags}' \
LDFLAGS='#{@ldflags} -lpthread' \
../configure #{CREW_OPTIONS} \
--with-computed-gotos \
--with-loadable-sqlite-extensions \
--without-ensurepip \
--enable-optimizations \
--with-lto \
--with-platlibdir='lib#{CREW_LIB_SUFFIX}' \
--with-system-ffi \
--with-system-expat \
--with-system-libmpdev \
--enable-shared"
system 'make'
end
end
def self.check
# Chromebook doesn't 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/"
# Chromebook returns 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'
end
# remove static libraries
# system "find #{CREW_DEST_PREFIX} -name 'libpython*.a' -print | xargs -r rm"
# create symbolic links in lib64 for other applications which use libpython
# Not needed as --libdir is passed to ./configure
# unless Dir.exist? CREW_DEST_LIB_PREFIX
# FileUtils.mkdir_p CREW_DEST_LIB_PREFIX
# system "cd #{CREW_DEST_LIB_PREFIX} && ln -s ../lib/libpython*.so* ."
# end
# Remove conflicting binaries
FileUtils.rm "#{CREW_DEST_PREFIX}/bin/wheel" if File.exist? "#{CREW_DEST_PREFIX}/bin/wheel"
# Make python3 the default python
FileUtils.ln_sf 'python3', "#{CREW_DEST_PREFIX}/bin/python"
end
end