Skip to content

Commit

Permalink
ENH: Remove python 2.7 support from ctk_compile_file helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
jcfr committed Dec 14, 2023
1 parent fa69a1f commit 530b5f0
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions CMake/ctk_compile_python_scripts.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,12 @@ from __future__ import print_function
# https://github.com/jonashaag/cpython/blob/ce5e5df0c9d8098da05dee26e12ffe2aa331889e/Lib/compileall.py#L61-111
#
import importlib
import os
import sys
import py_compile
import struct
magic = None
if sys.version_info.major>= 3:
import importlib
magic = importlib.util.MAGIC_NUMBER
else:
import imp
magic = imp.get_magic()
def ctk_compile_file(fullname, ddir=None, force=0, rx=None, quiet=0):
\"\"\"Byte-compile one file.
Expand Down Expand Up @@ -54,7 +49,7 @@ def ctk_compile_file(fullname, ddir=None, force=0, rx=None, quiet=0):
if not force:
try:
mtime = int(os.stat(fullname).st_mtime)
expect = struct.pack('<4sl', magic, mtime)
expect = struct.pack('<4sl', importlib.util.MAGIC_NUMBER, mtime)
cfile = fullname + (__debug__ and 'c' or 'o')
with open(cfile, 'rb') as chandle:
actual = chandle.read(8)
Expand Down

0 comments on commit 530b5f0

Please sign in to comment.