Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 75 additions & 75 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ jobs:
fail-fast: false
matrix:
include:
- name: "Ubuntu 22.04 Python 3.10"
os: ubuntu-22.04
build_type: Release
generators: Ninja
python-version: "3.10"

- name: "Ubuntu 22.04 Python 3.11"
os: ubuntu-22.04
build_type: Release
Expand All @@ -33,52 +27,51 @@ jobs:
python-version: "3.12"
upload-sdist: true

- name: "Ubuntu 20.04 with GCC 10 Python 3.8"
os: ubuntu-20.04
build_type: Release
generators: Ninja
wheel: manylinux_2_31_x86_64
python-version: "3.8"

- name: "Ubuntu 20.04 with GCC 10 Python 3.9"
os: ubuntu-20.04
- name: "Ubuntu 22.04 Python 3.13"
os: ubuntu-22.04
build_type: Release
generators: Ninja
wheel: manylinux_2_31_x86_64
python-version: "3.9"
wheel: manylinux_2_35_x86_64
python-version: "3.13"

- name: "Ubuntu 20.04 with GCC 10 Python 3.10"
os: ubuntu-20.04
- name: "Ubuntu 24.04 Python 3.13"
os: ubuntu-24.04
build_type: Release
generators: Ninja
wheel: manylinux_2_31_x86_64
python-version: "3.10"
python-version: "3.13"

- name: "Windows 2022 MSVC Python 3.10"
- name: "Windows 2022 MSVC Python 3.11"
os: windows-2022
triplet: x64-windows
build_type: Release
generators: "Visual Studio 17 2022"
wheel: win_amd64
python-version: "3.10"
python-version: "3.11"

- name: "Windows 2022 MSVC Python 3.11"
- name: "Windows 2022 MSVC Python 3.12"
os: windows-2022
triplet: x64-windows
build_type: Release
generators: "Visual Studio 17 2022"
wheel: win_amd64
python-version: "3.11"
python-version: "3.12"

- name: "Windows 2022 MSVC Python 3.12"
- name: "Windows 2022 MSVC Python 3.13"
os: windows-2022
triplet: x64-windows
build_type: Release
generators: "Visual Studio 17 2022"
wheel: win_amd64
python-version: "3.12"
python-version: "3.13"

- name: "macOS 15 x86_64 x86_64 Python 3.13"
- name: "Windows 2025 MSVC Python 3.13"
os: windows-2025
triplet: x64-windows
build_type: Release
generators: "Visual Studio 17 2022"
python-version: "3.13"

- name: "macOS 15 x86_64 Python 3.13"
os: macos-15-large
build_type: Release
generators: Ninja
Expand All @@ -92,6 +85,20 @@ jobs:
wheel: macosx_15_0_arm64
python-version: "3.13"

- name: "macOS 26 x86_64 Python 3.13"
os: macos-26-large
build_type: Release
generators: Ninja
wheel: macosx_26_0_x86_64
python-version: "3.13"

- name: "macOS 26 arm64 Python 3.13"
os: macos-26-xlarge
build_type: Release
generators: Ninja
wheel: macosx_26_0_arm64
python-version: "3.13"

steps:
- name: Unix line endings in git
if: startsWith(matrix.os, 'windows') || startsWith(matrix.os, 'macos')
Expand Down Expand Up @@ -170,13 +177,6 @@ jobs:
run: |
echo CXXFLAGS=" /wd4251 /wd4275" >> $GITHUB_ENV

- name: GCC 10 on Ubuntu 20.04
if: matrix.os == 'ubuntu-20.04'
shell: bash
run: |
echo CC=gcc-10 >> $GITHUB_ENV
echo CXX=g++-10 >> $GITHUB_ENV

- name: GCC 14 on Mac OS 15
if: startsWith(matrix.os, 'macos-13')
shell: bash
Expand All @@ -190,6 +190,12 @@ jobs:
run: |
echo MACOSX_DEPLOYMENT_TARGET=15.0 >> $GITHUB_ENV

