Skip to content

Commit

Permalink
move to python 3.9.9 with embedded tcltk
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinhendricks committed Dec 22, 2021
1 parent dd0e8e2 commit 3db0c13
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 10 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Expand Up @@ -109,7 +109,7 @@ message(STATUS "CMake version in use: ${CMAKE_VERSION}")
if (${USE_NEWER_FINDPYTHON3})
message(STATUS "Using newer findpython3 cmake module")
if ( APPLE )
find_package(Python3 3.8 COMPONENTS Interpreter Development)
find_package(Python3 3.9 COMPONENTS Interpreter Development)
endif()
if ( WIN32 )
find_package(Python3 3.5 COMPONENTS Interpreter Development)
Expand All @@ -120,8 +120,8 @@ if (${USE_NEWER_FINDPYTHON3})
else()
message(STATUS "Using older findpython cmake module")
if ( APPLE )
find_package(PythonInterp 3.8)
find_package (PythonLibs 3.8)
find_package(PythonInterp 3.9)
find_package (PythonLibs 3.9)
endif()
if ( WIN32 )
find_package(PythonInterp 3.5)
Expand Down
2 changes: 1 addition & 1 deletion cmake_extras/FindPythonInterp.cmake
Expand Up @@ -52,7 +52,7 @@ unset(_Python_NAMES)

set(_PYTHON1_VERSIONS 1.6 1.5)
set(_PYTHON2_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0)
set(_PYTHON3_VERSIONS 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0)
set(_PYTHON3_VERSIONS 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0)

if(PythonInterp_FIND_VERSION)
if(PythonInterp_FIND_VERSION_COUNT GREATER 1)
Expand Down
2 changes: 1 addition & 1 deletion cmake_extras/FindPythonLibs.cmake
Expand Up @@ -84,7 +84,7 @@ set(CMAKE_FIND_FRAMEWORK LAST)

set(_PYTHON1_VERSIONS 1.6 1.5)
set(_PYTHON2_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0)
set(_PYTHON3_VERSIONS 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0)
set(_PYTHON3_VERSIONS 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0)

if(PythonLibs_FIND_VERSION)
if(PythonLibs_FIND_VERSION_COUNT GREATER 1)
Expand Down
38 changes: 37 additions & 1 deletion src/Resource_Files/python_pkg/osx_add_python_framework.py
Expand Up @@ -66,6 +66,18 @@
# ('test_regex.py', 'f'),


def copy_python_tcltk(src_dir, dest_dir):
for x in os.listdir(src_dir):
y = os.path.join(src_dir, x)
ext = os.path.splitext(x)[1]
if os.path.isdir(y) and x not in ('python' + pversion, 'tcl8', 'pkgconfig', 'demos', 'tzdata'):
shutil.copytree(y, os.path.join(dest_dir, x),
ignore=ignore_in_tcltk_dirs)
if os.path.isfile(y) and ext not in ('.sh', '.chm', '.htm', '.txt'):
if x != 'libpython' + pversion + '.dylib':
shutil.copy2(y, dest_dir)


def copy_python_stdlibrary(src_dir, dest_dir):
for x in os.listdir(src_dir):
y = os.path.join(src_dir, x)
Expand Down Expand Up @@ -104,6 +116,23 @@ def copy_site_packages(packages, site_dest):
break


def ignore_in_tcltk_dirs(base, items, ignored_dirs=None):
ans = []
dylibname = 'libpython' + pversion + '.dylib'
if ignored_dirs is None:
ignored_dirs = {'tcl8', 'python' + pversion, 'pkgconfig', 'demos', 'tzdata'}
for name in items:
path = os.path.join(base, name)
if os.path.isdir(path):
if name in ignored_dirs:
ans.append(name)
else:
if name.rpartition('.')[-1] in ('chm', 'htm', 'html', 'txt' ):
ans.append(name)
if name == dylibname:
ans.append(name)
return ans

def ignore_in_dirs(base, items, ignored_dirs=None):
ans = []
if ignored_dirs is None:
Expand Down Expand Up @@ -176,6 +205,8 @@ def main():
dest_dir = os.path.join(app_dir,'Python.framework','Versions', pversion, 'lib', stdlib_name, 'site-packages')
copy_site_packages(site_packages, dest_dir)

dest_dir = os.path.join(app_dir,'Python.framework','Versions', pversion, 'lib')

# now pre-compile all of the .py code and replace it by .pyc
dest_dir = os.path.join(app_dir,'Python.framework','Versions', pversion, 'lib', stdlib_name)
for x in os.walk(dest_dir):
Expand All @@ -190,8 +221,14 @@ def main():
# if os.path.exists(z):
# os.remove(z)
except:

print ('Failed to byte-compile', y)

# copy the embedded tcl/tk fpieces
tcltksrcdir = os.path.join(build_fwk, 'lib')
tcltkdestdir = os.path.join(app_dir, 'Python.framework', 'Versions', pversion, 'lib')
copy_python_tcltk(tcltksrcdir, tcltkdestdir)

