From d073e594b5826e6f0d5323252e4e7a0ae582c89a Mon Sep 17 00:00:00 2001 From: Simon Mavi Stewart Date: Sun, 10 Mar 2024 11:36:11 +0000 Subject: [PATCH] [py] Fix how version numbers are handled --- Rakefile | 20 ++++++++++++++++---- py/BUILD.bazel | 2 +- py/docs/source/conf.py | 2 +- py/selenium/__init__.py | 2 +- py/selenium/webdriver/__init__.py | 2 +- py/setup.py | 2 +- 6 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Rakefile b/Rakefile index c439e57f95313..438d7269070df 100644 --- a/Rakefile +++ b/Rakefile @@ -624,11 +624,22 @@ namespace :py do bump_nightly = arguments[:version] === 'nightly' old_version = python_version new_version = nil - if bump_nightly && old_version.include?('nightly') - new_version = old_version.gsub('nightly', "#{Time.now.strftime("%Y%m%d%H%M")}") + + # There are three cases we want to deal with: + # 1. Switching from a release build to a nightly one + # 2. Updating a nightly build for the next nightly build + # 3. Switching from nightlies to a release build. + # According to PEP440, the way to indicate a nightly build is `M.m.v.devN` + # Where `N` is sorted numerically. That means we can create the dev + # version number from today's date. + + if bump_nightly && old_version.include?('.dev') + new_version = old_version.gsub(/\d+$/, "#{Time.now.strftime("%Y%m%d%H%M")}") + elsif bump_nightly + new_version = old_version + ".dev#{Time.now.strftime("%Y%m%d%H%M")}" else - new_version = updated_version(old_version, arguments[:version]) - new_version += '.nightly' unless old_version.include?('nightly') + new_version = updated_version(old_version.gsub(/\.dev\d+$/, ''), arguments[:version]) + puts "Calculated new version to be #{new_version}" end ['py/setup.py', @@ -1154,6 +1165,7 @@ task :create_release_notes do end def updated_version(current, desired = nil) + puts "Calculating " version = desired ? desired.split('.') : current.split(/\.|-/) if desired # Allows user to pass in only major/minor versions diff --git a/py/BUILD.bazel b/py/BUILD.bazel index 0358708996946..2698244fb9671 100644 --- a/py/BUILD.bazel +++ b/py/BUILD.bazel @@ -36,7 +36,7 @@ compile_pip_requirements( ], ) -SE_VERSION = "4.19.0.nightly" +SE_VERSION = "4.19.0.dev202403101143" BROWSER_VERSIONS = [ "v85", diff --git a/py/docs/source/conf.py b/py/docs/source/conf.py index fe530261c8caa..433869b30a80f 100644 --- a/py/docs/source/conf.py +++ b/py/docs/source/conf.py @@ -58,7 +58,7 @@ # The short X.Y version. version = '4.19' # The full version, including alpha/beta/rc tags. -release = '4.19.0.nightly' +release = '4.19.0.dev202403101143' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/py/selenium/__init__.py b/py/selenium/__init__.py index 7e848ae47b7f7..8c6af30de0afe 100644 --- a/py/selenium/__init__.py +++ b/py/selenium/__init__.py @@ -16,4 +16,4 @@ # under the License. -__version__ = "4.19.0.nightly" +__version__ = "4.19.0.dev202403101143" diff --git a/py/selenium/webdriver/__init__.py b/py/selenium/webdriver/__init__.py index 7ce95dbd0693d..aa5540ba9400d 100644 --- a/py/selenium/webdriver/__init__.py +++ b/py/selenium/webdriver/__init__.py @@ -44,7 +44,7 @@ from .wpewebkit.service import Service as WPEWebKitService # noqa from .wpewebkit.webdriver import WebDriver as WPEWebKit # noqa -__version__ = "4.19.0.nightly" +__version__ = "4.19.0.dev202403101143" # We need an explicit __all__ because the above won't otherwise be exported. __all__ = [ diff --git a/py/setup.py b/py/setup.py index ae4c5c3644b41..39fd531b3f5d6 100755 --- a/py/setup.py +++ b/py/setup.py @@ -27,7 +27,7 @@ setup_args = { 'cmdclass': {'install': install}, 'name': 'selenium', - 'version': "4.19.0.nightly", + 'version': "4.19.0.dev202403101143", 'license': 'Apache 2.0', 'description': 'Python bindings for Selenium', 'long_description': open(join(abspath(dirname(__file__)), "README.rst")).read(),