mirror of
https://github.com/YosysHQ/yosys
synced 2025-11-04 21:39:14 +00:00
pyosys: tox for non-wheel builds, update instructions
- add `tox` to list of dependencies: 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 early december)
This commit is contained in:
parent
b510c36162
commit
2b38a2385c
10 changed files with 38 additions and 15 deletions
2
.github/actions/setup-build-env/action.yml
vendored
2
.github/actions/setup-build-env/action.yml
vendored
|
|
@ -8,7 +8,7 @@ runs:
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
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
|
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
|
||||||
|
|
||||||
- name: Install macOS Dependencies
|
- name: Install macOS Dependencies
|
||||||
if: runner.os == 'macOS'
|
if: runner.os == 'macOS'
|
||||||
|
|
|
||||||
2
.github/workflows/test-compile.yml
vendored
2
.github/workflows/test-compile.yml
vendored
|
|
@ -45,7 +45,7 @@ jobs:
|
||||||
- 'gcc-14'
|
- 'gcc-14'
|
||||||
include:
|
include:
|
||||||
# macOS x86
|
# macOS x86
|
||||||
- os: macos-13
|
- os: macos-15-intel
|
||||||
compiler: 'clang-19'
|
compiler: 'clang-19'
|
||||||
# macOS arm
|
# macOS arm
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
|
|
|
||||||
4
.github/workflows/wheels.yml
vendored
4
.github/workflows/wheels.yml
vendored
|
|
@ -27,13 +27,13 @@ jobs:
|
||||||
{
|
{
|
||||||
name: "macOS 13",
|
name: "macOS 13",
|
||||||
family: "macos",
|
family: "macos",
|
||||||
runner: "macos-13",
|
runner: "macos-15-intel",
|
||||||
archs: "x86_64",
|
archs: "x86_64",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "macOS 14",
|
name: "macOS 14",
|
||||||
family: "macos",
|
family: "macos",
|
||||||
runner: "macos-14",
|
runner: "macos-15",
|
||||||
archs: "arm64",
|
archs: "arm64",
|
||||||
},
|
},
|
||||||
## Windows is disabled because of an issue with compiling FFI as
|
## Windows is disabled because of an issue with compiling FFI as
|
||||||
|
|
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -61,6 +61,7 @@
|
||||||
/venv
|
/venv
|
||||||
/*.whl
|
/*.whl
|
||||||
/*.egg-info
|
/*.egg-info
|
||||||
|
/.tox
|
||||||
|
|
||||||
# yosysjs dependency
|
# yosysjs dependency
|
||||||
/viz.js
|
/viz.js
|
||||||
|
|
|
||||||
2
Brewfile
2
Brewfile
|
|
@ -6,9 +6,9 @@ brew "git"
|
||||||
brew "graphviz"
|
brew "graphviz"
|
||||||
brew "pkg-config"
|
brew "pkg-config"
|
||||||
brew "python3"
|
brew "python3"
|
||||||
|
brew "tox"
|
||||||
brew "xdot"
|
brew "xdot"
|
||||||
brew "bash"
|
brew "bash"
|
||||||
brew "boost-python3"
|
|
||||||
brew "llvm@20"
|
brew "llvm@20"
|
||||||
brew "lld"
|
brew "lld"
|
||||||
brew "googletest"
|
brew "googletest"
|
||||||
|
|
|
||||||
13
Makefile
13
Makefile
|
|
@ -28,6 +28,7 @@ ENABLE_HELP_SOURCE := 0
|
||||||
|
|
||||||
# python wrappers
|
# python wrappers
|
||||||
ENABLE_PYOSYS := 0
|
ENABLE_PYOSYS := 0
|
||||||
|
PYOSYS_USE_TOX := 1
|
||||||
|
|
||||||
# other configuration flags
|
# other configuration flags
|
||||||
ENABLE_GCOV := 0
|
ENABLE_GCOV := 0
|
||||||
|
|
@ -352,16 +353,22 @@ PYTHON_OBJECTS = pyosys/wrappers.o kernel/drivers.o kernel/yosys.o passes/cmds/p
|
||||||
|
|
||||||
ifeq ($(ENABLE_PYOSYS),1)
|
ifeq ($(ENABLE_PYOSYS),1)
|
||||||
# python-config --ldflags includes -l and -L, but LINKFLAGS is only -L
|
# python-config --ldflags includes -l and -L, but LINKFLAGS is only -L
|
||||||
|
|
||||||
|
TOX_ENV :=
|
||||||
|
ifeq ($(PYOSYS_USE_TOX),1)
|
||||||
|
TOX_ENV := tox -qq -e build --
|
||||||
|
endif
|
||||||
|
|
||||||
LINKFLAGS += $(filter-out -l%,$(shell $(PYTHON_CONFIG) --ldflags))
|
LINKFLAGS += $(filter-out -l%,$(shell $(PYTHON_CONFIG) --ldflags))
|
||||||
LIBS += $(shell $(PYTHON_CONFIG) --libs)
|
LIBS += $(shell $(PYTHON_CONFIG) --libs)
|
||||||
EXE_LIBS += $(filter-out $(LIBS),$(shell $(PYTHON_CONFIG_FOR_EXE) --libs))
|
EXE_LIBS += $(filter-out $(LIBS),$(shell $(PYTHON_CONFIG_FOR_EXE) --libs))
|
||||||
PYBIND11_INCLUDE ?= $(shell $(PYTHON_EXECUTABLE) -m pybind11 --includes)
|
PYBIND11_INCLUDE ?= $(shell $(TOX_ENV) $(PYTHON_EXECUTABLE) -m pybind11 --includes)
|
||||||
CXXFLAGS += -I$(PYBIND11_INCLUDE) -DYOSYS_ENABLE_PYTHON
|
CXXFLAGS += -I$(PYBIND11_INCLUDE) -DYOSYS_ENABLE_PYTHON
|
||||||
CXXFLAGS += $(shell $(PYTHON_CONFIG) --includes) -DYOSYS_ENABLE_PYTHON
|
CXXFLAGS += $(shell $(PYTHON_CONFIG) --includes) -DYOSYS_ENABLE_PYTHON
|
||||||
|
|
||||||
OBJS += $(PY_WRAPPER_FILE).o
|
OBJS += $(PY_WRAPPER_FILE).o
|
||||||
PY_GEN_SCRIPT = pyosys/generator.py
|
PY_GEN_SCRIPT = pyosys/generator.py
|
||||||
PY_WRAP_INCLUDES := $(shell $(PYTHON_EXECUTABLE) $(PY_GEN_SCRIPT) --print-includes)
|
PY_WRAP_INCLUDES := $(shell $(TOX_ENV) $(PYTHON_EXECUTABLE) $(PY_GEN_SCRIPT) --print-includes)
|
||||||
endif # ENABLE_PYOSYS
|
endif # ENABLE_PYOSYS
|
||||||
|
|
||||||
ifeq ($(ENABLE_READLINE),1)
|
ifeq ($(ENABLE_READLINE),1)
|
||||||
|
|
@ -777,7 +784,7 @@ endif
|
||||||
ifeq ($(ENABLE_PYOSYS),1)
|
ifeq ($(ENABLE_PYOSYS),1)
|
||||||
$(PY_WRAPPER_FILE).cc: $(PY_GEN_SCRIPT) pyosys/wrappers_tpl.cc $(PY_WRAP_INCLUDES) pyosys/hashlib.h
|
$(PY_WRAPPER_FILE).cc: $(PY_GEN_SCRIPT) pyosys/wrappers_tpl.cc $(PY_WRAP_INCLUDES) pyosys/hashlib.h
|
||||||
$(Q) mkdir -p $(dir $@)
|
$(Q) mkdir -p $(dir $@)
|
||||||
$(P) $(PYTHON_EXECUTABLE) $(PY_GEN_SCRIPT) $(PY_WRAPPER_FILE).cc
|
$(P) $(TOX_ENV) $(PYTHON_EXECUTABLE) $(PY_GEN_SCRIPT) $(PY_WRAPPER_FILE).cc
|
||||||
endif
|
endif
|
||||||
|
|
||||||
%.o: %.cpp
|
%.o: %.cpp
|
||||||
|
|
|
||||||
|
|
@ -85,8 +85,7 @@ prerequisites for building yosys:
|
||||||
|
|
||||||
$ sudo apt-get install build-essential clang lld bison flex libfl-dev \
|
$ sudo apt-get install build-essential clang lld bison flex libfl-dev \
|
||||||
libreadline-dev gawk tcl-dev libffi-dev git \
|
libreadline-dev gawk tcl-dev libffi-dev git \
|
||||||
graphviz xdot pkg-config python3 libboost-system-dev \
|
graphviz xdot pkg-config python3-dev tox zlib1g-dev
|
||||||
libboost-python-dev libboost-filesystem-dev zlib1g-dev
|
|
||||||
|
|
||||||
The environment variable `CXX` can be used to control the C++ compiler used, or
|
The environment variable `CXX` can be used to control the C++ compiler used, or
|
||||||
run one of the following to override it:
|
run one of the following to override it:
|
||||||
|
|
|
||||||
|
|
@ -99,8 +99,7 @@ Installing all prerequisites for Ubuntu 22.04:
|
||||||
|
|
||||||
sudo apt-get install gperf build-essential clang lld bison flex libfl-dev \
|
sudo apt-get install gperf build-essential clang lld bison flex libfl-dev \
|
||||||
libreadline-dev gawk tcl-dev libffi-dev git \
|
libreadline-dev gawk tcl-dev libffi-dev git \
|
||||||
graphviz xdot pkg-config python3 libboost-system-dev \
|
graphviz xdot pkg-config python3-dev tox zlib1g-dev
|
||||||
libboost-python-dev libboost-filesystem-dev zlib1g-dev
|
|
||||||
|
|
||||||
Installing all prerequisites for macOS 13 (with Homebrew):
|
Installing all prerequisites for macOS 13 (with Homebrew):
|
||||||
|
|
||||||
|
|
@ -141,7 +140,7 @@ For Cygwin use the following command to install all prerequisites, or select the
|
||||||
missing `strdup` function when using gcc. It is instead recommended to use
|
missing `strdup` function when using gcc. It is instead recommended to use
|
||||||
Windows Subsystem for Linux (WSL) and follow the instructions for Ubuntu.
|
Windows Subsystem for Linux (WSL) and follow the instructions for Ubuntu.
|
||||||
|
|
||||||
..
|
..
|
||||||
For MSYS2 (MINGW64):
|
For MSYS2 (MINGW64):
|
||||||
|
|
||||||
.. code:: console
|
.. code:: console
|
||||||
|
|
@ -215,7 +214,7 @@ Running the build system
|
||||||
From the root ``yosys`` directory, call the following commands:
|
From the root ``yosys`` directory, call the following commands:
|
||||||
|
|
||||||
.. code:: console
|
.. code:: console
|
||||||
|
|
||||||
make
|
make
|
||||||
sudo make install
|
sudo make install
|
||||||
|
|
||||||
|
|
@ -228,7 +227,7 @@ To use a separate (out-of-tree) build directory, provide a path to the Makefile.
|
||||||
|
|
||||||
Out-of-tree builds require a clean source tree.
|
Out-of-tree builds require a clean source tree.
|
||||||
|
|
||||||
.. seealso::
|
.. seealso::
|
||||||
|
|
||||||
Refer to :doc:`/yosys_internals/extending_yosys/test_suites` for details on
|
Refer to :doc:`/yosys_internals/extending_yosys/test_suites` for details on
|
||||||
testing Yosys once compiled.
|
testing Yosys once compiled.
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,14 @@ methods:
|
||||||
|
|
||||||
``yosys -y ./my_pyosys_script.py``
|
``yosys -y ./my_pyosys_script.py``
|
||||||
|
|
||||||
|
Do note this requires some build-time dependencies to be available to Python,
|
||||||
|
namely, ``pybind11`` and ``cxxheaderparser``. By default, the required
|
||||||
|
``tox`` package will be used to create an ephemeral environment with the
|
||||||
|
correct versions of the tools installed.
|
||||||
|
|
||||||
|
You can force use of your current Python environment by passing the Makefile
|
||||||
|
flag ``PYOSYS_USE_TOX=0``.
|
||||||
|
|
||||||
2. Installing the Pyosys wheels
|
2. Installing the Pyosys wheels
|
||||||
|
|
||||||
On macOS and GNU/Linux you can install pre-built wheels of Yosys using
|
On macOS and GNU/Linux you can install pre-built wheels of Yosys using
|
||||||
|
|
|
||||||
9
tox.ini
Normal file
9
tox.ini
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
[tox]
|
||||||
|
envlist = build
|
||||||
|
|
||||||
|
[testenv:build]
|
||||||
|
skip_install = true
|
||||||
|
deps =
|
||||||
|
pybind11>=3,<4
|
||||||
|
cxxheaderparser
|
||||||
|
commands = {posargs}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue