Skip to content

Commit a3620a4

Browse files
committed
Add test asserting that an executable script retains its executable bit. Ref #2041.
1 parent e5a8bfe commit a3620a4

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

setuptools/tests/test_build_py.py

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ def test_directories_in_package_data_glob(tmpdir_cwd):
2626

2727
def test_read_only(tmpdir_cwd):
2828
"""
29-
Ensure mode is not preserved in copy for package modules
30-
and package data, as that causes problems
31-
with deleting read-only files on Windows.
29+
Ensure read-only flag is not preserved in copy
30+
for package modules and package data, as that
31+
causes problems with deleting read-only files on
32+
Windows.
3233
3334
#1451
3435
"""
@@ -47,3 +48,29 @@ def test_read_only(tmpdir_cwd):
4748
dist.parse_command_line()
4849
dist.run_commands()
4950
shutil.rmtree('build')
51+
52+
53+
def test_executable_data(tmpdir_cwd):
54+
"""
55+
Ensure executable bit is preserved in copy for
56+
package data, as users rely on it for scripts.
57+
58+
#2041
59+
"""
60+
dist = Distribution(dict(
61+
script_name='setup.py',
62+
script_args=['build_py'],
63+
packages=['pkg'],
64+
package_data={'pkg': ['run-me']},
65+
name='pkg',
66+
))
67+
os.makedirs('pkg')
68+
open('pkg/__init__.py', 'w').close()
69+
open('pkg/run-me', 'w').close()
70+
os.chmod('pkg/run-me', 0o700)
71+
72+
dist.parse_command_line()
73+
dist.run_commands()
74+
75+
assert os.stat('build/lib/pkg/run-me').st_mode & stat.S_IEXEC, \
76+
"Script is not executable"

0 commit comments

Comments
 (0)