Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
7e2f3074
Commit
7e2f3074
authored
Mar 25, 2020
by
Jason R. Coombs
Committed by
GitHub
Mar 25, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2046 from pypa/bugfix/1607-retain-executable-mode
Retain executable mode
parents
e5a8bfed
ef3a3864
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
5 deletions
+46
-5
changelog.d/2041.bugfix.rst
changelog.d/2041.bugfix.rst
+1
-0
setuptools/command/build_py.py
setuptools/command/build_py.py
+7
-2
setuptools/tests/test_build_py.py
setuptools/tests/test_build_py.py
+38
-3
No files found.
changelog.d/2041.bugfix.rst
0 → 100644
View file @
7e2f3074
Preserve file modes during pkg files copying, but clear read only flag for target afterwards.
setuptools/command/build_py.py
View file @
7e2f3074
...
...
@@ -7,6 +7,7 @@ import textwrap
import
io
import
distutils.errors
import
itertools
import
stat
from
setuptools.extern
import
six
from
setuptools.extern.six.moves
import
map
,
filter
,
filterfalse
...
...
@@ -20,6 +21,10 @@ except ImportError:
"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
...
...
@@ -120,8 +125,8 @@ 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
,
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
):
...
...
setuptools/tests/test_build_py.py
View file @
7e2f3074
...
...
@@ -2,6 +2,8 @@ import os
import
stat
import
shutil
import
pytest
from
setuptools.dist
import
Distribution
...
...
@@ -26,9 +28,10 @@ def test_directories_in_package_data_glob(tmpdir_cwd):
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.
Ensure read-only flag is not preserved in copy
for package modules and package data, as that
causes problems with deleting read-only files on
Windows.
#1451
"""
...
...
@@ -47,3 +50,35 @@ def test_read_only(tmpdir_cwd):
dist
.
parse_command_line
()
dist
.
run_commands
()
shutil
.
rmtree
(
'build'
)
@
pytest
.
mark
.
xfail
(
'platform.system() == "Windows"'
,
reason
=
"On Windows, files do not have executable bits"
,
raises
=
AssertionError
,
strict
=
True
,
)
def
test_executable_data
(
tmpdir_cwd
):
"""
Ensure executable bit is preserved in copy for
package data, as users rely on it for scripts.
#2041
"""
dist
=
Distribution
(
dict
(
script_name
=
'setup.py'
,
script_args
=
[
'build_py'
],
packages
=
[
'pkg'
],
package_data
=
{
'pkg'
:
[
'run-me'
]},
name
=
'pkg'
,
))
os
.
makedirs
(
'pkg'
)
open
(
'pkg/__init__.py'
,
'w'
).
close
()
open
(
'pkg/run-me'
,
'w'
).
close
()
os
.
chmod
(
'pkg/run-me'
,
0o700
)
dist
.
parse_command_line
()
dist
.
run_commands
()
assert
os
.
stat
(
'build/lib/pkg/run-me'
).
st_mode
&
stat
.
S_IEXEC
,
\
"Script is not executable"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment