Skip to content

Commit

Permalink
When copying package data, make sure it's writable, but otherwise pre…
Browse files Browse the repository at this point in the history
…serve the mode. Fixes #2041.
  • Loading branch information
jaraco committed Mar 25, 2020
1 parent a3620a4 commit 70e95ee
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions setuptools/command/build_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io
import distutils.errors
import itertools
import stat

from setuptools.extern import six
from setuptools.extern.six.moves import map, filter, filterfalse
Expand All @@ -20,6 +21,10 @@ def run_2to3(self, files, doctests=True):
"do nothing"


def make_writable(target):
os.chmod(target, os.stat(target).st_mode | stat.S_IWRITE)


class build_py(orig.build_py, Mixin2to3):
"""Enhanced 'build_py' command that includes data files with packages
Expand Down Expand Up @@ -120,8 +125,8 @@ def build_package_data(self):
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, preserve_mode=False)
outf, copied = self.copy_file(srcfile, target)
make_writable(target)
srcfile = os.path.abspath(srcfile)
if (copied and
srcfile in self.distribution.convert_2to3_doctests):
Expand Down

0 comments on commit 70e95ee

Please sign in to comment.