Debian Codegraph @

setup.py

raw symbols ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 #!/usr/bin/env python
2 # Copyright cocotb contributors
3 # Copyright (c) 2013 Potential Ventures Ltd
4 # Copyright (c) 2013 SolarFlare Communications Inc
5 # Licensed under the Revised BSD License, see LICENSE for details.
6 # SPDX-License-Identifier: BSD-3-Clause
7
8 import sys
9
10 if sys.version_info[:3] < (3, 6, 2): # noqa: UP036 | bug in ruff
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 # Note: cocotb is not installed properly yet and is missing dependencies and binaries
30 # We can still import other files next to setup.py, as long as they're in MANIFEST.in
31 # The below line is necessary for PEP517 support
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 # if this is not a git repository and _version.py already exists,
71 # we are probably installing from an sdist, so use the existing _version.py
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 # store log from build_libs and display at the end in verbose mode
83 # see https://github.com/pypa/pip/issues/6634
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/def")
112 + package_files("src/cocotb/share/lib/verilator")
113 ),
114 "cocotb_tools": (package_files("src/cocotb_tools/makefiles")),
115 },
116 ext_modules=get_ext(),
117 entry_points={
118 "console_scripts": [
119 "cocotb-config=cocotb_tools.config:main",
120 ]
121 },
122 platforms="any",
123 classifiers=[
124 "Programming Language :: Python :: 3",
125 "Programming Language :: Python :: 3.6",
126 "Programming Language :: Python :: 3.7",
127 "Programming Language :: Python :: 3.8",
128 "Programming Language :: Python :: 3.9",
129 "Programming Language :: Python :: 3.10",
130 "Programming Language :: Python :: 3.11",
131 "Programming Language :: Python :: 3.12",
132 "Programming Language :: Python :: 3.13",
133 "Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)",
134 "Framework :: cocotb",
135 ],
136 # these appear in the sidebar on PyPI
137 project_urls={
138 "Bug Tracker": "https://github.com/cocotb/cocotb/issues",
139 "Source Code": "https://github.com/cocotb/cocotb",
140 "Documentation": "https://docs.cocotb.org",
141 },
142 )
143
144 print(log_stream.getvalue())