1# Copyright 2023 The Bazel Authors. All rights reserved. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15"" 16 17def version_label(version, *, sep = ""): 18 """A version fragment derived from python minor version 19 20 Examples: 21 version_label("3.9") == "39" 22 version_label("3.9.12", sep="_") == "3_9" 23 version_label("3.11") == "311" 24 25 Args: 26 version: Python version. 27 sep: The separator between major and minor version numbers, defaults 28 to an empty string. 29 30 Returns: 31 The fragment of the version. 32 """ 33 major, _, version = version.partition(".") 34 minor, _, _ = version.partition(".") 35 36 return major + sep + minor 37