- name: Mac OS 26 deployment target
if: startsWith(matrix.os, 'macos-26')
shell: bash
run: |
echo MACOSX_DEPLOYMENT_TARGET=26.0 >> $GITHUB_ENV

- name: Mac OS ARCHFLAGS x86_64
if: startsWith(matrix.os, 'macos') && endsWith(matrix.wheel, '_x86_64')
shell: bash
Expand Down Expand Up @@ -229,9 +235,12 @@ jobs:
if: startsWith(matrix.os, 'macos')
shell: bash
run: |
BREW_PREFIX="$(brew --prefix)"
echo ${{ github.workspace }}/../target/bin >> $GITHUB_PATH
echo "${BREW_PREFIX}/opt/tcl-tk/bin" >> $GITHUB_PATH
echo REPAIR_LIBRARY_PATH=${{ github.workspace }}/../target/lib >> $GITHUB_ENV
echo PKG_CONFIG_PATH=${{ github.workspace }}/../target/lib/pkgconfig >> $GITHUB_ENV
echo EXTRA_OSX_LIBYANG=-DPATH_EXPECT= >> $GITHUB_ENV

# FIXME: CMake 4.0 is backwards-incompatible, https://github.com/actions/runner-images/issues/11926
- name: pin CMake to the latest 3.x series
Expand Down Expand Up @@ -260,11 +269,11 @@ jobs:
# Windows: pybind11 by vcpkg won't work for any other version of Python by design, https://github.com/microsoft/vcpkg/issues/23796
- name: Install pybind11 (Unix)
if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos')
run: sudo pip install pybind11[global]
run: sudo pip install 'pybind11[global]>=2.9.1,<3'

- name: Install pybind11 (Windows)
if: startsWith(matrix.os, 'windows')
run: pip install pybind11[global]
run: pip install 'pybind11[global]>=2.9.1,<3'

- name: configure libyang
shell: bash
Expand Down Expand Up @@ -382,15 +391,6 @@ jobs:
export CMAKE_ARGS="${EXTRA_VCPKG_TARGET_TRIPLET:+${EXTRA_VCPKG_TARGET_TRIPLET} }${EXTRA_CMAKE_TOOLCHAIN_FILE:+${EXTRA_CMAKE_TOOLCHAIN_FILE} }${EXTRA_PKG_CONFIG_EXECUTABLE:+${EXTRA_PKG_CONFIG_EXECUTABLE}}"
python3 -m build --skip-dependency-check --outdir '${{ github.workspace }}'/build-wheel '${{ github.workspace }}/'

