Skip to content

Commit

Permalink
Merge pull request #3084 from siliconcompiler/print-lics
Browse files Browse the repository at this point in the history
print licenses
  • Loading branch information
gadfort authored Dec 21, 2024
2 parents 75410e3 + 4bd9eae commit 815fe52
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
5 changes: 4 additions & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@ python:
- method: pip
path: .
extra_requirements:
- build
- docs
- test
- lint
- profile
- examples
25 changes: 19 additions & 6 deletions docs/_ext/requirements.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from sphinx.util.docutils import SphinxDirective
from docutils.parsers.rst import directives
import os
import re
from importlib.metadata import requires
import json
import subprocess
Expand All @@ -20,32 +21,44 @@ def run(self):

self.env.note_dependency(f'{SC_ROOT}/pyproject.toml')

requirements = [str(pkg).split()[0] for pkg in requires('siliconcompiler')]
find_name = re.compile(r'^([a-z\-_]+)')
find_extra = re.compile(r'extra == "(\w+)"')
requirements = [
find_name.match(pkg.lower()).groups(0)[0] for pkg in requires('siliconcompiler')]
if 'siliconcompiler' in requirements:
requirements.remove('siliconcompiler')
requirements = set(requirements)

extras = {}
for pkg in requires('siliconcompiler'):
name = find_name.match(pkg.lower()).groups(0)[0]
extras.setdefault(name, []).extend(find_extra.findall(pkg.lower()))

output = subprocess.check_output(['pip-licenses', '--format=json'])
pkg_data = json.loads(output)

if show_version:
entries = [[strong('Name'), strong('Version'), strong('License')]]
entries = [[strong('Name'), strong('Version'), strong('License'), strong('Extra')]]
else:
entries = [[strong('Name'), strong('License')]]
entries = [[strong('Name'), strong('License'), strong('Extra')]]

packages = {}
for pkg in pkg_data:
name = pkg['Name']
if name not in requirements:
if name.lower() not in requirements:
continue
package_url = f'https://pypi.org/project/{name}'
p = nodes.paragraph()
p += link(package_url, text=name)
version = pkg['Version']
license = pkg['License'].splitlines()[0]
if license.lower() == "unknown":
license = "---"
extra = ", ".join(set(extras.setdefault(name.lower(), [])))
if show_version:
packages[name] = [p, para(version), para(license)]
packages[extra, name.lower()] = [p, para(version), para(license), para(extra)]
else:
packages[name] = [p, para(license)]
packages[extra, name.lower()] = [p, para(license), para(extra)]

for pkg in sorted(packages.keys()):
entries.append(packages[pkg])
Expand Down
16 changes: 0 additions & 16 deletions docs/reference_manual/appendix/licenses.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,3 @@ SiliconCompiler.

.. requirements_licenses::
:version:

The precompiled SiliconCompiler wheels distributed on PyPI include the following
bundled dependencies:

.. table::
:widths: 300 300

============================================ ========================
Name License
============================================ ========================
`Si2 LEF parser`_ (distributed by OpenROAD) `Apache Software License <https://github.com/The-OpenROAD-Project/OpenROAD/blob/master/src/odb/src/lef/LICENSE.TXT>`__
`Surelog`_ `Apache Software License <https://github.com/chipsalliance/Surelog/blob/master/LICENSE>`__
============================================ ========================

.. _Si2 LEF parser: https://github.com/The-OpenROAD-Project/OpenROAD/tree/master/src/odb/src/lef
.. _Surelog: https://github.com/chipsalliance/Surelog/

0 comments on commit 815fe52

Please sign in to comment.