Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate pyslang into this repository #1210

Merged
merged 7 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ assignees: ''

---

**Is your bug report related to the C++ slang project or the pyslang Python bindings?**
C++ slang / Pyslang Python bindings

**Describe the bug**
A clear and concise description of what the bug is.

Expand Down
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ assignees: ''

---

**Is your feature request related to the C++ slang project or the pyslang Python bindings?**
C++ slang / Pyslang Python bindings

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is.

Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/python-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: "Python Build"

on:
workflow_dispatch:
pull_request:
push:
branches:
- master

jobs:
build:
name: Build with Pip
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
platform: [windows-latest, macos-latest, ubuntu-latest]
python-version: ["3.11", "pypy-3.9"]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- uses: maxim-lobanov/setup-xcode@v1
if: matrix.platform == 'macos-latest'
with:
xcode-version: 'latest'
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
- name: Build and install
run: pip install --verbose .
- name: Test
run: pytest
95 changes: 95 additions & 0 deletions .github/workflows/python-dist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: "Python Dist"
on:
workflow_dispatch:
push:
branches:
- master
release:
types:
- published

jobs:
build_sdist:
name: Build SDist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Build SDist
run: pipx run build --sdist
- name: Check metadata
run: pipx run twine check dist/*
- uses: actions/upload-artifact@v4
with:
path: dist/*.tar.gz
name: artifact-sdist

build_wheels:
name: Wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- uses: maxim-lobanov/setup-xcode@v1
if: matrix.os == 'macos-latest'
with:
xcode-version: 'latest'
- uses: pypa/cibuildwheel@v2.21.3
env:
CIBW_ARCHS_MACOS: auto universal2
MACOSX_DEPLOYMENT_TARGET: "10.15"
- name: Verify clean directory
run: git diff --exit-code
shell: bash
- uses: actions/upload-artifact@v4
with:
path: wheelhouse/*.whl
name: artifact-${{ matrix.os }}

upload_test:
name: Upload test
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags')
steps:
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- uses: actions/download-artifact@v4
with:
pattern: artifact-*
path: dist
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: setup this secret in this repo before landing.

repository-url: https://test.pypi.org/legacy/
verbose: true
skip_existing: true

upload_official:
name: Upload official
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
if: (github.event_name == 'release' && github.event.action == 'published') || github.event_name == 'workflow_dispatch'
steps:
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- uses: actions/download-artifact@v4
with:
pattern: artifact-*
path: dist
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
verbose: true
20 changes: 16 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
.vs/
.vscode/
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think .vs or .vscode should be unignored -- you can just exempt the one settings.json file like:

!.vscode/settings.json

# Python ignores.
.pytest_cache/
.venv/
venv/
.idea/
.cache/
.DS_Store
__pycache__/
*.pyc
*.pyo
*.pyd
_version.py

# C and CMake ignores.
build/
install/
compile_commands.json
Expand All @@ -15,5 +21,11 @@ prefix/
CMakeLists.txt.user
CMakeUserPresets.json
.ccls
_version.py

# Editor ignores.
.vscode/
!.vscode/settings.json

.idea/
.vs/
*.code-workspace
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"python.testing.pytestArgs": [],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
}
69 changes: 69 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
[project]
name = "pyslang"
version = "7.0.1"
description = "Python bindings for slang, a library for compiling SystemVerilog"
readme = {file = "pyslang/README.md", content-type = "text/markdown"}
authors = [{name = "Mike Popoloski"}]
keywords = ["slang", "verilog", "systemverilog", "parsing", "compiler", "eda"]
license = {file = "LICENSE"}
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Operating System :: Unix",
"Programming Language :: C++",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)",
"Topic :: Software Development :: Compilers",
"Topic :: Software Development :: Libraries :: Python Modules"
]

[project.urls]
Homepage = "https://sv-lang.com/"
Documentation = "https://sv-lang.com/"
Repository = "https://github.com/MikePopoloski/slang"
Issues = "https://github.com/MikePopoloski/slang/issues"
Changelog = "https://github.com/MikePopoloski/slang/blob/master/CHANGELOG.md"

[project.optional-dependencies]
test = ["pytest"]

[build-system]
requires = [
"pybind11",
"scikit-build-core",
]
build-backend = "scikit_build_core.build"

[tool.scikit-build]
build-dir = "build/{wheel_tag}"
cmake.source-dir = "."
install.components = ["pylib"]
sdist.exclude = [
".github",
"./build",
"./install",
"./tests",
"./tools",
]
wheel.packages = ["pyslang/pyslang"]

[tool.scikit-build.cmake.define]
SLANG_INCLUDE_TESTS = "OFF"
SLANG_INCLUDE_TOOLS = "OFF"
SLANG_INCLUDE_PYLIB = "ON"

[tool.cibuildwheel]
archs = ["auto64"]
manylinux-x86_64-image = "manylinux_2_28"
skip = ["pp*", "cp36-*", "*musllinux*"]
build-verbosity = 1
test-command = "pytest {project}/tests"
test-extras = ["test"]
test-skip = ["*universal2:arm64"]

[tool.pytest.ini_options]
testpaths = ["pyslang/tests"]
35 changes: 35 additions & 0 deletions pyslang/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Contributing to `pyslang`

Pyslang, the Python bindings for the [slang project](https://github.com/MikePopoloski/slang), are built, tested, and packaged with code in this repository.

The bulk of functional code is in the [`slang` repository](https://github.com/MikePopoloski/slang). Please refer to its [CONTRIBUTING.md](https://github.com/MikePopoloski/slang/blob/master/CONTRIBUTING.md) guide for more information on contributing to the core project.

## Python Bindings

Python bindings are built using [pybind11](https://github.com/pybind/pybind11).

## Documentation

All documentation is contained in the `docs` directory of the `slang` repository.

## Building and Testing

1. Clone the `pyslang` repository (https://github.com/MikePopoloski/pyslang)
2. Clone the `slang` submodule:

```bash
git submodule update --init --recursive
```

3. Optionally, create a virtual environment and activate it.

```bash
python3 -m venv venv
source venv/bin/activate
```

4. Install `pyslang` as a Python package (including building the C++ `slang` library with bindings, from the submodule):

```bash
pip install .
```
Loading
Loading