forked from strath-sdr/rfsoc_sam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
92 lines (79 loc) · 2.84 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
import os
import shutil
from distutils.dir_util import copy_tree
from setuptools import find_packages, setup
# global variables
package_name = 'rfsoc_sam'
pip_name = 'rfsoc-sam'
board = os.environ['BOARD']
repo_board_folder = f'boards/{board}/rfsoc_sam'
alt_overlay_folder = [f'boards/{board}/rfsoc_sam']
board_notebooks_dir = os.environ['PYNQ_JUPYTER_NOTEBOOKS']
board_project_dir = os.path.join(board_notebooks_dir, 'spectrum-analyzer')
data_files = []
# check whether board is supported
def check_env():
if not os.path.isdir(repo_board_folder):
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 overlays to python package
def copy_overlays():
for repo_folder in alt_overlay_folder:
src_ol_dir = os.path.join(repo_folder, 'bitstream')
dst_ol_dir = os.path.join(package_name, 'bitstream')
copy_tree(src_ol_dir, dst_ol_dir)
data_files.extend(
[os.path.join("..", dst_ol_dir, f) for f in os.listdir(dst_ol_dir)])
# copy assets to python package
def copy_assets():
src_at_dir = os.path.join(repo_board_folder, 'assets')
dst_at_dir = os.path.join(package_name, 'assets')
copy_tree(src_at_dir, dst_at_dir)
data_files.extend(
[os.path.join("..", dst_at_dir, f) for f in os.listdir(dst_at_dir)])
# copy board specific drivers
def copy_drivers():
src_dr_dir = os.path.join(repo_board_folder, 'drivers')
dst_dr_dir = os.path.join(package_name)
copy_tree(src_dr_dir, dst_dr_dir)
# copy notebooks to jupyter home
def copy_notebooks():
src_nb_dir = os.path.join(repo_board_folder, 'notebooks')
dst_nb_dir = os.path.join(board_project_dir)
copy_tree(src_nb_dir, dst_nb_dir)
# copy xrfclk file to python package (gen3 devices only)
def copy_xrfclk():
src_at_dir = os.path.join(repo_board_folder, 'xrfclk')
if os.path.exists(src_at_dir):
dst_at_dir = os.path.join('xrfclk')
copy_tree(src_at_dir, dst_at_dir)
data_files.extend(
[os.path.join("..", dst_at_dir, f) for f in os.listdir(dst_at_dir)])
check_env()
check_path()
copy_overlays()
copy_assets()
copy_drivers()
copy_notebooks()
copy_xrfclk()
setup(
name=package_name,
version='0.4.2',
install_requires=[
'pynq==2.7',
],
url='https://github.com/strath-sdr/rfsoc_sam',
license='BSD 3-Clause License',
author="Lewis Davin McLaughlin",
author_email="[email protected]",
packages=find_packages(),
package_data={
'': data_files,
},
description="PYNQ example of using the RFSoC as a Spectrum Analyzer.")