Skip to content

Commit

Permalink
package lib for pypi
Browse files Browse the repository at this point in the history
cleanup
  • Loading branch information
gadfort committed Dec 8, 2023
1 parent 18b3fb0 commit 16a12f5
Show file tree
Hide file tree
Showing 173 changed files with 217 additions and 14 deletions.
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
max-line-length = 100
extend-exclude = build
extend-ignore =
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI
on:
# Runs on all pushes to branches
push:
# Runs on all PRs
pull_request:
# Manual Dispatch
workflow_dispatch:

jobs:
lint_python:
name: Lint Python Code
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v4
- name: Lint with Flake8
run: |
pip install --upgrade pip
pip install .[dev]
flake8 --statistics .
check_paths:
name: Run CI
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v4
- name: Run tests
run: |
pip install --upgrade pip
pip install -e .[dev]
pytest
49 changes: 49 additions & 0 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Wheels

on:
workflow_dispatch:
release:
types:
- published

jobs:
build_wheels:
name: Wheels lambdalib
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: hynek/build-and-inspect-python-package@v1

publish:
needs: [build_wheels]
runs-on: ubuntu-latest
permissions:
id-token: write
if: github.event_name == 'release' && github.event.action == 'published'

steps:
- uses: actions/download-artifact@v3
with:
name: Packages
path: dist

- name: Publish
uses: pypa/[email protected]

save:
needs: [publish]
runs-on: ubuntu-latest

steps:
- uses: actions/download-artifact@v3
with:
name: Packages
path: dist

- name: Add wheels to GitHub release artifacts
uses: softprops/action-gh-release@v1
with:
files: dist/*.whl
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ a.out

# Byte-compiled / optimized / DLL files
__pycache__/
lambdalib.egg-info/
build/
dist/
22 changes: 22 additions & 0 deletions lambdalib/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import os
import pkg_resources
try:
__version__ = pkg_resources.get_distribution('lambdalib').version
except: # noqa E722
__version__ = None


def register_data_source(chip):
# check if local
root_path = os.path.dirname(os.path.dirname(__file__))
test_path = os.path.join(root_path, 'lambdalib', 'iolib', 'rtl', 'la_ioanalog.v')
if os.path.exists(test_path):
path = root_path
ref = None
else:
path = 'git+https://github.com/siliconcompiler/lambdalib.git'
ref = f'v{__version__}'

chip.register_package_source(name='lambdalib',
path=path,
ref=ref)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
37 changes: 26 additions & 11 deletions lambdalib/lambdalib.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,37 @@
import siliconcompiler
from lambdalib import register_data_source
from siliconcompiler import Library
import os


########################
# SiliconCompiler Setup
########################

def setup(target=None):
def setup(chip):
'''Lambdalib library setup script'''

# Create chip object
chip = siliconcompiler.Chip('lambdalib')

# Project sources
root = os.path.realpath(os.path.join(os.path.dirname(__file__), '..'))
root = os.path.dirname(__file__)

dependencies = {
'iolib': ['stdlib'],
'stdlib': [],
'ramlib': ['stdlib'],
'padring': ['stdlib'],
'syslib': ['stdlib'],
'vectorlib': ['stdlib']
}

register_data_source(chip)

libs = []
# Iterate over all libs
for item in ['iolib', 'stdlib', 'ramlib', 'padring']:
chip.add('option', 'ydir', f"{root}/{item}/rtl")
chip.add('option', 'idir', f"{root}/{item}/rtl")
for name, dep in dependencies.items():
lib = Library(chip, f'la_{name}', package='lambdalib')

for path in [name, *dep]:
lib.add('option', 'ydir', f"{root}/{path}/rtl")
lib.add('option', 'idir', f"{root}/{path}/rtl")

libs.append(lib)

return chip
return libs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import re
import siliconcompiler


Expand All @@ -15,5 +14,5 @@
chip.add('option', 'ydir', f'{root}/submodules/openpdks/pdks/sky130/libs/sky130io/bb')
chip.set('option', 'relax', True)
chip.set('option', 'steplist', ['import', 'syn', 'floorplan'])
chip.set('asic', 'diearea', [(0,0), (2000,2000)])
chip.set('asic', 'diearea', [(0, 0), (2000, 2000)])
chip.run()
2 changes: 1 addition & 1 deletion padring/padring.py → lambdalib/padring/padring.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import siliconcompiler
import os


########################
# SiliconCompiler Setup
########################

def setup(target=None):
'''Lambdalib Padring Setup'''

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
37 changes: 37 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[build-system]
requires = [
"setuptools >= 61.2",
"setuptools_scm[toml] >= 6.2"
]
build-backend = "setuptools.build_meta"

[tool.setuptools]
include-package-data = false
packages = [
"lambdalib"
]

[project]
name = "lambdalib"
authors = [{name = "Zero ASIC"}]
description = "Standardized ASIC design libraries"
readme = "README.md"
urls = {Homepage = "https://github.com/siliconcompiler/lambdalib"}
requires-python = ">= 3.8"
license = {file = "LICENSE"}
dependencies = [
"siliconcompiler >= 0.17.0"
]
version = "0.1.0"

[tool.pytest.ini_options]
testpaths = "tests"
timeout = "60"

[project.optional-dependencies]
# Dev dependencies.
dev = [
"flake8 >= 5.0.0",
"pytest >= 6.2.4",
"pytest-timeout >= 2.1.0"
]
8 changes: 8 additions & 0 deletions tests/test_local_detect.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from siliconcompiler import Chip
from lambdalib import register_data_source


def test_local_install_detection():
chip = Chip('<test>')
register_data_source(chip)
assert 'git+https' not in chip.get('package', 'source', 'lambdalib', 'path')
9 changes: 9 additions & 0 deletions tests/test_paths.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from siliconcompiler import Chip

from lambdalib import lambdalib


def test_pdk_paths():
chip = Chip('<lib>')
chip.use(lambdalib)
assert chip.check_filepaths()
24 changes: 24 additions & 0 deletions tests/test_setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from siliconcompiler import Chip

from lambdalib import lambdalib


def test_setup_without_depencency():
chip = Chip('<lib>')
chip.use(lambdalib)

assert 'la_stdlib' in chip.getkeys('library')

assert len(chip.get('library', 'la_stdlib', 'option', 'ydir')) == 1


def test_setup_with_depencency():
chip = Chip('<lib>')
chip.use(lambdalib)

assert 'la_stdlib' in chip.getkeys('library')
assert 'la_iolib' in chip.getkeys('library')
assert 'la_ramlib' in chip.getkeys('library')

assert len(chip.get('library', 'la_iolib', 'option', 'ydir')) == 2
assert len(chip.get('library', 'la_ramlib', 'option', 'ydir')) == 2

0 comments on commit 16a12f5

Please sign in to comment.