Skip to content

Commit

Permalink
Merge branch 'spinler-feat-cocotb_pyproject' into 'devel'
Browse files Browse the repository at this point in the history
Spinler feat cocotb pyproject

See merge request ndk/ndk-fpga!96
  • Loading branch information
jakubcabal committed Nov 12, 2024
2 parents f898655 + 0d90891 commit c375c13
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 67 deletions.
27 changes: 5 additions & 22 deletions apps/minimal/tests/cocotb/prepare.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
#!/bin/sh

OFM_PATH=../../../../
NDK_FPGA_PATH=../../../..
source $NDK_FPGA_PATH/env.sh

#swbase=../../../swbase/
swbase=git+https://github.com/CESNET/ndk-sw.git#subdirectory=
ndk_fpga_venv_prepare "venv-cocotb"

PKG_PYNFB=${swbase}pynfb/
PKG_LIBNFBEXT_PYTHON=${swbase}ext/libnfb_ext_python/
PKG_COCOTBEXT_OFM=$OFM_PATH/python/cocotbext/

# Python virtual environment
python -m venv venv-cocotb
source venv-cocotb/bin/activate

python -m pip install cython wheel setuptools
python -m pip install pylibfdt fdt
python -m pip install scapy
python -m pip wheel -w ./cocotbwheels $PKG_PYNFB
python -m pip install --find-links ./cocotbwheels nfb
python -m pip install --find-links ./cocotbwheels $PKG_LIBNFBEXT_PYTHON
python -m pip install $PKG_COCOTBEXT_OFM

echo ""
echo "Now activate environment with:"
echo "source venv-cocotb/bin/activate"
pip install .
#pip install "cocotbext-ofm[nfb]@$NDK_FPGA_COCOTBEXT_OFM_URL"
10 changes: 10 additions & 0 deletions apps/minimal/tests/cocotb/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[project]
name = "cocotb-ndk-minimal-test-toplevel"
version = "0.1.0"
dependencies = [
"cocotbext-ofm[nfb] @ ${NDK_FPGA_COCOTBEXT_OFM_URL}",
]

[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"
17 changes: 3 additions & 14 deletions apps/minimal/tests/cocotb/top-level-sim.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,20 @@ def CARDS = ["alveo-u200", "alveo-u55c", "vcu118", "ia-420f", "n6010", "fb2cghh"

node("preklad") {
cleanWs()
def swbase = "ndk-sw"
checkout scm

stage("Clone required repository") {
sh "git clone https://github.com/CESNET/ndk-sw.git"
}

if (params.nightly != null && params.nightly == true) {
stage("Prepare for nightly build") {
sh "(cd extra/nfb-200g2ql; git checkout main)"
sh "(cd extra/dma-medusa; git checkout main)"
}
}

sh "python3.9 -m venv venv-cocotb"

stage("Prepare environment") {
sh """
source venv-cocotb/bin/activate
python3.9 -m pip install cython wheel
python3.9 -m pip install pylibfdt fdt
python3.9 -m pip wheel -w ./cocotbwheels ${swbase}/pynfb/
python3.9 -m pip install --find-links ./cocotbwheels nfb
python3.9 -m pip install --find-links ./cocotbwheels ${swbase}/ext/libnfb_ext_python/
python3.9 -m pip install python/cocotbext/
source ./env.sh
ndk_fpga_venv_prepare "venv-cocotb"
pip install apps/minimal/tests/cocotb
"""
}

Expand Down
12 changes: 12 additions & 0 deletions build/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Common functions
function ndk_fpga_venv_prepare {
if [ -z "$1" ]; then
VENV_NAME="venv-cocotb"
else
VENV_NAME="$1"
fi

echo "Creating virtual environment '$VENV_NAME'"
python -m venv $VENV_NAME
source $VENV_NAME/bin/activate
}
28 changes: 0 additions & 28 deletions core/cocotb/prepare.sh

This file was deleted.

2 changes: 0 additions & 2 deletions core/cocotb/requirements.txt

This file was deleted.

22 changes: 22 additions & 0 deletions env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh
if [ -z "${NDK_FPGA_PATH}" ]; then
NDK_FPGA_PATH=$(dirname "${BASH_SOURCE[0]}")
fi

source $NDK_FPGA_PATH/build/common.sh


# REALPATHs are necessary for local Python packages based on PDM
NDK_FPGA_REALPATH=$(realpath $NDK_FPGA_PATH)

# ####################################################################
# Default package paths

# OFM extension for cocotb
export NDK_FPGA_COCOTBEXT_OFM_URL="file://${NDK_FPGA_REALPATH}/python/cocotbext/"

# NDK software Python packages are dependencies of cocotbext-ofm[nfb]
export NDK_SW_PYTHON_URL="git+https://github.com/CESNET/ndk-sw.git#subdirectory="
# NDK software alternative path for local ndk-sw repository
#NDK_SW_REALPATH=$(realpath $NDK_FPGA_PATH/../swbase)
#NDK_SW_PYTHON_URL="file:///$(realpath $NDK_SW_PATH)/"
23 changes: 23 additions & 0 deletions python/cocotbext/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[project]
name = "cocotbext-ofm"
version = "0.1.0"
dependencies = [
"cocotb",
"cocotb-bus",
]

[project.optional-dependencies]
nfb = [
"pylibfdt",
"nfb @ ${NDK_SW_PYTHON_URL}pynfb",
"libnfb-ext-python @ ${NDK_SW_PYTHON_URL}ext/libnfb_ext_python",
]

[build-system]
requires = [
"pdm-backend",
]
build-backend = "pdm.backend"

[tool.pdm.build]
includes = ["cocotbext"]
2 changes: 1 addition & 1 deletion python/cocotbext/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

keywords=['python'],
packages=find_namespace_packages(include=["cocotbext.*"]),
install_requires=["cocotb", "cocotb-bus"],
install_requires=["cocotb", "cocotb-bus", "pylibfdt"],
python_requires=">=3.5",
classifiers=[
"Programming Language :: Python :: 3",
Expand Down

0 comments on commit c375c13

Please sign in to comment.