# next copy the bin
src_file = os.path.join(build_fwk, 'bin', 'python3')
dest_file = os.path.join(app_dir, 'Python.framework', 'Versions', pversion, 'bin', 'python3')
Expand All @@ -218,7 +255,6 @@ def main():
os.symlink(os.path.join('Versions', 'Current', 'Resources'), 'Resources')

os.chdir(os.path.join(app_dir, 'Python.framework', 'Versions', pversion, 'lib'))
# dylibname = 'libpython' + pversion + 'm.dylib'
dylibname = 'libpython' + pversion + '.dylib'
os.symlink('../Python', dylibname)

Expand Down
37 changes: 36 additions & 1 deletion src/Resource_Files/python_pkg/osx_add_python_framework6.py
Expand Up @@ -56,6 +56,18 @@
('PySide6', 'd')]


def copy_python_tcltk(src_dir, dest_dir):
for x in os.listdir(src_dir):
y = os.path.join(src_dir, x)
ext = os.path.splitext(x)[1]
if os.path.isdir(y) and x not in ('python' + pversion, 'tcl8', 'pkgconfig', 'demos', 'tzdata'):
shutil.copytree(y, os.path.join(dest_dir, x),
ignore=ignore_in_tcltk_dirs)
if os.path.isfile(y) and ext not in ('.sh', '.chm', '.htm', '.txt'):
if x != 'libpython' + pversion + '.dylib':
shutil.copy2(y, dest_dir)


def copy_python_stdlibrary(src_dir, dest_dir):
for x in os.listdir(src_dir):
y = os.path.join(src_dir, x)
Expand Down Expand Up @@ -93,7 +105,7 @@ def copy_site_packages(packages, site_dest):
else:
break


def ignore_in_dirs(base, items, ignored_dirs=None):
ans = []
if ignored_dirs is None:
Expand Down Expand Up @@ -126,6 +138,24 @@ def ignore_in_pyside6_dirs(base, items, ignored_dirs=None):
return ans


def ignore_in_tcltk_dirs(base, items, ignored_dirs=None):
ans = []
dylibname = 'libpython' + pversion + '.dylib'
if ignored_dirs is None:
ignored_dirs = {'tcl8', 'python' + pversion, 'pkgconfig', 'demos', 'tzdata'}
for name in items:
path = os.path.join(base, name)
if os.path.isdir(path):
if name in ignored_dirs:
ans.append(name)
else:
if name.rpartition('.')[-1] in ('chm', 'htm', 'html', 'txt' ):
ans.append(name)
if name == dylibname:
ans.append(name)
return ans


def get_rpaths(path_to_executable):
rpaths = []
raw = subprocess.check_output(['otool', '-l', path_to_executable])
Expand Down Expand Up @@ -174,6 +204,11 @@ def main():
except:
print ('Failed to byte-compile', y)

# copy the embedded tcl/tk fpieces
tcltksrcdir = os.path.join(build_fwk, 'lib')
tcltkdestdir = os.path.join(app_dir, 'Python.framework', 'Versions', pversion, 'lib')
copy_python_tcltk(tcltksrcdir, tcltkdestdir)

# next copy the bin
src_file = os.path.join(build_fwk, 'bin', 'python3')
dest_file = os.path.join(app_dir, 'Python.framework', 'Versions', pversion, 'bin', 'python3')
Expand Down
6 changes: 3 additions & 3 deletions src/sigil_constants.cpp
@@ -1,6 +1,6 @@
/************************************************************************
**
** Copyright (C) 2015-2020 Kevin B. Hendricks, Stratford Ontario Canada
** Copyright (C) 2015-2021 Kevin B. Hendricks, Stratford Ontario Canada
** Copyright (C) 2015-2021 Doug Massay
** Copyright (C) 2009-2011 Strahinja Markovic <strahinja.markovic@gmail.com>
**
Expand Down Expand Up @@ -43,9 +43,9 @@ const bool DONT_CHECK_FOR_UPDATES = DONT_CHECK_UPDATES;

#if __APPLE__
const QString PATH_LIST_DELIM = ":";
const QString PYTHON_MAIN_PREFIX = "/Frameworks/Python.framework/Versions/3.8";
const QString PYTHON_MAIN_PREFIX = "/Frameworks/Python.framework/Versions/3.9";
const QString PYTHON_MAIN_BIN_PATH = PYTHON_MAIN_PREFIX + "/bin/python3";
const QString PYTHON_LIB_PATH = "/lib/python3.8";
const QString PYTHON_LIB_PATH = "/lib/python3.9";
const QString PYTHON_SITE_PACKAGES = PYTHON_MAIN_PREFIX + PYTHON_LIB_PATH + "/site-packages";
const QStringList PYTHON_SYS_PATHS = QStringList () << "/lib-dynload" << "/site-packages";
#endif
Expand Down

0 comments on commit 3db0c13

Please sign in to comment.