| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
import sys |
| 9 |
|
| 10 |
if sys.version_info[:3] < (3, 6, 2): |
| 11 |
version_str = ".".join(sys.version_info[:3]) |
| 12 |
msg = [ |
| 13 |
"This version of cocotb requires at least Python 3.6.2,", |
| 14 |
f"you are running Python {version_str}." |
| 15 |
"For more information please refer to the documentation at ", |
| 16 |
"https://cocotb.readthedocs.io.", |
| 17 |
] |
| 18 |
|
| 19 |
raise SystemExit("\n".join(msg)) |
| 20 |
|
| 21 |
import logging |
| 22 |
import os |
| 23 |
import subprocess |
| 24 |
from io import StringIO |
| 25 |
from os import path, walk |
| 26 |
|
| 27 |
from setuptools import find_packages, setup |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
sys.path.append(path.dirname(__file__)) |
| 33 |
from cocotb_build_libs import build_ext, get_ext |
| 34 |
|
| 35 |
__version__ = "2.0.1" |
| 36 |
|
| 37 |
max_python3_minor_version = 13 |
| 38 |
if "COCOTB_IGNORE_PYTHON_REQUIRES" not in os.environ and sys.version_info >= ( |
| 39 |
3, |
| 40 |
max_python3_minor_version + 1, |
| 41 |
): |
| 42 |
raise RuntimeError( |
| 43 |
f"cocotb {__version__} only supports a maximum Python version of 3.{max_python3_minor_version}.\n" |
| 44 |
"You can suppress this error by defining the environment variable COCOTB_IGNORE_PYTHON_REQUIRES\n" |
| 45 |
"There is no guarantee this will work and no support will be provided." |
| 46 |
) |
| 47 |
|
| 48 |
|
| 49 |
def read_file(fname): |
| 50 |
with open(path.join(path.dirname(__file__), fname), encoding="utf8") as f: |
| 51 |
return f.read() |
| 52 |
|
| 53 |
|
| 54 |
def package_files(directory): |
| 55 |
paths = [] |
| 56 |
for fpath, _, filenames in walk(directory): |
| 57 |
for filename in filenames: |
| 58 |
paths.append(path.join("..", "..", fpath, filename)) |
| 59 |
return paths |
| 60 |
|
| 61 |
|
| 62 |
version_file_path = path.join("src", "cocotb", "_version.py") |
| 63 |
if "dev" in __version__: |
| 64 |
try: |
| 65 |
rev = subprocess.check_output( |
| 66 |
["git", "rev-parse", "--short", "HEAD"], universal_newlines=True |
| 67 |
).strip() |
| 68 |
__version__ += f"+{rev}" |
| 69 |
except Exception as e: |
| 70 |
|
| 71 |
|
| 72 |
if path.exists(version_file_path): |
| 73 |
exec(read_file(version_file_path)) |
| 74 |
else: |
| 75 |
print(e, file=sys.stderr) |
| 76 |
with open(version_file_path, "w") as f: |
| 77 |
f.write("# Package version\n") |
| 78 |
f.write("# Generated by setup.py -- do not modify directly\n\n") |
| 79 |
f.write(f'__version__ = "{__version__}"\n') |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
log_stream = StringIO() |
| 85 |
handler = logging.StreamHandler(log_stream) |
| 86 |
log = logging.getLogger("cocotb_build_libs") |
| 87 |
log.setLevel(logging.INFO) |
| 88 |
log.addHandler(handler) |
| 89 |
|
| 90 |
setup( |
| 91 |
name="cocotb", |
| 92 |
cmdclass={"build_ext": build_ext}, |
| 93 |
version=__version__, |
| 94 |
description="cocotb is a coroutine based cosimulation library for writing VHDL and Verilog testbenches in Python.", |
| 95 |
url="https://www.cocotb.org", |
| 96 |
license="BSD-3-Clause", |
| 97 |
long_description=read_file("README.md"), |
| 98 |
long_description_content_type="text/markdown", |
| 99 |
author="Chris Higgs, Stuart Hodgson", |
| 100 |
maintainer="cocotb contributors", |
| 101 |
maintainer_email="[email protected]", |
| 102 |
install_requires=[ |
| 103 |
"find_libpython", |
| 104 |
], |
| 105 |
python_requires=">=3.6.2", |
| 106 |
packages=find_packages(where="src"), |
| 107 |
package_dir={"": "src"}, |
| 108 |
package_data={ |
| 109 |
"cocotb": ( |
| 110 |
package_files("src/cocotb/share/include") |
| 111 |
+ package_files("src/cocotb/share/lib/verilator") |
| 112 |
), |
| 113 |
"cocotb_tools": (package_files("src/cocotb_tools/makefiles")), |
| 114 |
}, |
| 115 |
ext_modules=get_ext(), |
| 116 |
entry_points={ |
| 117 |
"console_scripts": [ |
| 118 |
"cocotb-config=cocotb_tools.config:main", |
| 119 |
] |
| 120 |
}, |
| 121 |
platforms="any", |
| 122 |
classifiers=[ |
| 123 |
"Programming Language :: Python :: 3", |
| 124 |
"Programming Language :: Python :: 3.6", |
| 125 |
"Programming Language :: Python :: 3.7", |
| 126 |
"Programming Language :: Python :: 3.8", |
| 127 |
"Programming Language :: Python :: 3.9", |
| 128 |
"Programming Language :: Python :: 3.10", |
| 129 |
"Programming Language :: Python :: 3.11", |
| 130 |
"Programming Language :: Python :: 3.12", |
| 131 |
"Programming Language :: Python :: 3.13", |
| 132 |
"Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)", |
| 133 |
"Framework :: cocotb", |
| 134 |
], |
| 135 |
|
| 136 |
project_urls={ |
| 137 |
"Bug Tracker": "https://github.com/cocotb/cocotb/issues", |
| 138 |
"Source Code": "https://github.com/cocotb/cocotb", |
| 139 |
"Documentation": "https://docs.cocotb.org", |
| 140 |
}, |
| 141 |
) |
| 142 |
|
| 143 |
print(log_stream.getvalue()) |