-
Notifications
You must be signed in to change notification settings - Fork 144
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
MikePopoloski
merged 7 commits into
MikePopoloski:master
from
parker-research:migrate-pyslang
Jan 17, 2025
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
bcf2362
Copy pyslang files exactly as they were
parker-research 76d6c76
Update bug/feature report templates to ask for C++/Python version
parker-research 9601c22
Update pyproject and `.vscode/settings.json` to point to new paths
parker-research e36ef9d
style: pre-commit fixes
pre-commit-ci[bot] 53d32b5
Add pyslang CI workflows
parker-research e71402e
Implement code review feedback
parker-research 8ff2f40
Fix license in pyproject.toml
parker-research File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
.vs/ | ||
.vscode/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
|
||
# 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 | ||
|
@@ -15,5 +21,11 @@ prefix/ | |
CMakeLists.txt.user | ||
CMakeUserPresets.json | ||
.ccls | ||
_version.py | ||
|
||
# Editor ignores. | ||
.vscode/ | ||
!.vscode/settings.json | ||
|
||
.idea/ | ||
.vs/ | ||
*.code-workspace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 . | ||
``` |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.