Files
chromebrew/lib/buildsystems/pip.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

55 lines
3.3 KiB
Ruby

Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
require 'json'
require 'package'
require_relative '../const'
class Pip < Package
property :pip_install_extras, :pre_configure_options
def self.install
# Make sure Chromebrew pypi variables are set:
Kernel.system 'pip config --user set local.index-url https://gitlab.com/api/v4/projects/26210301/packages/pypi/simple' unless `pip config get local.index-url`.chomp == 'https://gitlab.com/api/v4/projects/26210301/packages/pypi/simple'
Kernel.system 'pip config --user set local.extra-index-url https://pypi.org/simple' unless `pip config get local.extra-index-url`.chomp == 'https://pypi.org/simple'
Kernel.system 'pip config --user set local.trusted-host gitlab.com' unless `pip config get local.trusted-host`.chomp == 'gitlab.com'
puts 'Checking for pip updates'.orange if CREW_VERBOSE
system "python3 -s -m pip install -U pip | grep -v 'Requirement already satisfied'", exception: false
@py_pkg = name.gsub('py3_', '')
@py_pkg_chromebrew_version = version.gsub(/-py3\.\d{2}/, '').gsub(/-icu\d{2}\.\d/, '')
puts "Checking for #{@py_pkg} python dependencies...".orange if CREW_VERBOSE
@py_pkg_pypi = `curl -Ls https://pypi.org/pypi/#{@py_pkg}/json`.chomp
@py_pkg_pypi_hash = JSON.parse(@py_pkg_pypi)
@py_pkg_version = @py_pkg_pypi_hash['info']['version']
@py_pkg_versioned_pypi = `curl -Ls https://pypi.org/pypi/#{@py_pkg}/#{@py_pkg_version}/json`.chomp
@py_pkg_versioned_pypi_hash = JSON.parse(@py_pkg_versioned_pypi)
@py_pkg_deps = @py_pkg_versioned_pypi_hash['info']['requires_dist']
# We don't want extra packages listed in the dependency list, since
# those are optional.
@py_pkg_deps.reject! { |x| x.include?('extra ==') } unless @py_pkg_deps.to_s.empty?
unless @py_pkg_deps.to_s.empty?
puts "Installing #{@py_pkg} python dependencies with pip...".orange
@py_pkg_deps.each do |pip_dep|
@cleaned_py_dep = pip_dep[/[^;]+/]
puts "——Installing: #{@cleaned_py_dep}".gray
system "python3 -s -m pip install --ignore-installed -U \"#{@cleaned_py_dep}\" | grep -v 'Requirement already satisfied'", exception: false
end
end
puts "Installing #{@py_pkg} python module. This may take a while...".lightblue
puts "Additional pre_configure_options being used: #{@pre_configure_options.nil? ? '<no pre_configure_options>' : @pre_configure_options}".orange
system "MAKEFLAGS=-j#{CREW_NPROC} #{@pre_configure_options} python -s -m pip install --ignore-installed -U \"#{@py_pkg}==#{@py_pkg_chromebrew_version}\" | grep -v 'Requirement already satisfied'", exception: false
@pip_files = `python3 -s -m pip show -f #{@py_pkg}`.chomp
abort "pip install of #{@py_pkg} failed." if @pip_files.empty?
@pip_files_base = @pip_files[/(?<=Location: ).*/, 0].concat('/')
@pip_files_lines = @pip_files[/(?<=Files:\n)[\W|\w]*/, 0].split
@pip_files_lines.each do |pip_file|
@pip_path = File.expand_path("#{@pip_files_base}#{pip_file}")
@destpath = File.join(CREW_DEST_DIR, @pip_path)
# Handle older FileUtils from older ruby versions.
FileUtils.mkdir_p File.dirname(@destpath) if Gem::Version.new(RUBY_VERSION.to_s) < Gem::Version.new('3.3')
FileUtils.install @pip_path, @destpath
end
@pip_install_extras&.call
end
end