Files
chromebrew/packages/python3.rb
Satadru Pramanik, DO, MPH, MEng 172ca528a1 Python => 3.12.6 (#10436)
* remove @_ver from py3 packages, change to use pip, and rename where appropriate

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Update py3_package versions.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* bump version of update_ruby...

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Attempt to fix i686 install.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Update core_packages.txt.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Python => 3.12.6

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Remove binaries...

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Remove binaries from py3_ packages.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* lint/fixup

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* move py3_wheel to pip

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Move pytimeparse to pip.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add ruby_debug gem to buildessential since it is needed for irb.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* move py3_text_unidecode to pip

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* lint

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* convert more packages to pip

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* replace appdirs with platformdirs

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* fixup

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* fixup

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Pip should unconditionally install...

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Adjust pip install...

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Adjust py3_python_ package deps

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add error message for which package file was not found.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* cleanup py3_typing_extensions

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Update python packages...

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add some binaries.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Adjust py3_setuptools...

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* fixup py3_setuptools_rust

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* ruby adjustments

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add setuptools binaries

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Remove ruby_debug from fixup deprecation list.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Update py3_magic to py3_python_magic.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Update python packages, adjust update_python script and buildsystems/pip

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Fix missing version in py3_parsedatetime.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Update update scripts to use parallel.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add py3_patchelf and py3_libxml2 binaries

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add unless defined check for USER in const.rb.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Change CREW_CONST_GIT_COMMIT from being a constant.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add binaries for py3_pyopenssl.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Have remove use pip if possible.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* fixup

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* add more debug code to fixup.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Prepare pip packages for build...

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* fixup py3_pyyaml

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* update py3_pyyaml

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* fix py3_unsupported_python

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* fix py3_unsupported_python

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* remove some debug code

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* more pip updates

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add more binaries.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add binaries for py3_pyopenssl.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add py3_oci binaries.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add binaries

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Update py3_twine.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* update py3_oci_cli binaries

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* cleanup buildsystems/pip

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* add binaries for sphinx

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Update more packages.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* add binary_compression to pip files

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

---------

Signed-off-by: Satadru Pramanik <satadru@gmail.com>
2024-09-10 10:55:11 -05:00

130 lines
5.2 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/'
version '3.12.6'
license 'PSF-2.0'
compatibility 'all'
source_url "https://www.python.org/ftp/python/#{version}/Python-#{version}.tar.xz"
source_sha256 '1999658298cf2fb837dffed8ff3c033ef0c98ef20cf73c5d5f66bed5ab89697c'
binary_compression 'tar.zst'
binary_sha256({
aarch64: '85df5cadf8cbb04698c3befe0bdcc8010e46e8aa51ebcf69dab8f298151a3feb',
armv7l: '85df5cadf8cbb04698c3befe0bdcc8010e46e8aa51ebcf69dab8f298151a3feb',
i686: '6ac42600df7756eb34c93046f561196808556f53dcf2e633d5aab15d2ca8d382',
x86_64: '9f6ddb59083d921353eca0c119f95d8a8c8c52ac4211a069afd98e8b45dad5e6'
})
depends_on 'autoconf_archive' => :build
depends_on 'bzip2' # 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 'libnsl' # R
depends_on 'libtirpc' # R
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 'zlib' # 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.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
# 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 "../configure #{CREW_CONFIGURE_OPTIONS} \
--with-lto \
--with-computed-gotos \
--enable-loadable-sqlite-extensions \
--with-ensurepip \
--enable-optimizations \
--with-platlibdir='lib#{CREW_LIB_SUFFIX}' \
--with-system-expat \
--with-system-libmpdec \
--with-tzpath=#{CREW_PREFIX}/share/zoneinfo \
--with-libc= \
--enable-shared"
system "MAKEFLAGS=-j#{CREW_NPROC} mold -run make"
File.write 'python_config_env', <<~PYTHON_CONFIG_EOF
# Force use of python3 over python2.7 in packages which check the variable to set the python used.
PYTHON=python3
PYTHON_CONFIG_EOF
end
end
def self.install
Dir.chdir 'builddir' do
system 'make', "DESTDIR=#{CREW_DEST_DIR}", 'install'
# There is a Python ABI break in 3.11.5 coming from 3.11.4, see https://github.com/python/cpython/issues/108525
system "LD_LIBRARY_PATH=#{CREW_DEST_LIB_PREFIX}:#{CREW_LIB_PREFIX} #{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"
FileUtils.install 'builddir/python_config_env', "#{CREW_DEST_PREFIX}/etc/env.d/python", mode: 0o644
end
def self.postinstall
# First force pip upgrade to make sure we are past the problematic pip 23.2.1
# See https://github.com/pypa/pip/issues/12357 and https://github.com/pypa/pip/issues/12428
system 'PIP_DISABLE_PIP_VERSION_CHECK=1 python -m pip install --upgrade --force-reinstall pip'
# Pip is installed inside Python 3. The following steps ensure that
# pip can properly build other packages from buildsystems/pip.
@required_pip_modules = %w[build installer setuptools wheel pyproject_hooks]
@pip_list = `pip list --exclude pip`
@required_pip_modules.each do |pip_pkg|
unless @pip_list.include?(pip_pkg)
puts "Installing #{pip_pkg} using pip..."
system "MAKEFLAGS=-j#{CREW_NPROC} pip install #{pip_pkg}"
end
end
puts 'Updating pip packages...'.lightblue
system 'pip list --outdated --format=json | python -c "import json, sys; print(\'\n\'.join([x[\'name\'] for x in json.load(sys.stdin)]))" | xargs -rn1 pip install -U', exception: false
ExitMessage.add "Please install tcl and tk with 'crew install tcl tk' if tkinter is needed.".lightblue unless ARCH == 'i686'
end
end