- name: fix the wheel, Ubuntu 20.x
if: startsWith(matrix.os, 'ubuntu-20') && (matrix.wheel != '')
shell: bash
run: |
# we're on old Ubuntu to use an old manylinux tag, and newer auditwheel requires too fresh patchelf
pip install 'auditwheel<5.2.0'
find '${{ github.workspace }}'/build-wheel -name '*.whl'
auditwheel repair --plat '${{ matrix.wheel }}' '${{ github.workspace }}'/build-wheel/*.whl

- name: fix the wheel, Ubuntu 22.x
if: startsWith(matrix.os, 'ubuntu-22') && (matrix.wheel != '')
shell: bash
Expand Down Expand Up @@ -442,11 +442,6 @@ jobs:
fail-fast: false
matrix:
include:
- name: "Ubuntu 22.04 Python 3.10"
os: ubuntu-22.04
python-version: "3.10"
wheel: manylinux_2_31_x86_64

- name: "Ubuntu 22.04 Python 3.11"
os: ubuntu-22.04
python-version: "3.11"
Expand All @@ -457,30 +452,15 @@ jobs:
python-version: "3.12"
wheel: manylinux_2_35_x86_64

- name: "Ubuntu 20.04 with GCC 10 Python 3.8"
os: ubuntu-20.04
wheel: manylinux_2_31_x86_64
python-version: "3.8"

- name: "Ubuntu 20.04 with GCC 10 Python 3.9"
os: ubuntu-20.04
wheel: manylinux_2_31_x86_64
python-version: "3.9"

- name: "Ubuntu 20.04 with GCC 10 Python 3.10"
os: ubuntu-20.04
wheel: manylinux_2_31_x86_64
python-version: "3.10"

- name: "Windows 2019 MSVC Python 3.10"
os: windows-2019
wheel: win_amd64
python-version: "3.10"
- name: "Ubuntu 22.04 Python 3.13"
os: ubuntu-22.04
python-version: "3.13"
wheel: manylinux_2_35_x86_64

- name: "Windows 2022 MSVC Python 3.10"
os: windows-2022
wheel: win_amd64
python-version: "3.10"
- name: "Ubuntu 24.04 Python 3.13"
os: ubuntu-24.04
python-version: "3.13"
wheel: manylinux_2_35_x86_64

- name: "Windows 2022 MSVC Python 3.11"
os: windows-2022
Expand All @@ -492,16 +472,36 @@ jobs:
wheel: win_amd64
python-version: "3.12"

- name: "Windows 2022 MSVC Python 3.13"
os: windows-2022
wheel: win_amd64
python-version: "3.13"

- name: "Windows 2025 MSVC Python 3.13"
os: windows-2025
wheel: win_amd64
python-version: "3.13"

- name: "macOS 15 x86_64 Python 3.13"
os: macos-15-large
wheel: macosx_15_0_x86_64
python-version: "3.13"

- name: "macOS 13 arm64 Python 3.13"
- name: "macOS 15 arm64 Python 3.13"
os: macos-15-xlarge
wheel: macosx_15_0_arm64
python-version: "3.13"

- name: "macOS 26 x86_64 Python 3.13"
os: macos-26-large
wheel: macosx_26_0_x86_64
python-version: "3.13"

- name: "macOS 26 arm64 Python 3.13"
os: macos-26-xlarge
wheel: macosx_26_0_arm64
python-version: "3.13"

steps:
- uses: actions/checkout@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "libyang"]
path = libyang
url = ../../jktjkt/libyang
url = ../../CESNET/libyang
[submodule "libyang-cpp"]
path = libyang-cpp
url = ../../CESNET/libyang-cpp
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ We also produce prebuilt binary [wheels](https://realpython.com/python-wheels/)
```python
import oopt_gnpy_libyang as ly

c = ly.Context('tests/yang', ly.ContextOptions.AllImplemented | ly.ContextOptions.NoYangLibrary)
c = ly.Context('tests/yang', ly.ContextOptions.RefImplemented | ly.ContextOptions.NoYangLibrary)
for m in ('iana-if-type', 'ietf-interfaces', 'ietf-ip'):
c.load_module(m)
blob = '''{
Expand Down
2 changes: 1 addition & 1 deletion libyang
Submodule libyang updated 243 files
21 changes: 18 additions & 3 deletions oopt-gnpy-libyang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ PYBIND11_MODULE(oopt_gnpy_libyang, m) {
.value("PreferSearchDirs", ContextOptions::PreferSearchDirs)
.value("SetPrivParsed", ContextOptions::SetPrivParsed)
.value("ExplicitCompile", ContextOptions::ExplicitCompile)
.value("EnableImpFeatures", ContextOptions::EnableImpFeatures)
.value("CompileObsolete", ContextOptions::CompileObsolete)
.value("LybHashes", ContextOptions::LybHashes)
.value("LeafrefExtended", ContextOptions::LeafrefExtended)
.value("LeafrefLinking", ContextOptions::LeafrefLinking)
.value("BuiltinPluginsOnly", ContextOptions::BuiltinPluginsOnly)
.value("StaticPluginsOnly", ContextOptions::StaticPluginsOnly)
.def("__or__", [](ContextOptions a, ContextOptions b){ return a | b; })
;

Expand Down Expand Up @@ -104,11 +111,15 @@ PYBIND11_MODULE(oopt_gnpy_libyang, m) {
.value("Strict", ParseOptions::Strict)
.value("Opaque", ParseOptions::Opaque)
.value("NoState", ParseOptions::NoState)
.value("LybModUpdate", ParseOptions::LybModUpdate)
.value("LybSkipModuleCheck", ParseOptions::LybSkipModuleCheck)
.value("LybModUpdate", ParseOptions::LybSkipModuleCheck)
.value("Ordered", ParseOptions::Ordered)
.value("Subtree", ParseOptions::Subtree)
.value("WhenTrue", ParseOptions::WhenTrue)
.value("NoNew", ParseOptions::NoNew)
.value("StoreOnly", ParseOptions::StoreOnly)
.value("JsonNull", ParseOptions::JsonNull)
.value("JsonStringDataTypes", ParseOptions::JsonStringDataTypes)
.def("__or__", [](ParseOptions a, ParseOptions b){ return a | b; })
;

Expand All @@ -118,19 +129,23 @@ PYBIND11_MODULE(oopt_gnpy_libyang, m) {
.value("MultiError", ValidationOptions::MultiError)
.value("Operational", ValidationOptions::Operational)
.value("NoDefaults", ValidationOptions::NoDefaults)
.value("NotFinal", ValidationOptions::NotFinal)
.def("__or__", [](ValidationOptions a, ValidationOptions b){ return a | b; })
;

py::enum_<PrintFlags>(m, "PrintFlags")
.value("WithDefaultsExplicit", PrintFlags::WithDefaultsExplicit)
.value("WithSiblings", PrintFlags::WithSiblings)
.value("Siblings", PrintFlags::Siblings)
.value("WithSiblings", PrintFlags::Siblings)
.value("Shrink", PrintFlags::Shrink)
.value("KeepEmptyCont", PrintFlags::KeepEmptyCont)
.value("EmptyContainers", PrintFlags::EmptyContainers)
.value("KeepEmptyCont", PrintFlags::EmptyContainers)
.value("WithDefaultsTrim", PrintFlags::WithDefaultsTrim)
.value("WithDefaultsAll", PrintFlags::WithDefaultsAll)
.value("WithDefaultsAllTag", PrintFlags::WithDefaultsAllTag)
.value("WithDefaultsImplicitTag", PrintFlags::WithDefaultsImplicitTag)
.value("WithDefaultsMask", PrintFlags::WithDefaultsMask)
.value("JsonNoNestedPrefix", PrintFlags::JsonNoNestedPrefix)
.def("__or__", [](PrintFlags a, PrintFlags b){ return a | b; })
;

Expand Down
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

@pytest.fixture(scope='function')
def context_no_libyang():
# libyang 4.7.x is stable here with RefImplemented; AllImplemented crashes during manual module loading.
return ly.Context(str(Path(os.environ.get('CMAKE_CURRENT_SOURCE_DIR', os.getcwd())) / 'tests' / 'yang'),
ly.ContextOptions.AllImplemented | ly.ContextOptions.NoYangLibrary)
ly.ContextOptions.RefImplemented | ly.ContextOptions.NoYangLibrary)

@pytest.fixture(scope='function')
def context_with_modules(context_no_libyang):
Expand Down
16 changes: 14 additions & 2 deletions tests/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,17 @@ def test_explicit_loading(context_no_libyang):

def test_version():
assert len(ly.libyang_version_info()) == 3
assert ly.libyang_version_info()[0] == 3
assert ly.libyang_version()[0:2] == '3.'
major, minor, micro = ly.libyang_version_info()
assert ly.libyang_version() == f"{major}.{minor}.{micro}"


def test_enum_api_compatibility():
assert ly.ParseOptions.LybSkipModuleCheck == ly.ParseOptions.LybModUpdate
assert ly.PrintFlags.Siblings == ly.PrintFlags.WithSiblings
assert ly.PrintFlags.EmptyContainers == ly.PrintFlags.KeepEmptyCont

assert hasattr(ly.ParseOptions, "StoreOnly")
assert hasattr(ly.ParseOptions, "JsonNull")
assert hasattr(ly.ParseOptions, "JsonStringDataTypes")
assert hasattr(ly.PrintFlags, "JsonNoNestedPrefix")
assert hasattr(ly.ValidationOptions, "NotFinal")
Loading