Skip to content

Commit 4009654

Browse files
linesightclaude
andcommitted
examples: replace packaging.version with stdlib tuple comparison
Removes the third-party `packaging` dependency from all example scripts. The upstream master branch has no such requirement, and the version checks only need simple numeric comparisons that a split+tuple handles cleanly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 17911e6 commit 4009654

7 files changed

Lines changed: 7 additions & 14 deletions

File tree

examples/hello_world.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
from cefpython3 import cefpython as cef
1414
import platform
15-
from packaging.version import Version as parse_version
1615

1716

1817
def main():
@@ -34,7 +33,7 @@ def check_versions():
3433
print("[hello_world.py] Python {ver} {arch}".format(
3534
ver=platform.python_version(),
3635
arch=platform.architecture()[0]))
37-
assert parse_version(cef.__version__) >= parse_version("57.0"), \
36+
assert tuple(int(x) for x in cef.__version__.split(".")) >= (57, 0), \
3837
"CEF Python v57.0+ required to run this"
3938

4039

examples/pywin32.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from cefpython3 import cefpython as cef
1717

1818
import distutils.sysconfig
19-
from packaging.version import Version as parse_version
2019
import math
2120
import os
2221
import platform
@@ -109,7 +108,7 @@ def check_versions():
109108
pywin32_version = fp.read().strip()
110109
print("[pywin32.py] pywin32 {ver}".format(ver=pywin32_version))
111110

112-
assert parse_version(cef.__version__) >= parse_version("57.0"), "CEF Python v57.0+ required to run this"
111+
assert tuple(int(x) for x in cef.__version__.split(".")) >= (57, 0), "CEF Python v57.0+ required to run this"
113112

114113

115114
def create_browser(window_info, settings, url):

examples/qt.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import platform
1313
import subprocess
1414
import sys
15-
from packaging.version import Version as parse_version
1615

1716
# GLOBALS
1817
PYQT5 = False
@@ -140,7 +139,7 @@ def check_versions():
140139
print("[qt.py] PySide6 {v1} (qt {v2})".format(
141140
v1=PySide6.__version__, v2=QtCore.__version__))
142141
# CEF Python version requirement
143-
assert parse_version(cef.__version__) >= parse_version("55.4"), "CEF Python v55.4+ required to run this"
142+
assert tuple(int(x) for x in cef.__version__.split(".")) >= (55, 4), "CEF Python v55.4+ required to run this"
144143

145144

146145
class MainWindow(QMainWindow):

examples/screenshot.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
"""
3737

3838
from cefpython3 import cefpython as cef
39-
from packaging.version import Version as parse_version
4039
import os
4140
import platform
4241
import subprocess
@@ -115,7 +114,7 @@ def check_versions():
115114
ver=platform.python_version(),
116115
arch=platform.architecture()[0]))
117116
print("[screenshot.py] Pillow {ver}".format(ver=PILLOW_VERSION))
118-
assert parse_version(cef.__version__) >= parse_version("57.0"), "CEF Python v57.0+ required to run this"
117+
assert tuple(int(x) for x in cef.__version__.split(".")) >= (57, 0), "CEF Python v57.0+ required to run this"
119118

120119

121120
def command_line_arguments():

examples/tkinter_.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import os
2727
import platform
2828
import logging as _logging
29-
from packaging.version import Version as parse_version
3029

3130
# Fix for PyCharm hints warnings
3231
WindowUtils = cef.WindowUtils()
@@ -54,7 +53,7 @@ def main():
5453
logger.info("Python {ver} {arch}".format(
5554
ver=platform.python_version(), arch=platform.architecture()[0]))
5655
logger.info("Tk {ver}".format(ver=tk.Tcl().eval('info patchlevel')))
57-
assert parse_version(cef.__version__) >= parse_version("55.3"), "CEF Python v55.3+ required to run this"
56+
assert tuple(int(x) for x in cef.__version__.split(".")) >= (55, 3), "CEF Python v55.3+ required to run this"
5857
sys.excepthook = cef.ExceptHook # To shutdown all CEF processes on error
5958
# Tk must be initialized before CEF otherwise fatal error (Issue #306)
6059
root = tk.Tk()

examples/tutorial.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import platform
77
import sys
88
import threading
9-
from packaging.version import Version as parse_version
109

1110
# HTML code. Browser will navigate to a Data uri created
1211
# from this html code.
@@ -86,7 +85,7 @@ def check_versions():
8685
print("[tutorial.py] Python {ver} {arch}".format(
8786
ver=platform.python_version(),
8887
arch=platform.architecture()[0]))
89-
assert parse_version(cef.__version__) >= parse_version("57.0"), "CEF Python v57.0+ required to run this"
88+
assert tuple(int(x) for x in cef.__version__.split(".")) >= (57, 0), "CEF Python v57.0+ required to run this"
9089

9190

9291
def html_to_data_uri(html, js_callback=None):

examples/wxpython.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import platform
1313
import sys
1414
import os
15-
from packaging.version import Version as parse_version
1615

1716
# Platforms
1817
WINDOWS = (platform.system() == "Windows")
@@ -63,7 +62,7 @@ def check_versions():
6362
ver=platform.python_version(), arch=platform.architecture()[0]))
6463
print("[wxpython.py] wxPython {ver}".format(ver=wx.version()))
6564
# CEF Python version requirement
66-
assert parse_version(cef.__version__) >= parse_version("66.0"), "CEF Python v66.0+ required to run this"
65+
assert tuple(int(x) for x in cef.__version__.split(".")) >= (66, 0), "CEF Python v66.0+ required to run this"
6766

6867

6968
def scale_window_size_for_high_dpi(width, height):

0 commit comments

Comments
 (0)