[Python-checkins] bpo-42613: Fix freeze.py config directory (GH-23792) (GH-23817)

vstinner webhook-mailer at python.org
Thu Dec 17 09:29:46 EST 2020


https://github.com/python/cpython/commit/79c535796da4a1377364910e309b97e53c3e51ef
commit: 79c535796da4a1377364910e309b97e53c3e51ef
branch: 3.9
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: vstinner <vstinner at python.org>
date: 2020-12-17T15:29:36+01:00
summary:

bpo-42613: Fix freeze.py config directory (GH-23792) (GH-23817)

Fix freeze.py tool to use the prope config and library directories.
(cherry picked from commit 1c653f17cb84d81df3a74ab0b42140d2bb68c5c4)

Co-authored-by: Victor Stinner <vstinner at python.org>

Co-authored-by: Victor Stinner <vstinner at python.org>

files:
A Misc/NEWS.d/next/Tools-Demos/2020-12-16-09-10-32.bpo-42613.J-jnm5.rst
M Tools/freeze/freeze.py

diff --git a/Misc/NEWS.d/next/Tools-Demos/2020-12-16-09-10-32.bpo-42613.J-jnm5.rst b/Misc/NEWS.d/next/Tools-Demos/2020-12-16-09-10-32.bpo-42613.J-jnm5.rst
new file mode 100644
index 0000000000000..140ff8255b96b
--- /dev/null
+++ b/Misc/NEWS.d/next/Tools-Demos/2020-12-16-09-10-32.bpo-42613.J-jnm5.rst
@@ -0,0 +1,2 @@
+Fix ``freeze.py`` tool to use the prope config and library directories.
+Patch by Victor Stinner.
diff --git a/Tools/freeze/freeze.py b/Tools/freeze/freeze.py
index 83aa508a46a93..d66e1e2708e75 100755
--- a/Tools/freeze/freeze.py
+++ b/Tools/freeze/freeze.py
@@ -93,6 +93,7 @@
 import getopt
 import os
 import sys
+import sysconfig
 
 
 # Import the freeze-private modules
@@ -226,7 +227,7 @@ def main():
         extensions_c = 'frozen_extensions.c'
     if ishome:
         print("(Using Python source directory)")
-        binlib = exec_prefix
+        configdir = exec_prefix
         incldir = os.path.join(prefix, 'Include')
         config_h_dir = exec_prefix
         config_c_in = os.path.join(prefix, 'Modules', 'config.c.in')
@@ -235,22 +236,21 @@ def main():
         if win:
             frozendllmain_c = os.path.join(exec_prefix, 'Pc\\frozen_dllmain.c')
     else:
-        binlib = os.path.join(exec_prefix,
-                              'lib', 'python%s' % version,
-                              'config-%s' % flagged_version)
+        configdir = sysconfig.get_config_var('LIBPL')
         incldir = os.path.join(prefix, 'include', 'python%s' % flagged_version)
         config_h_dir = os.path.join(exec_prefix, 'include',
                                     'python%s' % flagged_version)
-        config_c_in = os.path.join(binlib, 'config.c.in')
-        frozenmain_c = os.path.join(binlib, 'frozenmain.c')
-        makefile_in = os.path.join(binlib, 'Makefile')
-        frozendllmain_c = os.path.join(binlib, 'frozen_dllmain.c')
+        config_c_in = os.path.join(configdir, 'config.c.in')
+        frozenmain_c = os.path.join(configdir, 'frozenmain.c')
+        makefile_in = os.path.join(configdir, 'Makefile')
+        frozendllmain_c = os.path.join(configdir, 'frozen_dllmain.c')
+    libdir = sysconfig.get_config_var('LIBDIR')
     supp_sources = []
     defines = []
     includes = ['-I' + incldir, '-I' + config_h_dir]
 
     # sanity check of directories and files
-    check_dirs = [prefix, exec_prefix, binlib, incldir]
+    check_dirs = [prefix, exec_prefix, configdir, incldir]
     if not win:
         # These are not directories on Windows.
         check_dirs = check_dirs + extensions
@@ -457,7 +457,7 @@ def main():
 
     cflags = ['$(OPT)']
     cppflags = defines + includes
-    libs = [os.path.join(binlib, '$(LDLIBRARY)')]
+    libs = [os.path.join(libdir, '$(LDLIBRARY)')]
 
     somevars = {}
     if os.path.exists(makefile_in):



More information about the Python-checkins mailing list