-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
34 lines (26 loc) · 1 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# used when installing the project as a pip package
import os
from setuptools import setup
# from: https://stackoverflow.com/questions/27664504/how-to-add-package-data-recursively-in-python-setup-py
def package_files(directory) -> list:
"""
This will make sure that ANY file within `recommerce/` is included in the pip package.
Args:
directory (str): The directory to check, in our case, 'recommerce'.
Returns:
list: The list of files found.
"""
paths = []
for (path, directories, filenames) in os.walk(directory):
paths.extend(os.path.join('..', path, filename) for filename in filenames if '__pycache__' not in path)
return paths
if __name__ == '__main__':
extra_files = package_files('recommerce')
# handle the user_path.txt in configuration/
with open(os.path.join(os.path.dirname(__file__), 'recommerce', 'configuration', 'user_path.txt'), 'w') as path_file:
path_file.write(os.path.abspath('.'))
# install the pip package
setup(
packages=['recommerce'],
package_data={'': extra_files}
)