Skip to content

Commit 4b0c927

Browse files
committed
Modified setup.py to include data_files
1 parent 4c75b99 commit 4b0c927

2 files changed

Lines changed: 55 additions & 2 deletions

File tree

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ prune doc/build
77
recursive-include pythonforandroid *.py *.tmpl
88
recursive-include pythonforandroid/recipes *.py *.patch *.c *.pyx
99

10-
recursive-include pythonforandroid/bootstraps *.properties *.xml *.java *.tmpl *.txt
10+
recursive-include pythonforandroid/bootstraps *.properties *.xml *.java *.tmpl *.txt *.png
1111

1212
prune .git
1313
prune pythonforandroid/bootstraps/pygame/build/libs

setup.py

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,57 @@
11

22
from setuptools import setup, find_packages
3+
from os import walk
4+
from os.path import join, dirname
5+
import os
6+
import glob
7+
8+
# NOTE: All package data should also be set in MANIFEST.in
9+
10+
packages = find_packages()
11+
12+
package_data = {'': ['*.tmpl',
13+
'*.patch', ], }
14+
15+
16+
data_files = []
17+
18+
# Include any patches under recipes
19+
# recipes = {}
20+
# recipes_allowed_ext = ('patch', )
21+
# for root, subfolders, files in walk('pythonforandroid/recipes'):
22+
# for fn in files:
23+
# ext = fn.split('.')[-1].lower()
24+
# if ext not in recipes_allowed_ext:
25+
# continue
26+
# filename = join(root, fn)
27+
# # directory = '%s%s' % (data_file_prefix, dirname(filename))
28+
# directory = root
29+
# if not directory in recipes:
30+
# recipes[directory] = []
31+
# recipes[directory].append(filename)
32+
33+
# print('recipes is', recipes)
34+
# data_files = recipes.items()
35+
36+
def recursively_include(results, directory, allowed_exts):
37+
for root, subfolders, files in walk(directory):
38+
for fn in files:
39+
if not any([glob.fnmatch.fnmatch(fn, pattern) for pattern in allowed_exts]):
40+
continue
41+
# ext = fn.split('.')[-1].lower()
42+
# if ext not in allowed_exts:
43+
# continue
44+
filename = join(root, fn)
45+
directory = root
46+
if directory not in results:
47+
results[directory] = []
48+
results[directory].append(filename)
49+
50+
data_files = {}
51+
recursively_include(data_files, 'pythonforandroid/recipes', ['*.patch', ])
52+
recursively_include(data_files, 'pythonforandroid/bootstraps',
53+
['*.properties', '*.xml', '*.java', '*.tmpl', '*.txt', '*.png'])
354

4-
# NOTE: All package data is set in MANIFEST.in
555

656
setup(name='python-for-android',
757
version='0.2',
@@ -34,4 +84,7 @@
3484
'Topic :: Software Development',
3585
'Topic :: Utilities',
3686
],
87+
packages=packages,
88+
package_data=package_data,
89+
data_files=data_files.items(),
3790
)

0 commit comments

Comments
 (0)