mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
Fixed 'find_package_modules()' to ensure that we never build (and thus
install) the setup script itself. Fixed 'build_module()' so we do *not* preserve file mode (which means we can install read-only files, which makes the next installation of this distribution fail -- at least under Unix); added a comment explaining this.
This commit is contained in:
parent
48697d931b
commit
9b45443c1b
1 changed files with 24 additions and 11 deletions
|
@ -6,7 +6,7 @@ Implements the Distutils 'build_py' command."""
|
||||||
|
|
||||||
__rcsid__ = "$Id$"
|
__rcsid__ = "$Id$"
|
||||||
|
|
||||||
import string, os
|
import sys, string, os
|
||||||
from types import *
|
from types import *
|
||||||
from glob import glob
|
from glob import glob
|
||||||
|
|
||||||
|
@ -40,11 +40,21 @@ class BuildPy (Command):
|
||||||
|
|
||||||
def run (self):
|
def run (self):
|
||||||
|
|
||||||
# XXX copy_file by default preserves all stat info -- mode, atime,
|
# XXX copy_file by default preserves atime and mtime. IMHO this is
|
||||||
# and mtime. IMHO this is the right thing to do, but perhaps it
|
# the right thing to do, but perhaps it should be an option -- in
|
||||||
# should be an option -- in particular, a site administrator might
|
# particular, a site administrator might want installed files to
|
||||||
# want installed files to reflect the time of installation rather
|
# reflect the time of installation rather than the last
|
||||||
# than the last modification time before the installed release.
|
# modification time before the installed release.
|
||||||
|
|
||||||
|
# XXX copy_file by default preserves mode, which appears to be the
|
||||||
|
# wrong thing to do: if a file is read-only in the working
|
||||||
|
# directory, we want it to be installed read/write so that the next
|
||||||
|
# installation of the same module distribution can overwrite it
|
||||||
|
# without problems. (This might be a Unix-specific issue.) Thus
|
||||||
|
# we turn off 'preserve_mode' when copying to the build directory,
|
||||||
|
# since the build directory is supposed to be exactly what the
|
||||||
|
# installation will look like (ie. we preserve mode when
|
||||||
|
# installing).
|
||||||
|
|
||||||
# XXX copy_file does *not* preserve MacOS-specific file metadata.
|
# XXX copy_file does *not* preserve MacOS-specific file metadata.
|
||||||
# If this is a problem for building/installing Python modules, then
|
# If this is a problem for building/installing Python modules, then
|
||||||
|
@ -73,7 +83,7 @@ class BuildPy (Command):
|
||||||
if self.modules and self.packages:
|
if self.modules and self.packages:
|
||||||
raise DistutilsOptionError, \
|
raise DistutilsOptionError, \
|
||||||
"build_py: supplying both 'packages' and 'modules' " + \
|
"build_py: supplying both 'packages' and 'modules' " + \
|
||||||
"options not allowed"
|
"options is not allowed"
|
||||||
|
|
||||||
# Now we're down to two cases: 'modules' only and 'packages' only.
|
# Now we're down to two cases: 'modules' only and 'packages' only.
|
||||||
if self.modules:
|
if self.modules:
|
||||||
|
@ -81,7 +91,6 @@ class BuildPy (Command):
|
||||||
else:
|
else:
|
||||||
self.build_packages ()
|
self.build_packages ()
|
||||||
|
|
||||||
|
|
||||||
# run ()
|
# run ()
|
||||||
|
|
||||||
|
|
||||||
|
@ -162,9 +171,13 @@ class BuildPy (Command):
|
||||||
def find_package_modules (self, package, package_dir):
|
def find_package_modules (self, package, package_dir):
|
||||||
module_files = glob (os.path.join (package_dir, "*.py"))
|
module_files = glob (os.path.join (package_dir, "*.py"))
|
||||||
module_pairs = []
|
module_pairs = []
|
||||||
|
setup_script = os.path.abspath (sys.argv[0])
|
||||||
|
|
||||||
for f in module_files:
|
for f in module_files:
|
||||||
module = os.path.splitext (os.path.basename (f))[0]
|
abs_f = os.path.abspath (f)
|
||||||
module_pairs.append (module, f)
|
if abs_f != setup_script:
|
||||||
|
module = os.path.splitext (os.path.basename (f))[0]
|
||||||
|
module_pairs.append ((module, f))
|
||||||
return module_pairs
|
return module_pairs
|
||||||
|
|
||||||
|
|
||||||
|
@ -253,7 +266,7 @@ class BuildPy (Command):
|
||||||
|
|
||||||
dir = os.path.dirname (outfile)
|
dir = os.path.dirname (outfile)
|
||||||
self.mkpath (dir)
|
self.mkpath (dir)
|
||||||
self.copy_file (module_file, outfile)
|
self.copy_file (module_file, outfile, preserve_mode=0)
|
||||||
|
|
||||||
|
|
||||||
def build_modules (self):
|
def build_modules (self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue