-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsetup.py
executable file
·97 lines (81 loc) · 2.98 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
from setuptools import setup, find_packages
from distutils.dir_util import copy_tree
import glob
import os
import subprocess
import sys
import shutil
# global variables
board = os.environ['BOARD']
board_folder = 'boards/{}/'.format(board)
notebooks_dir = os.environ['PYNQ_JUPYTER_NOTEBOOKS']
prio_data_files = []
# check whether board is supported
def check_env():
if not os.path.isdir(board_folder):
raise ValueError("Board {} is not supported.".format(board))
if not os.path.isdir(notebooks_dir):
raise ValueError("Directory {} does not exist.".format(notebooks_dir))
# excludes file from path and returns other files
def exclude_from_files(exclude, path):
return [file for file in os.listdir(path)
if os.path.isfile(os.path.join(path, file))
and file != exclude]
def get_files(path):
return [file for file in os.listdir(path)
if os.path.isfile(os.path.join(path, file))]
# find dirs containing .bit files
def find_designs(path):
result = []
if os.path.isdir(path) and len(os.listdir(path)) > 0:
for f in os.listdir(path):
if os.path.isdir(os.path.join(path, f)) \
and len(glob.glob(os.path.join(path, f, "*.bit"))) > 0:
result += [f]
print("f: " + f)
tmp = find_designs(os.path.join(path, f))
for p in tmp:
result += [os.path.join(f, p)]
return result
# collect and package the board's overlay designs
def collect_prio_designs():
design_dirs = find_designs(board_folder)
for ds in design_dirs:
copy_tree(os.path.join(board_folder, ds), ds)
files = exclude_from_files("makefile", ds)
prio_data_files.extend([os.path.join("..", ds, f) for f in files])
dtbo_src = os.path.join(board_folder, "prio_linux/dtbo")
dtbo_dst = "prio_linux/dtbo"
copy_tree(dtbo_src, dtbo_dst)
files = get_files(dtbo_dst)
prio_data_files.extend([os.path.join('..', dtbo_dst, f) for f in files])
# Copy notebooks in boards/BOARD/notebooks
def copy_notebooks():
if os.path.isdir(board_folder):
dst_folder = notebooks_dir
if os.path.exists(os.path.join(dst_folder, 'prio')):
shutil.rmtree(os.path.join(dst_folder, 'prio'))
if os.path.exists(os.path.join(dst_folder, 'prio_linux')):
shutil.rmtree(os.path.join(dst_folder, 'prio_linux'))
copy_tree(os.path.join(board_folder, 'notebooks'), dst_folder)
check_env()
collect_prio_designs()
copy_notebooks()
setup(
name="pynq_prio",
version='1.0',
install_requires=[
'pynq>=2.5',
'pyserial',
'smbus2'
],
url='https://github.com/byuccl/PYNQ-PRIO',
license='BSD 3-Clause License',
author="Hayden Cook, Tanner Gaskin",
author_email="haydencook95@gmail.com, gaskin.tanner@byu.edu",
packages=find_packages(),
package_data={
'': prio_data_files,
},
description="Partially Reconfigurable Input Output Project supporting PYNQ-enabled boards"
)