Skip to content

Commit 7193598

Browse files
committed
pyosys: tox for non-wheels builds, update instructions
- add `tox` to list of packages: saves builder(s) from manually having to manage a venv for python build dependencies - when building wheels, pip automatically creates the environment with those dependencies, so no need for tox - when running simply `make ENABLE_PYOSYS=1`, this is not the case. people attempting to `pip3 install --upgrade pybind11 cxxheaderparser` to add it to their system packages will be met with a scare message about "breaking system packages" - tox is available from all major package managers all the way back to ubuntu 20.04 and resolves this issue - update installation instructions to drop boost and add tox instead - update ci scripts to use `macos-15[-intel]` (`macos-13` sunset in november)
1 parent 6535995 commit 7193598

File tree

10 files changed

+38
-15
lines changed

10 files changed

+38
-15
lines changed

.github/actions/setup-build-env/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ runs:
88
shell: bash
99
run: |
1010
sudo apt-get update
11-
sudo apt-get install gperf build-essential bison flex libfl-dev libreadline-dev gawk tcl-dev libffi-dev git graphviz xdot pkg-config python3 libboost-system-dev libboost-python-dev libboost-filesystem-dev zlib1g-dev libbz2-dev libgtest-dev
11+
sudo apt-get install gperf build-essential bison flex libfl-dev libreadline-dev gawk tcl-dev libffi-dev git graphviz xdot pkg-config python3-dev tox zlib1g-dev libbz2-dev libgtest-dev
1212
1313
- name: Install macOS Dependencies
1414
if: runner.os == 'macOS'

.github/workflows/test-compile.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
- 'gcc-14'
4646
include:
4747
# macOS x86
48-
- os: macos-13
48+
- os: macos-15-intel
4949
compiler: 'clang-19'
5050
# macOS arm
5151
- os: macos-latest

