aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2020-03-21 12:51:26 -0400
committerJason R. Coombs <jaraco@jaraco.com>2020-03-21 12:51:32 -0400
commite7f29530df7595a876e4995f2011784ac9f43086 (patch)
tree21b6b8aa7bbd62a931276fc97ad04dd718668c04
parent17dde199ad37b6f9e911e1edb9d2d303e3238157 (diff)
parent52e718872259617203556e4889d451167f209343 (diff)
downloadexternal_python_setuptools-e7f29530df7595a876e4995f2011784ac9f43086.tar.gz
external_python_setuptools-e7f29530df7595a876e4995f2011784ac9f43086.tar.bz2
external_python_setuptools-e7f29530df7595a876e4995f2011784ac9f43086.zip
Merge pull request 1424 from jorikdima.
-rw-r--r--changelog.d/1424.change.rst1
-rw-r--r--setuptools/command/build_py.py2
-rw-r--r--setuptools/tests/test_build_py.py27
3 files changed, 29 insertions, 1 deletions
diff --git a/changelog.d/1424.change.rst b/changelog.d/1424.change.rst
new file mode 100644
index 00000000..361997dd
--- /dev/null
+++ b/changelog.d/1424.change.rst
@@ -0,0 +1 @@
+Prevent keeping files mode for package_data build. It may break a build if user's package data has read only flag. \ No newline at end of file
diff --git a/setuptools/command/build_py.py b/setuptools/command/build_py.py
index b0314fd4..6fc0a4e4 100644
--- a/setuptools/command/build_py.py
+++ b/setuptools/command/build_py.py
@@ -120,7 +120,7 @@ class build_py(orig.build_py, Mixin2to3):
target = os.path.join(build_dir, filename)
self.mkpath(os.path.dirname(target))
srcfile = os.path.join(src_dir, filename)
- outf, copied = self.copy_file(srcfile, target)
+ outf, copied = self.copy_file(srcfile, target, preserve_mode=False)
srcfile = os.path.abspath(srcfile)
if (copied and
srcfile in self.distribution.convert_2to3_doctests):
diff --git a/setuptools/tests/test_build_py.py b/setuptools/tests/test_build_py.py
index b3a99f56..92b455dd 100644
--- a/setuptools/tests/test_build_py.py
+++ b/setuptools/tests/test_build_py.py
@@ -1,4 +1,6 @@
import os
+import stat
+import shutil
from setuptools.dist import Distribution
@@ -20,3 +22,28 @@ def test_directories_in_package_data_glob(tmpdir_cwd):
os.makedirs('path/subpath')
dist.parse_command_line()
dist.run_commands()
+
+
+def test_read_only(tmpdir_cwd):
+ """
+ Ensure mode is not preserved in copy for package modules
+ and package data, as that causes problems
+ with deleting read-only files on Windows.
+
+ #1451
+ """
+ dist = Distribution(dict(
+ script_name='setup.py',
+ script_args=['build_py'],
+ packages=['pkg'],
+ package_data={'pkg': ['data.dat']},
+ name='pkg',
+ ))
+ os.makedirs('pkg')
+ open('pkg/__init__.py', 'w').close()
+ open('pkg/data.dat', 'w').close()
+ os.chmod('pkg/__init__.py', stat.S_IREAD)
+ os.chmod('pkg/data.dat', stat.S_IREAD)
+ dist.parse_command_line()
+ dist.run_commands()
+ shutil.rmtree('build')