Skip to content

Commit 868ca84

Browse files
authored
feat: test making Fault available on PIP (#57)
* Add support for building Fault as a binary Python wheel (the Python part being a small shim to execute the Swift app) * Support Swift 5.6 (for RHEL 8/Glibc 2.2.8)
1 parent 0d6ab60 commit 868ca84

File tree

15 files changed

+387
-120
lines changed

15 files changed

+387
-120
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,3 @@ jobs:
2020
extra-trusted-public-keys = openlane.cachix.org-1:qqdwh+QMNGmZAuyeQJTH9ErW57OWSvdtuwfBKdS254E=
2121
- uses: DeterminateSystems/magic-nix-cache-action@main
2222
- run: nix build
23-
push_to_pypi:
24-
name: Build
25-
needs: [test]
26-
runs-on: ubuntu-24.04
27-
steps:
28-
- name: Check out Git repository
29-
uses: actions/checkout@v3
30-
- name: Set default for env.NEW_TAG
31-
run: echo "NEW_TAG=NO_NEW_TAG" >> $GITHUB_ENV
32-
- name: Check for new version
33-
if: ${{ env.BRANCH_NAME == 'main' }}
34-
run: |
35-
python3 .github/scripts/generate_tag.py
36-
- name: Tag Commit
37-
if: ${{ env.NEW_TAG != 'NO_NEW_TAG' }}
38-
uses: tvdias/[email protected]
39-
with:
40-
tag: "${{ env.NEW_TAG }}"
41-
repo-token: "${{ secrets.MY_TOKEN }}"

.github/workflows/wheels.yml

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
#!/usr/bin/env python3
2+
# Copyright (C) 2025 The American University in Cairo
3+
#
4+
# Adapted from Yosys wheels
5+
#
6+
# Copyright (C) 2024 Efabless Corporation
7+
#
8+
# Permission to use, copy, modify, and/or distribute this software for any
9+
# purpose with or without fee is hereby granted, provided that the above
10+
# copyright notice and this permission notice appear in all copies.
11+
#
12+
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13+
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14+
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15+
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16+
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17+
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18+
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19+
name: Build Wheels for PyPI
20+
21+
on:
22+
push:
23+
branches:
24+
- "*"
25+
pull_request:
26+
27+
jobs:
28+
build_wheels:
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
os: [
33+
{
34+
name: "Ubuntu 22.04",
35+
family: "linux",
36+
runner: "ubuntu-22.04",
37+
archs: "x86_64",
38+
},
39+
{
40+
name: "Ubuntu 22.04",
41+
family: "linux",
42+
runner: "ubuntu-22.04-arm",
43+
archs: "aarch64",
44+
},
45+
{
46+
name: "macOS 13",
47+
family: "macos",
48+
runner: "macos-13",
49+
archs: "x86_64",
50+
},
51+
{
52+
name: "macOS 14",
53+
family: "macos",
54+
runner: "macos-14",
55+
archs: "arm64",
56+
},
57+
## Windows is disabled because of an issue with compiling FFI as
58+
## under MinGW in the GitHub Actions environment (SHELL variable has
59+
## whitespace.)
60+
# {
61+
# name: "Windows Server 2019",
62+
# family: "windows",
63+
# runner: "windows-2019",
64+
# archs: "AMD64",
65+
# },
66+
]
67+
name: Build Wheels | ${{ matrix.os.name }} | ${{ matrix.os.archs }}
68+
runs-on: ${{ matrix.os.runner }}
69+
steps:
70+
- uses: actions/checkout@v4
71+
with:
72+
fetch-depth: 0
73+
submodules: true
74+
persist-credentials: false
75+
- uses: actions/setup-python@v5
76+
## Software installed by default in GitHub Action Runner VMs:
77+
## https://github.com/actions/runner-images
78+
- if: ${{ matrix.os.family == 'macos' && matrix.os.archs == 'arm64' }}
79+
name: "[macOS/arm64] Install Python 3.8 (see: https://cibuildwheel.pypa.io/en/stable/faq/#macos-building-cpython-38-wheels-on-arm64)"
80+
uses: actions/setup-python@v5
81+
with:
82+
python-version: 3.8
83+
- name: Build wheels
84+
uses: pypa/cibuildwheel@v2.21.1
85+
env:
86+
# * APIs not supported by PyPy
87+
# * Musllinux disabled to save build time
88+
CIBW_SKIP: >
89+
pp*
90+
*musllinux*
91+
CIBW_ARCHS: ${{ matrix.os.archs }}
92+
CIBW_BUILD_VERBOSITY: "1"
93+
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
94+
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux_2_28
95+
CIBW_BEFORE_ALL: |
96+
if command -v dnf > /dev/null; then
97+
dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
98+
dnf --enablerepo=powertools install -y libstdc++-static
99+
dnf install -y swift-lang
100+
fi
101+
CIBW_ENVIRONMENT: ""
102+
CIBW_ENVIRONMENT_MACOS: >
103+
MACOSX_DEPLOYMENT_TARGET=12
104+
- uses: actions/upload-artifact@v4
105+
with:
106+
name: python-wheels-${{ matrix.os.runner }}
107+
path: ./wheelhouse/*.whl
108+
upload_wheels:
109+
name: Upload Wheels
110+
runs-on: ubuntu-latest
111+
needs: build_wheels
112+
steps:
113+
- name: Check out Git repository
114+
uses: actions/checkout@v4
115+
- uses: actions/download-artifact@v4
116+
with:
117+
path: "."
118+
pattern: python-wheels-*
119+
merge-multiple: true
120+
- run: |
121+
ls
122+
mkdir -p ./dist
123+
mv *.whl ./dist
124+
- name: Set default for env.NEW_TAG
125+
run: echo "NEW_TAG=NO_NEW_TAG" >> $GITHUB_ENV
126+
- name: Check for new version
127+
if: ${{ env.BRANCH_NAME == 'main' }}
128+
run: |
129+
python3 .github/scripts/generate_tag.py
130+
- name: Tag Commit
131+
if: ${{ env.NEW_TAG != 'NO_NEW_TAG' }}
132+
uses: tvdias/github-tagger@v0.0.1
133+
with:
134+
tag: "${{ env.NEW_TAG }}"
135+
repo-token: "${{ secrets.MY_TOKEN }}"
136+
- name: Publish
137+
uses: pypa/gh-action-pypi-publish@release/v1
138+
if: ${{ env.NEW_TAG != 'NO_NEW_TAG' }}
139+
with:
140+
password: ${{ secrets.PYPI_TOKEN }}
141+
repository-url: ${{ vars.PYPI_INDEX || 'https://upload.pypi.org/legacy/' }}

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ Netlists
1414

1515
*.out
1616
*.vcd
17-
/*.py
1817
/*.sv
1918
/*.v
2019
/*.log
@@ -30,3 +29,6 @@ parsetab.py
3029
.swiftpm/
3130
abc.history
3231
temp.txt
32+
*.egg-info
33+
build/
34+
dist/

MANIFEST.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
include Package.swift
2+
recursive-include Sources *.swift
3+
recursive-include fault *.py

Package.resolved

Lines changed: 56 additions & 58 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
// swift-tools-version:5.8
1+
// swift-tools-version:5.6
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription
55

66
let package = Package(
77
name: "Fault",
88
platforms: [
9-
.macOS(.v13) // Regex features only available in Ventura+
9+
.macOS(.v12)
1010
],
1111
dependencies: [
1212
// Dependencies declare other packages that this package depends on.
1313
.package(
1414
url: "https://github.com/apple/swift-collections.git", .upToNextMajor(from: "1.0.0")),
15-
.package(url: "https://github.com/pvieito/PythonKit", from: "0.5.0"),
15+
.package(url: "https://github.com/pvieito/PythonKit", exact: "0.4.2"),
1616
.package(url: "https://github.com/donn/Defile.git", from: "5.2.1"),
1717
.package(url: "https://github.com/attaswift/BigInt.git", from: "5.2.1"),
1818
.package(url: "https://github.com/jpsim/Yams.git", from: "5.0.6"),
19-
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.3.0"),
19+
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.2.0"),
2020
],
2121
targets: [
2222
// Targets are the basic building blocks of a package. A target can define a module or a test suite.

Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<h1 align="center">🧪 Fault</h1>
22

33
<p align="center">
4-
<a href="https://developer.apple.com/swift/"><img src="https://img.shields.io/badge/Swift-5.8-orange?logo=swift" alt="Swift 5.8 or higher"/></a>
4+
<a href="https://developer.apple.com/swift/"><img src="https://img.shields.io/badge/Swift-5.6-orange?logo=swift" alt="Swift 5.6 or higher"/></a>
55
<a href="https://fault.readthedocs.io/en/latest/"><img src="https://readthedocs.org/projects/fault/badge" alt="Read the Docs"/></a>
66
<a href="https://nixos.org/"><img src="https://img.shields.io/static/v1?logo=nixos&logoColor=white&label=&message=Built%20with%20Nix&color=41439a"  
77
alt="Built with Nix"/></a>

Sources/Fault/Entries/main.swift

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import Foundation
2121
import PythonKit
2222
import Yams
2323

24-
let VERSION = "0.8.0"
24+
let VERSION = "0.9.0.dev2"
2525

2626
var env = ProcessInfo.processInfo.environment
2727
let iverilogBase = env["FAULT_IVL_BASE"] ?? "/usr/local/lib/ivl"
@@ -41,13 +41,6 @@ _ = [ // Register all TVGens
4141
PodemQuest.registered,
4242
]
4343

44-
let yosysTest = "'\(yosysExecutable)' -V".sh(silent: true)
45-
if yosysTest != EX_OK {
46-
Stderr.print(
47-
"Yosys must be installed to PATH on your computer for Fault to work. Fault will now quit.")
48-
exit(EX_UNAVAILABLE)
49-
}
50-
5144
let pythonVersions = {
5245
// Test Yosys, Python
5346
() -> (python: String, pyverilog: String) in

0 commit comments

Comments
 (0)