Python: add ensurepip variant (#28205)
This commit is contained in:
parent
6235184522
commit
a2181e9d25
@ -16,7 +16,7 @@ class PyBuild(PythonPackage):
|
|||||||
|
|
||||||
variant('virtualenv', default=False, description='Install optional virtualenv dependency')
|
variant('virtualenv', default=False, description='Install optional virtualenv dependency')
|
||||||
|
|
||||||
depends_on('python@3.6:', type=('build', 'run'))
|
depends_on('python@3.6:+ensurepip', type=('build', 'run'))
|
||||||
depends_on('py-setuptools', type='build')
|
depends_on('py-setuptools', type='build')
|
||||||
depends_on('py-packaging@19:', type=('build', 'run'))
|
depends_on('py-packaging@19:', type=('build', 'run'))
|
||||||
depends_on('py-pep517@0.9.1:', type=('build', 'run'))
|
depends_on('py-pep517@0.9.1:', type=('build', 'run'))
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#
|
#
|
||||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||||
|
|
||||||
|
import glob
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
@ -156,12 +157,13 @@ class Python(AutotoolsPackage):
|
|||||||
variant('nis', default=False, description='Build nis module')
|
variant('nis', default=False, description='Build nis module')
|
||||||
variant('zlib', default=True, description='Build zlib module')
|
variant('zlib', default=True, description='Build zlib module')
|
||||||
variant('bz2', default=True, description='Build bz2 module')
|
variant('bz2', default=True, description='Build bz2 module')
|
||||||
variant('lzma', default=True, description='Build lzma module')
|
variant('lzma', default=True, description='Build lzma module', when='@3.3:')
|
||||||
variant('pyexpat', default=True, description='Build pyexpat module')
|
variant('pyexpat', default=True, description='Build pyexpat module')
|
||||||
variant('ctypes', default=True, description='Build ctypes module')
|
variant('ctypes', default=True, description='Build ctypes module')
|
||||||
variant('tkinter', default=False, description='Build tkinter module')
|
variant('tkinter', default=False, description='Build tkinter module')
|
||||||
variant('uuid', default=True, description='Build uuid module')
|
variant('uuid', default=True, description='Build uuid module')
|
||||||
variant('tix', default=False, description='Build Tix module')
|
variant('tix', default=False, description='Build Tix module')
|
||||||
|
variant('ensurepip', default=True, description='Build ensurepip module', when='@2.7.9:2,3.4:')
|
||||||
|
|
||||||
depends_on('pkgconfig@0.9.0:', type='build')
|
depends_on('pkgconfig@0.9.0:', type='build')
|
||||||
depends_on('gettext +libxml2', when='+libxml2')
|
depends_on('gettext +libxml2', when='+libxml2')
|
||||||
@ -281,7 +283,7 @@ def determine_variants(cls, exes, version_str):
|
|||||||
variants += '~pythoncmd'
|
variants += '~pythoncmd'
|
||||||
|
|
||||||
for module in ['readline', 'sqlite3', 'dbm', 'nis',
|
for module in ['readline', 'sqlite3', 'dbm', 'nis',
|
||||||
'zlib', 'bz2', 'lzma', 'ctypes', 'uuid']:
|
'zlib', 'bz2', 'ctypes', 'uuid']:
|
||||||
try:
|
try:
|
||||||
python('-c', 'import ' + module, error=os.devnull)
|
python('-c', 'import ' + module, error=os.devnull)
|
||||||
variants += '+' + module
|
variants += '+' + module
|
||||||
@ -303,7 +305,23 @@ def determine_variants(cls, exes, version_str):
|
|||||||
except ProcessError:
|
except ProcessError:
|
||||||
variants += '~pyexpat'
|
variants += '~pyexpat'
|
||||||
|
|
||||||
# Some modules changed names in Python 3
|
# Some modules are version-dependent
|
||||||
|
if Version(version_str) >= Version('3.3'):
|
||||||
|
try:
|
||||||
|
python('-c', 'import lzma', error=os.devnull)
|
||||||
|
variants += '+lzma'
|
||||||
|
except ProcessError:
|
||||||
|
variants += '~lzma'
|
||||||
|
|
||||||
|
if Version(version_str) in ver('2.7.9:2,3.4:'):
|
||||||
|
# The ensurepip module is always available, but won't work if built with
|
||||||
|
# --without-ensurepip. A more reliable check to see if the package was built
|
||||||
|
# with --with-ensurepip is to check for the presence of a pip executable.
|
||||||
|
if glob.glob(os.path.join(os.path.dirname(exes[0]), 'pip*')):
|
||||||
|
variants += '+ensurepip'
|
||||||
|
else:
|
||||||
|
variants += '~ensurepip'
|
||||||
|
|
||||||
if Version(version_str) >= Version('3'):
|
if Version(version_str) >= Version('3'):
|
||||||
try:
|
try:
|
||||||
python('-c', 'import tkinter', error=os.devnull)
|
python('-c', 'import tkinter', error=os.devnull)
|
||||||
@ -472,7 +490,10 @@ def configure_args(self):
|
|||||||
raise ValueError(
|
raise ValueError(
|
||||||
'+ucs4 variant not compatible with Python 3.3 and beyond')
|
'+ucs4 variant not compatible with Python 3.3 and beyond')
|
||||||
|
|
||||||
if spec.satisfies('@3:'):
|
if spec.satisfies('@2.7.9:2,3.4:'):
|
||||||
|
if '+ensurepip' in spec:
|
||||||
|
config_args.append('--with-ensurepip')
|
||||||
|
else:
|
||||||
config_args.append('--without-ensurepip')
|
config_args.append('--without-ensurepip')
|
||||||
|
|
||||||
if '+pic' in spec:
|
if '+pic' in spec:
|
||||||
@ -650,6 +671,10 @@ def import_tests(self):
|
|||||||
else:
|
else:
|
||||||
self.command('-c', 'import Tix')
|
self.command('-c', 'import Tix')
|
||||||
|
|
||||||
|
# Ensure that ensurepip module works
|
||||||
|
if '+ensurepip' in spec:
|
||||||
|
self.command('-c', 'import ensurepip')
|
||||||
|
|
||||||
# ========================================================================
|
# ========================================================================
|
||||||
# Set up environment to make install easy for python extensions.
|
# Set up environment to make install easy for python extensions.
|
||||||
# ========================================================================
|
# ========================================================================
|
||||||
|
Loading…
Reference in New Issue
Block a user