forked from chipsalliance/f4pga
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
132 lines (117 loc) · 4.12 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (C) 2022 F4PGA Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
from pathlib import Path
from typing import List
from shutil import which
from subprocess import run
from setuptools import setup as setuptools_setup
from os import environ
FPGA_FAM = environ.get('FPGA_FAM', 'xc7')
packagePath = Path(__file__).resolve().parent
requirementsFile = packagePath / "requirements.txt"
# Read requirements file and add them to package dependency list
def get_requirements(file: Path) -> List[str]:
requirements = []
with file.open("r") as fh:
for line in fh.read().splitlines():
if line.startswith("#") or line == "":
continue
elif line.startswith("-r"):
# Remove the first word/argument (-r)
filename = " ".join(line.split(" ")[1:])
requirements += get_requirements(file.parent / filename)
elif line.startswith("https"):
# Convert 'URL#NAME' to 'NAME @ URL'
splitItems = line.split("#")
requirements.append("{} @ {}".format(splitItems[1], splitItems[0]))
else:
requirements.append(line)
return requirements
semver = "0.0.0"
version = None
with (packagePath.parent / '.gitcommit').open("r") as rptr:
sha = rptr.read().strip()
if sha != '$Format:%h$':
version = f'{semver}-{sha}'
git = which('git')
if git is not None:
proc = run(['git', 'rev-parse', 'HEAD'], capture_output=True)
if proc.returncode == 0:
version = f'{semver}-{proc.stdout.decode("utf8")[0:8]}'
if version is None:
version = semver
sf = "symbiflow"
shwrappers = "f4pga.wrappers.sh.__init__"
setuptools_setup(
name=packagePath.name,
version=version,
license="Apache-2.0",
author="F4PGA Authors",
description="F4PGA.",
url="https://github.com/chipsalliance/f4pga",
packages=[
"f4pga",
"f4pga.common_modules",
"f4pga.wrappers.sh",
"f4pga.wrappers.tcl"
],
package_dir={"f4pga": "."},
package_data={
'f4pga': [
'*.yml',
],
'f4pga.wrappers.sh': [
'xc7/*.f4pga.sh',
'quicklogic/*.f4pga.sh'
],
'f4pga.wrappers.tcl': [
'xc7/*.f4pga.tcl',
'eos-s3/*.f4pga.tcl',
'qlf_k4n8/*.f4pga.tcl',
'ice40/*.f4pga.tcl',
]
},
classifiers=[],
python_requires='>=3.6',
install_requires=list(set(get_requirements(requirementsFile))),
entry_points={
"console_scripts": [
"f4pga = f4pga.__init__:main",
f"{sf}_pack = {shwrappers}:pack",
f"{sf}_place = {shwrappers}:place",
f"{sf}_route = {shwrappers}:route",
f"{sf}_synth = {shwrappers}:synth",
f"{sf}_write_fasm = {shwrappers}:write_fasm"
] + (
[
f"{sf}_write_bitstream = {shwrappers}:write_bitstream",
] if FPGA_FAM == 'xc7' else [
f"{sf}_analysis = {shwrappers}:analysis",
f"{sf}_fasm2bels = {shwrappers}:fasm2bels",
f"{sf}_generate_bitstream = {shwrappers}:generate_bitstream",
f"{sf}_repack = {shwrappers}:repack",
f"{sf}_write_binary = {shwrappers}:write_binary",
f"{sf}_write_bitheader = {shwrappers}:write_bitheader",
f"{sf}_write_jlink = {shwrappers}:write_jlink",
f"{sf}_write_openocd = {shwrappers}:write_openocd",
f"ql_{sf} = {shwrappers}:ql",
]
)
},
)