diff --git a/Lib/msilib/__init__.py b/Lib/msilib/__init__.py --- a/Lib/msilib/__init__.py +++ b/Lib/msilib/__init__.py @@ -1,12 +1,18 @@ # Copyright (C) 2005 Martin v. Löwis # Licensed to PSF under a Contributor Agreement. from _msi import * -import os, string, re, sys +import fnmatch +import glob +import os +import os.path +import re +import string +import sys AMD64 = "AMD64" in sys.version Itanium = "Itanium" in sys.version Win64 = AMD64 or Itanium # Partially taken from Wine datasizemask= 0x00ff type_valid= 0x0100 @@ -370,17 +376,17 @@ class Directory: self.logical, 2), (logical+"o", self.component, "%sO|%so" % (short, file), self.logical, 2)]) return logical def glob(self, pattern, exclude = None): """Add a list of files to the current component as specified in the glob pattern. Individual files can be excluded in the exclude list.""" - files = glob.glob1(self.absolute, pattern) + files = glob.glob(os.path.join(fnmatch.escape(self.absolute), pattern)) for f in files: if exclude and f in exclude: continue self.add_file(f) return files def remove_pyc(self): "Remove .pyc/.pyo files on uninstall" add_data(self.db, "RemoveFile", diff --git a/Tools/msi/msi.py b/Tools/msi/msi.py --- a/Tools/msi/msi.py +++ b/Tools/msi/msi.py @@ -1,11 +1,12 @@ # Python MSI Generator # (C) 2003 Martin v. Loewis # See "FOO" in comments refers to MSDN sections with the title FOO. +import fnmatch, os.path import msilib, schema, sequence, os, glob, time, re, shutil, zipfile import subprocess, tempfile from msilib import Feature, CAB, Directory, Dialog, Binary, add_data import uisample from win32com.client import constants from distutils.spawn import find_executable # Settings can be overridden in config.py below @@ -1093,20 +1094,23 @@ def add_files(db): if have_tcl: if not os.path.exists("%s/%s/_tkinter.pyd" % (srcdir, PCBUILD)): print("WARNING: Missing _tkinter.pyd") else: lib.start_component("TkDLLs", tcltk) lib.add_file("_tkinter.pyd") dlls.append("_tkinter.pyd") tcldir = os.path.normpath(srcdir+("/../tcltk%s/bin" % tclsuffix)) - for f in glob.glob1(tcldir, "*.dll"): + tclfiles = glob.glob(os.path.join(fnmatch.escape(tcldir), "*.dll")) + for f in tclfiles: lib.add_file(f, src=os.path.join(tcldir, f)) # check whether there are any unknown extensions - for f in glob.glob1(srcdir+"/"+PCBUILD, "*.pyd"): + pydfiles = glob.glob(os.path.join(fnmatch.escape(srcdir + "/" + PCBUILD), + "*.pyd")) + for f in pydfiles: if f.endswith("_d.pyd"): continue # debug version if f in dlls: continue print("WARNING: Unknown extension", f) # Add headers default_feature.set_current() lib = PyDirectory(db, cab, root, "include", "include", "INCLUDE|include") lib.glob("*.h") @@ -1319,17 +1323,19 @@ def add_registry(db): ]) db.Commit() def build_pdbzip(): pdbexclude = ['kill_python.pdb', 'make_buildinfo.pdb', 'make_versioninfo.pdb'] path = "python-%s%s-pdb.zip" % (full_current_version, msilib.arch_ext) pdbzip = zipfile.ZipFile(path, 'w') - for f in glob.glob1(os.path.join(srcdir, PCBUILD), "*.pdb"): + pdbfiles = glob.glob(os.path.join(fnmatch.escape(os.path.join(srcdir, PCBUILD)), + "*.pdb")) + for f in pdbfiles: if f not in pdbexclude and not f.endswith('_d.pdb'): pdbzip.write(os.path.join(srcdir, PCBUILD, f), f) pdbzip.close() db,msiname = build_database() try: add_features(db) add_ui(db) diff --git a/Tools/msi/msilib.py b/Tools/msi/msilib.py --- a/Tools/msi/msilib.py +++ b/Tools/msi/msilib.py @@ -1,16 +1,27 @@ # Microsoft Installer Library # (C) 2003 Martin v. Loewis import win32com.client.gencache import win32com.client import pythoncom, pywintypes from win32com.client import constants -import re, string, os, sets, glob, subprocess, sys, _winreg, struct, _msi +import fnmatch +import glob +import os +import os.path +import re +import sets +import string +import struct +import subprocess +import sys +import _msi +import _winreg try: basestring except NameError: basestring = (str, unicode) # Partially taken from Wine datasizemask= 0x00ff @@ -540,17 +551,17 @@ class Directory: # [(logical+"c", self.component, "%sC|%sc" % (short, file), # self.logical, 2), # (logical+"o", self.component, "%sO|%so" % (short, file), # self.logical, 2)]) def glob(self, pattern, exclude = None): """Add a list of files to the current component as specified in the glob pattern. Individual files can be excluded in the exclude list.""" - files = glob.glob1(self.absolute, pattern) + files = glob.glob(os.path.join(fnmatch.escape(self.absolute), pattern)) for f in files: if exclude and f in exclude: continue self.add_file(f) return files def remove_pyc(self): "Remove .pyc/.pyo files from __pycache__ on uninstall" directory = self.logical + "_pycache"