Skip to content

Commit f9a86e5

Browse files
authored
Merge pull request #24127: Update staging of Python wheels (#24114)
2 parents 9a94381 + 7f24715 commit f9a86e5

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

sdks/python/apache_beam/runners/portability/stager.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,8 @@ def _get_platform_for_default_sdk_container():
699699
# Base image
700700
pip_version = pkg_resources.get_distribution('pip').version
701701
if parse_version(pip_version) >= parse_version('19.3'):
702+
# pip can only recognize manylinux2014_x86_64 wheels
703+
# from version 19.3.
702704
return 'manylinux2014_x86_64'
703705
else:
704706
return 'manylinux2010_x86_64'
@@ -830,13 +832,15 @@ def _create_beam_sdk(sdk_remote_location, temp_dir):
830832
try:
831833
abi_suffix = 'm' if sys.version_info < (3, 8) else ''
832834
# Stage binary distribution of the SDK, for now on a best-effort basis.
835+
platform_tag = Stager._get_platform_for_default_sdk_container()
833836
sdk_local_file = Stager._download_pypi_sdk_package(
834837
temp_dir,
835838
fetch_binary=True,
836839
language_version_tag='%d%d' %
837840
(sys.version_info[0], sys.version_info[1]),
838841
abi_tag='cp%d%d%s' %
839-
(sys.version_info[0], sys.version_info[1], abi_suffix))
842+
(sys.version_info[0], sys.version_info[1], abi_suffix),
843+
platform_tag=platform_tag)
840844
sdk_binary_staged_name = Stager.\
841845
_desired_sdk_filename_in_staging_location(sdk_local_file)
842846
_LOGGER.info(
@@ -873,10 +877,10 @@ def _create_beam_sdk(sdk_remote_location, temp_dir):
873877
def _download_pypi_sdk_package(
874878
temp_dir,
875879
fetch_binary=False,
876-
language_version_tag='27',
880+
language_version_tag='39',
877881
language_implementation_tag='cp',
878-
abi_tag='cp27mu',
879-
platform_tag='manylinux1_x86_64'):
882+
abi_tag='cp39',
883+
platform_tag='manylinux2014_x86_64'):
880884
"""Downloads SDK package from PyPI and returns path to local path."""
881885
package_name = Stager.get_sdk_package_name()
882886
try:
@@ -911,7 +915,10 @@ def _download_pypi_sdk_package(
911915
'--platform',
912916
platform_tag
913917
])
914-
# Example wheel: apache_beam-2.4.0-cp27-cp27mu-manylinux1_x86_64.whl
918+
# Example wheel: with manylinux14 tag.
919+
# apache_beam-2.43.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl # pylint: disable=line-too-long
920+
if platform_tag == 'manylinux2014_x86_64':
921+
platform_tag = 'manylinux_2_17_x86_64.' + platform_tag
915922
expected_files = [
916923
os.path.join(
917924
temp_dir,
@@ -921,8 +928,9 @@ def _download_pypi_sdk_package(
921928
language_implementation_tag,
922929
language_version_tag,
923930
abi_tag,
924-
platform_tag))
931+
platform_tag)),
925932
]
933+
926934
else:
927935
_LOGGER.info('Downloading source distribution of the SDK from PyPi')
928936
cmd_args.extend(['--no-binary', ':all:'])

sdks/python/apache_beam/runners/portability/stager_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ def pip_fake(args):
137137
# Per PEP-0427 in wheel filenames non-alphanumeric characters
138138
# in distribution name are replaced with underscore.
139139
distribution_name = distribution_name.replace('-', '_')
140+
if args[17] == 'manylinux2014_x86_64':
141+
args[17] = 'manylinux_2_17_x86_64.' + args[17]
140142
package_file = '%s-%s-%s%s-%s-%s.whl' % (
141143
distribution_name,
142144
distribution_version,

sdks/python/container/boot.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ func setupAcceptableWheelSpecs() error {
224224
if err != nil {
225225
return err
226226
}
227-
re := regexp.MustCompile(`Python (\d)\.(\d).*`)
227+
re := regexp.MustCompile(`Python (\d)\.(\d+).*`)
228228
pyVersions := re.FindStringSubmatch(string(stdoutStderr[:]))
229229
if len(pyVersions) != 3 {
230230
return fmt.Errorf("cannot get parse Python version from %s", stdoutStderr)
@@ -233,9 +233,9 @@ func setupAcceptableWheelSpecs() error {
233233
var wheelName string
234234
switch pyVersion {
235235
case "36", "37":
236-
wheelName = fmt.Sprintf("cp%s-cp%sm-manylinux1_x86_64.whl", pyVersion, pyVersion)
236+
wheelName = fmt.Sprintf("cp%s-cp%sm-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", pyVersion, pyVersion)
237237
default:
238-
wheelName = fmt.Sprintf("cp%s-cp%s-manylinux1_x86_64.whl", pyVersion, pyVersion)
238+
wheelName = fmt.Sprintf("cp%s-cp%s-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", pyVersion, pyVersion)
239239
}
240240
acceptableWhlSpecs = append(acceptableWhlSpecs, wheelName)
241241
return nil

sdks/python/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def get_version():
9595
different technologies and user communities.
9696
'''
9797

98-
RECOMMENDED_MIN_PIP_VERSION = '7.0.0'
98+
RECOMMENDED_MIN_PIP_VERSION = '19.3.0'
9999
try:
100100
_PIP_VERSION = get_distribution('pip').version
101101
if parse_version(_PIP_VERSION) < parse_version(RECOMMENDED_MIN_PIP_VERSION):

0 commit comments

Comments
 (0)