forked from strath-sdr/rfsoc_qsfp_offload
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
82 lines (72 loc) · 2.45 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
import os
import shutil
from distutils.dir_util import copy_tree
from setuptools import find_packages, setup
# globals
package_name = 'rfsoc_qsfp_offload'
board = os.environ['BOARD']
repo_board_dir = f'boards/{board}/{package_name}'
board_notebooks_dir = os.environ['PYNQ_JUPYTER_NOTEBOOKS']
board_project_dir = os.path.join(board_notebooks_dir, 'rfsoc-offload')
data_files = ['network_layer.json']
# check whether board is supported
def check_env():
if not os.path.isdir(repo_board_dir):
raise ValueError("Board {} is not supported.".format(board))
if not os.path.isdir(board_notebooks_dir):
raise ValueError(
"Directory {} does not exist.".format(board_notebooks_dir))
# check if the path already exists, delete if so
def check_path():
if os.path.exists(board_project_dir):
shutil.rmtree(board_project_dir)
# copy bitstream to python package
def copy_bitstream():
src_dir = os.path.join(repo_board_dir, 'bitstream')
dst_dir = os.path.join(package_name, 'bitstream')
copy_tree(src_dir, dst_dir)
data_files.extend(
[os.path.join("..", dst_dir, f) for f in os.listdir(dst_dir)])
# copy assets to python package
def copy_assets():
src_dir = os.path.join(f'assets')
dst_dir = os.path.join(package_name, 'assets')
copy_tree(src_dir, dst_dir)
data_files.extend(
[os.path.join("..", dst_dir, f) for f in os.listdir(dst_dir)])
# copy board specific drivers
def copy_drivers():
src_dir = os.path.join(repo_board_dir, 'drivers')
dst_dir = os.path.join(package_name)
copy_tree(src_dir, dst_dir)
data_files.extend(
[os.path.join("..", dst_dir, f) for f in os.listdir(dst_dir)])
# copy notebooks to jupyter home
def copy_notebooks():
src_nb_dir = os.path.join((repo_board_dir), 'notebooks')
dst_nb_dir = os.path.join(board_project_dir)
if os.path.exists(dst_nb_dir):
shutil.rmtree(dst_nb_dir)
copy_tree(src_nb_dir, dst_nb_dir)
check_env()
check_path()
copy_bitstream()
copy_assets()
copy_drivers()
copy_notebooks()
setup(
name="rfsoc_qsfp_offload",
version='0.0.3',
install_requires=[
'pynq>=2.7',
],
url='https://github.com/',
license='BSD 3-Clause License',
author='Josh Goldsmith',
author_email='[email protected]',
packages=find_packages(),
package_data={
'': data_files,
},
description="QSFP offload for RFSoC"
)