Skip to content

Commit

Permalink
Allow recursive globs for package_data
Browse files Browse the repository at this point in the history
  • Loading branch information
nullableVoidPtr committed May 7, 2022
1 parent ddb8844 commit 019ad89
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion setuptools/command/build_py.py
@@ -1,3 +1,4 @@
from functools import partial
from glob import glob
from distutils.util import convert_path
import distutils.command.build_py as orig
Expand Down Expand Up @@ -98,7 +99,7 @@ def find_data_files(self, package, src_dir):
package,
src_dir,
)
globs_expanded = map(glob, patterns)
globs_expanded = map(partial(glob, recursive=True), patterns)
# flatten the expanded globs into an iterable of matches
globs_matches = itertools.chain.from_iterable(globs_expanded)
glob_files = filter(os.path.isfile, globs_matches)
Expand Down
23 changes: 23 additions & 0 deletions setuptools/tests/test_build_py.py
Expand Up @@ -25,6 +25,29 @@ def test_directories_in_package_data_glob(tmpdir_cwd):
dist.run_commands()


def test_recursive_in_package_data_glob(tmpdir_cwd):
"""
Files matching recursive globs (**) in package_data should
be included in the package data.
#1806
"""
dist = Distribution(dict(
script_name='setup.py',
script_args=['build_py'],
packages=[''],
package_data={'': ['path/**/data']},
))
os.makedirs('path/subpath/subsubpath')
open('path/subpath/subsubpath/data', 'w').close()

dist.parse_command_line()
dist.run_commands()

assert stat.S_IREG(os.stat('build/lib/path/subpath/subsubpath/data').st_mode), \
"File is not included"


def test_read_only(tmpdir_cwd):
"""
Ensure read-only flag is not preserved in copy
Expand Down

0 comments on commit 019ad89

Please sign in to comment.