.github/workflows/wheels.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ jobs:
2727
{
2828
name: "macOS 13",
2929
family: "macos",
30-
runner: "macos-13",
30+
runner: "macos-15-intel",
3131
archs: "x86_64",
3232
},
3333
{
3434
name: "macOS 14",
3535
family: "macos",
36-
runner: "macos-14",
36+
runner: "macos-15",
3737
archs: "arm64",
3838
},
3939
## Windows is disabled because of an issue with compiling FFI as

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
/venv
6262
/*.whl
6363
/*.egg-info
64+
/.tox
6465

6566
# yosysjs dependency
6667
/viz.js

Brewfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ brew "git"
66
brew "graphviz"
77
brew "pkg-config"
88
brew "python3"
9+
brew "tox"
910
brew "xdot"
1011
brew "bash"
11-
brew "boost-python3"
1212
brew "llvm@20"
1313
brew "lld"
1414
brew "googletest"

Makefile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ ENABLE_HELP_SOURCE := 0
2828

2929
# python wrappers
3030
ENABLE_PYOSYS := 0
31+
PYOSYS_USE_TOX := 1
3132

3233
# other configuration flags
3334
ENABLE_GCOV := 0
@@ -352,16 +353,22 @@ PYTHON_OBJECTS = pyosys/wrappers.o kernel/drivers.o kernel/yosys.o passes/cmds/p
352353

353354
ifeq ($(ENABLE_PYOSYS),1)
354355
# python-config --ldflags includes -l and -L, but LINKFLAGS is only -L
356+
357+
TOX_ENV :=
358+
ifeq ($(PYOSYS_USE_TOX),1)
359+
TOX_ENV := tox -qq -e build --
360+
endif
361+
355362
LINKFLAGS += $(filter-out -l%,$(shell $(PYTHON_CONFIG) --ldflags))
356363
LIBS += $(shell $(PYTHON_CONFIG) --libs)
357364
EXE_LIBS += $(filter-out $(LIBS),$(shell $(PYTHON_CONFIG_FOR_EXE) --libs))
358-
PYBIND11_INCLUDE ?= $(shell $(PYTHON_EXECUTABLE) -m pybind11 --includes)
365+
PYBIND11_INCLUDE ?= $(shell $(TOX_ENV) $(PYTHON_EXECUTABLE) -m pybind11 --includes)
359366
CXXFLAGS += -I$(PYBIND11_INCLUDE) -DYOSYS_ENABLE_PYTHON
360367
CXXFLAGS += $(shell $(PYTHON_CONFIG) --includes) -DYOSYS_ENABLE_PYTHON
361368

362369
OBJS += $(PY_WRAPPER_FILE).o
363370
PY_GEN_SCRIPT = pyosys/generator.py
364-
PY_WRAP_INCLUDES := $(shell $(PYTHON_EXECUTABLE) $(PY_GEN_SCRIPT) --print-includes)
371+
PY_WRAP_INCLUDES := $(shell $(TOX_ENV) $(PYTHON_EXECUTABLE) $(PY_GEN_SCRIPT) --print-includes)
365372
endif # ENABLE_PYOSYS
366373

367374
ifeq ($(ENABLE_READLINE),1)
@@ -777,7 +784,7 @@ endif
777784
ifeq ($(ENABLE_PYOSYS),1)
778785
$(PY_WRAPPER_FILE).cc: $(PY_GEN_SCRIPT) pyosys/wrappers_tpl.cc $(PY_WRAP_INCLUDES) pyosys/hashlib.h
779786
$(Q) mkdir -p $(dir $@)
780-
$(P) $(PYTHON_EXECUTABLE) $(PY_GEN_SCRIPT) $(PY_WRAPPER_FILE).cc
787+
$(P) $(TOX_ENV) $(PYTHON_EXECUTABLE) $(PY_GEN_SCRIPT) $(PY_WRAPPER_FILE).cc
781788
endif
782789

783790
%.o: %.cpp

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ prerequisites for building yosys:
8585

8686
$ sudo apt-get install build-essential clang lld bison flex libfl-dev \
8787
libreadline-dev gawk tcl-dev libffi-dev git \
88-
graphviz xdot pkg-config python3 libboost-system-dev \
89-
libboost-python-dev libboost-filesystem-dev zlib1g-dev
88+
graphviz xdot pkg-config python3-dev tox zlib1g-dev
9089

9190
The environment variable `CXX` can be used to control the C++ compiler used, or
9291
run one of the following to override it:

docs/source/getting_started/installation.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ Installing all prerequisites for Ubuntu 22.04:
9999
100100
sudo apt-get install gperf build-essential clang lld bison flex libfl-dev \
101101
libreadline-dev gawk tcl-dev libffi-dev git \
102-
graphviz xdot pkg-config python3 libboost-system-dev \
103-
libboost-python-dev libboost-filesystem-dev zlib1g-dev
102+
graphviz xdot pkg-config python3-dev tox zlib1g-dev
104103
105104
Installing all prerequisites for macOS 13 (with Homebrew):
106105

@@ -141,7 +140,7 @@ For Cygwin use the following command to install all prerequisites, or select the
141140
missing `strdup` function when using gcc. It is instead recommended to use
142141
Windows Subsystem for Linux (WSL) and follow the instructions for Ubuntu.
143142

144-
..
143+
..
145144
For MSYS2 (MINGW64):
146145
147146
.. code:: console
@@ -215,7 +214,7 @@ Running the build system
215214
From the root ``yosys`` directory, call the following commands:
216215

217216
.. code:: console
218-
217+
219218
make
220219
sudo make install
221220
@@ -228,7 +227,7 @@ To use a separate (out-of-tree) build directory, provide a path to the Makefile.
228227
229228
Out-of-tree builds require a clean source tree.
230229

231-
.. seealso::
230+
.. seealso::
232231

233232
Refer to :doc:`/yosys_internals/extending_yosys/test_suites` for details on
234233
testing Yosys once compiled.

docs/source/using_yosys/pyosys.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ methods:
2828

2929
``yosys -y ./my_pyosys_script.py``
3030

31+
Do note this requires some build-time dependencies to be available to Python,
32+
namely, ``pybind11`` and ``cxxheaderparser``. By default, the required
33+
``tox`` package will be used to create an ephemeral environment with the
34+
correct versions of the tools installed.
35+
36+
You can force use of your current Python environment by passing the Makefile
37+
flag ``PYOSYS_USE_TOX=0``.
38+
3139
2. Installing the Pyosys wheels
3240

3341
On macOS and GNU/Linux you can install pre-built wheels of Yosys using

tox.ini

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[tox]
2+
envlist = build
3+
4+
[testenv:build]
5+
skip_install = true
6+
deps =
7+
pybind11>=3,<4
8+
cxxheaderparser
9+
commands = {posargs}

0 commit comments

Comments
 (0)