forked from xupsh/pp4fpgas-cn-hls
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
79 lines (64 loc) · 2.32 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
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']
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]
# find dirs containing .bit files
def find_designs(path):
return [f 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]
# collect and package the board's overlay designs
def collect_designs():
design_dirs = find_designs(board_folder)
for ds in design_dirs:
new_dir = os.path.join("pp4fpgas", ds)
copy_tree(os.path.join(board_folder, ds), new_dir)
files = exclude_from_files("makefile", new_dir)
data_files.extend([os.path.join("..", new_dir, f) for f in files])
# Copy notebooks in boards/BOARD/notebooks
def copy_notebooks():
if os.path.isdir(board_folder):
dst_folder = os.path.join(notebooks_dir, 'pp4fpgas')
if os.path.exists(dst_folder):
copy_tree(dst_folder, os.path.join("backup", dst_folder))
shutil.rmtree(dst_folder)
copy_tree(os.path.join(board_folder, 'notebooks'), dst_folder)
copy_tree(board_folder,os.path.join('/usr/local/lib',os.environ['PYNQ_PYTHON'],'dist-packages/pynq/overlays/'))
check_env()
collect_designs()
copy_notebooks()
setup(
name="pynq-pp4fpgas",
version='1.0',
install_requires=[
'pynq>=2.1'
],
url='https://github.com/xupsh/pp4fpgas-cn-hls',
license='Apache-2.0',
author="xupsh",
author_email="xup.shanghai@gmail.com",
packages=find_packages(),
package_data={
'': data_files,
},
description="HLS tutorials using pynq on PYNQ-Z1 and PYNQ-Z2 boards"
)