dioptic.profileparser 0.3.1__tar.gz → 0.3.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. {dioptic_profileparser-0.3.1 → dioptic_profileparser-0.3.3}/.github/workflows/pypi-packages.yml +32 -12
  2. dioptic_profileparser-0.3.3/.github/workflows/quality.yml +27 -0
  3. {dioptic_profileparser-0.3.1 → dioptic_profileparser-0.3.3}/.github/workflows/web-package.yml +4 -4
  4. dioptic_profileparser-0.3.3/.gitignore +6 -0
  5. dioptic_profileparser-0.3.3/.python-version +1 -0
  6. dioptic_profileparser-0.3.3/PKG-INFO +54 -0
  7. dioptic_profileparser-0.3.3/README.md +44 -0
  8. {dioptic_profileparser-0.3.1 → dioptic_profileparser-0.3.3}/cpp/CMakeLists.txt +15 -1
  9. {dioptic_profileparser-0.3.1 → dioptic_profileparser-0.3.3}/cpp/printers.cpp +12 -3
  10. dioptic_profileparser-0.3.3/pyproject.toml +56 -0
  11. dioptic_profileparser-0.3.3/python/CMakeLists.txt +60 -0
  12. dioptic_profileparser-0.3.3/python/CMakePresets.json +27 -0
  13. dioptic_profileparser-0.3.3/python/__init__.py +2 -0
  14. {dioptic_profileparser-0.3.1 → dioptic_profileparser-0.3.3}/python/pyprofileparser.cpp +8 -5
  15. dioptic_profileparser-0.3.3/tests/test_profileparser.py +39 -0
  16. dioptic_profileparser-0.3.3/uv.lock +170 -0
  17. dioptic_profileparser-0.3.3/web/README.md +32 -0
  18. dioptic_profileparser-0.3.1/.gitignore +0 -3
  19. dioptic_profileparser-0.3.1/PKG-INFO +0 -11
  20. dioptic_profileparser-0.3.1/README.md +0 -1
  21. dioptic_profileparser-0.3.1/cpp/peglib.h +0 -4839
  22. dioptic_profileparser-0.3.1/pyproject.toml +0 -24
  23. dioptic_profileparser-0.3.1/python/CMakeLists.txt +0 -58
  24. dioptic_profileparser-0.3.1/python/__init__.py +0 -2
  25. dioptic_profileparser-0.3.1/web/README.md +0 -11
  26. {dioptic_profileparser-0.3.1 → dioptic_profileparser-0.3.3}/LICENSE +0 -0
  27. {dioptic_profileparser-0.3.1 → dioptic_profileparser-0.3.3}/cpp/include/profileparser/types.hpp +0 -0
  28. {dioptic_profileparser-0.3.1 → dioptic_profileparser-0.3.3}/cpp/include/profileparser/utils.hpp +0 -0
  29. {dioptic_profileparser-0.3.1 → dioptic_profileparser-0.3.3}/cpp/include/profileparser.hpp +0 -0
  30. {dioptic_profileparser-0.3.1 → dioptic_profileparser-0.3.3}/cpp/lineinfo.cpp +0 -0
  31. {dioptic_profileparser-0.3.1 → dioptic_profileparser-0.3.3}/cpp/parser.cpp +0 -0
  32. {dioptic_profileparser-0.3.1 → dioptic_profileparser-0.3.3}/cpp/parser.hpp +0 -0
  33. {dioptic_profileparser-0.3.1 → dioptic_profileparser-0.3.3}/cpp/validation.cpp +0 -0
  34. {dioptic_profileparser-0.3.1 → dioptic_profileparser-0.3.3}/web/CMakeLists.txt +0 -0
  35. {dioptic_profileparser-0.3.1 → dioptic_profileparser-0.3.3}/web/binding_api.hpp +0 -0
  36. {dioptic_profileparser-0.3.1 → dioptic_profileparser-0.3.3}/web/binding_ast.hpp +0 -0
  37. {dioptic_profileparser-0.3.1 → dioptic_profileparser-0.3.3}/web/binding_helpers.hpp +0 -0
  38. {dioptic_profileparser-0.3.1 → dioptic_profileparser-0.3.3}/web/profile_parser_js.cpp +0 -0
@@ -11,12 +11,15 @@ jobs:
11
11
  build-sdist:
12
12
  runs-on: ubuntu-latest
13
13
  steps:
14
- - uses: actions/checkout@v4
14
+ - uses: actions/checkout@v7
15
+ - uses: actions/setup-python@v7
16
+ with:
17
+ python-version: "3.12"
15
18
  - name: Build sdist package
16
19
  run: |
17
- python -m pip install pip build --upgrade
20
+ python -m pip install --upgrade pip build
18
21
  python -m build --sdist
19
- - uses: actions/upload-artifact@v4
22
+ - uses: actions/upload-artifact@v7
20
23
  with:
21
24
  name: packages-src
22
25
  path: "dist/*.tar.gz"
@@ -25,31 +28,44 @@ jobs:
25
28
  runs-on: windows-latest
26
29
  strategy:
27
30
  matrix:
28
- python-version: ["3.9", "3.10", "3.11", "3.12"]
31
+ python-version: ["3.12"]
29
32
  steps:
30
- - uses: actions/checkout@v4
31
- - uses: ilammy/msvc-dev-cmd@v1
32
- - uses: actions/setup-python@v5
33
+ - uses: actions/checkout@v7
34
+ - uses: step-security/msvc-dev-cmd@v1
35
+ - uses: actions/setup-python@v7
33
36
  with:
34
37
  python-version: ${{ matrix.python-version }}
35
- - name: Build wheel for py${{ matrix.python-version }}
38
+ - name: Build wheel for python ${{ matrix.python-version }}
36
39
  run: |
37
- python -m pip install pip build --upgrade
40
+ python -m pip install --upgrade pip build ninja
38
41
  python -m build --wheel
39
- - uses: actions/upload-artifact@v4
42
+ env:
43
+ CMAKE_GENERATOR: Ninja
44
+ - uses: actions/upload-artifact@v7
40
45
  with:
41
46
  name: packages-win-py${{ matrix.python-version }}
42
47
  path: "dist/*.whl"
43
48
 
49
+ build-linux-wheels:
50
+ runs-on: ubuntu-latest
51
+ steps:
52
+ - uses: actions/checkout@v7
53
+ - name: Build Linux wheels
54
+ uses: pypa/cibuildwheel@v4.1.1
55
+ - uses: actions/upload-artifact@v7
56
+ with:
57
+ name: packages-linux-${{ strategy.job-index }}
58
+ path: ./wheelhouse/*.whl
59
+
44
60
  pypi-publish:
45
61
  if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
46
- needs: [build-sdist, build-win64-wheels]
62
+ needs: [build-sdist, build-win64-wheels, build-linux-wheels]
47
63
  runs-on: ubuntu-latest
48
64
  permissions:
49
65
  # IMPORTANT: this permission is mandatory for trusted publishing
50
66
  id-token: write
51
67
  steps:
52
- - uses: actions/download-artifact@v4
68
+ - uses: actions/download-artifact@v6
53
69
  with:
54
70
  path: dist
55
71
  pattern: packages-*
@@ -58,6 +74,10 @@ jobs:
58
74
  uses: pypa/gh-action-pypi-publish@release/v1
59
75
  with:
60
76
  repository-url: https://test.pypi.org/legacy/
77
+ packages-dir: dist
78
+ attestations: false
61
79
  skip-existing: true
62
80
  - name: PyPI publish
63
81
  uses: pypa/gh-action-pypi-publish@release/v1
82
+ with:
83
+ packages-dir: dist
@@ -0,0 +1,27 @@
1
+ name: Quality checks
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+
9
+ jobs:
10
+ lint-and-test:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v7
14
+ - uses: actions/setup-python@v7
15
+ with:
16
+ python-version: "3.12"
17
+ - name: Install Ninja
18
+ run: |
19
+ sudo apt-get update
20
+ sudo apt-get install --yes ninja-build
21
+ - uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
22
+ - name: Sync dependencies
23
+ run: uv sync
24
+ - name: Lint
25
+ run: uv run ruff check .
26
+ - name: Test
27
+ run: uv run pytest
@@ -11,10 +11,10 @@ jobs:
11
11
  build-web:
12
12
  runs-on: ubuntu-latest
13
13
  steps:
14
- - uses: actions/checkout@v4
15
- - uses: mymindstorm/setup-emsdk@v14
14
+ - uses: actions/checkout@v7
15
+ - uses: emscripten-core/setup-emsdk@v16
16
16
  with:
17
- version: 3.1.57
17
+ version: 6.0.3
18
18
  actions-cache-folder: 'emsdk-cache'
19
19
  - name: Build WASM port
20
20
  run: |
@@ -22,7 +22,7 @@ jobs:
22
22
  mkdir build && cd build
23
23
  emcmake cmake -DCMAKE_BUILD_TYPE="Release" ..
24
24
  cmake --build .
25
- - uses: actions/upload-artifact@v4
25
+ - uses: actions/upload-artifact@v7
26
26
  with:
27
27
  name: web
28
28
  path: "web/build/ProfileParserJs.*"
@@ -0,0 +1,6 @@
1
+ __pycache__
2
+ .venv
3
+ .vscode
4
+ *.user
5
+ build
6
+ dist
@@ -0,0 +1 @@
1
+ 3.12
@@ -0,0 +1,54 @@
1
+ Metadata-Version: 2.2
2
+ Name: dioptic.profileparser
3
+ Version: 0.3.3
4
+ Summary: Parser library for ARGOS declarative profiles
5
+ Author-Email: Peter Würtz <pwuertz@gmail.com>
6
+ Classifier: License :: OSI Approved :: MIT License
7
+ Project-URL: Homepage, https://github.com/dioptic/profileparser
8
+ Requires-Python: >=3.12
9
+ Description-Content-Type: text/markdown
10
+
11
+ # Dioptic declarative profile parser
12
+
13
+ Python parser library for ARGOS declarative profiles.
14
+
15
+ ## Build prerequisites
16
+
17
+ - Python `3.12+`
18
+ - CMake `>=3.24`
19
+ - Ninja
20
+ - C++20 compiler
21
+
22
+ ## Build with dependencies from lockfile
23
+
24
+ ```shell
25
+ uv sync --no-install-project
26
+ uv build --wheel --no-build-isolation
27
+ ```
28
+
29
+ ## Develop with auto rebuild
30
+
31
+ ```shell
32
+ uv sync
33
+ uv run ruff check .
34
+ uv run pytest
35
+ ```
36
+
37
+ ## Usage
38
+
39
+ ```python
40
+ import dioptic.profileparser as profileparser
41
+
42
+ profile = profileparser.parse("""
43
+ Profile {
44
+ description: "Example profile"
45
+ application: MyApp {
46
+ hello: "world"
47
+ }
48
+ }
49
+ """
50
+ )
51
+
52
+ profileparser.validate(profile)
53
+ print(profile.to_json_ast())
54
+ ```
@@ -0,0 +1,44 @@
1
+ # Dioptic declarative profile parser
2
+
3
+ Python parser library for ARGOS declarative profiles.
4
+
5
+ ## Build prerequisites
6
+
7
+ - Python `3.12+`
8
+ - CMake `>=3.24`
9
+ - Ninja
10
+ - C++20 compiler
11
+
12
+ ## Build with dependencies from lockfile
13
+
14
+ ```shell
15
+ uv sync --no-install-project
16
+ uv build --wheel --no-build-isolation
17
+ ```
18
+
19
+ ## Develop with auto rebuild
20
+
21
+ ```shell
22
+ uv sync
23
+ uv run ruff check .
24
+ uv run pytest
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ ```python
30
+ import dioptic.profileparser as profileparser
31
+
32
+ profile = profileparser.parse("""
33
+ Profile {
34
+ description: "Example profile"
35
+ application: MyApp {
36
+ hello: "world"
37
+ }
38
+ }
39
+ """
40
+ )
41
+
42
+ profileparser.validate(profile)
43
+ print(profile.to_json_ast())
44
+ ```
@@ -1,12 +1,27 @@
1
1
  cmake_minimum_required(VERSION 3.16)
2
2
  project(libProfileParser CXX)
3
3
 
4
+ include(FetchContent)
5
+ FetchContent_Declare(
6
+ peglib
7
+ GIT_REPOSITORY https://github.com/yhirose/cpp-peglib
8
+ GIT_TAG 4b3bd64
9
+ GIT_SHALLOW TRUE
10
+ )
11
+ FetchContent_GetProperties(peglib)
12
+ if(NOT peglib_POPULATED)
13
+ FetchContent_Populate(peglib)
14
+ endif()
15
+
4
16
  add_library(libProfileParser STATIC)
5
17
  add_library(libProfileParser::libProfileParser ALIAS libProfileParser)
6
18
 
7
19
  target_include_directories(libProfileParser PUBLIC
8
20
  "${CMAKE_CURRENT_LIST_DIR}/include"
9
21
  )
22
+ target_include_directories(libProfileParser PRIVATE
23
+ "${peglib_SOURCE_DIR}"
24
+ )
10
25
 
11
26
  set_target_properties(libProfileParser PROPERTIES
12
27
  CXX_STANDARD 20
@@ -29,5 +44,4 @@ target_sources(libProfileParser PRIVATE
29
44
  "parser.hpp"
30
45
  "printers.cpp"
31
46
  "validation.cpp"
32
- "peglib.h" # Use FetchContent?
33
47
  )
@@ -77,10 +77,18 @@ struct Printer
77
77
  return self();
78
78
  }
79
79
 
80
+ PrinterImpl& operator<<(const String& v)
81
+ {
82
+ o << '"' << v << '"';
83
+ return self();
84
+ }
85
+
80
86
  PrinterImpl& operator<<(const DocString& v)
81
87
  {
82
- for(auto& line : v.lines)
83
- self() << "# " << line << '\n' << indent;
88
+ for (auto& line : v.lines) {
89
+ o << "# " << line;
90
+ self() << '\n' << indent;
91
+ }
84
92
  return self();
85
93
  }
86
94
 
@@ -143,7 +151,8 @@ struct Printer
143
151
  const std::string start = v.classname + ((v.id.empty()) ? "" : ' ' + v.id) + " {";
144
152
  Collection obj(&self(), start, ""sv, "}"sv);
145
153
 
146
- obj << v.docstring;
154
+ if(v.docstring.lines.size())
155
+ obj << v.docstring;
147
156
 
148
157
  for (const auto& item: v.children) {
149
158
  obj << item;
@@ -0,0 +1,56 @@
1
+ [build-system]
2
+ requires = ["scikit-build-core>=0.11", "nanobind"]
3
+ build-backend = "scikit_build_core.build"
4
+
5
+ [project]
6
+ name = "dioptic.profileparser"
7
+ version = "0.3.3"
8
+ description = "Parser library for ARGOS declarative profiles"
9
+ readme = "README.md"
10
+ requires-python = ">=3.12"
11
+ authors = [
12
+ { name = "Peter Würtz", email = "pwuertz@gmail.com" },
13
+ ]
14
+ classifiers = [
15
+ "License :: OSI Approved :: MIT License",
16
+ ]
17
+
18
+ [project.urls]
19
+ Homepage = "https://github.com/dioptic/profileparser"
20
+
21
+ [tool.scikit-build]
22
+ cmake.source-dir = "./python"
23
+ cmake.version = "CMakeLists.txt"
24
+ cmake.args = ["--preset", "default"]
25
+ build-dir = "build/{wheel_tag}"
26
+ wheel.py-api = "cp312"
27
+ editable.rebuild = true
28
+
29
+ [tool.uv]
30
+ no-build-isolation-package = ["dioptic.profileparser"]
31
+
32
+ [dependency-groups]
33
+ dev = [
34
+ "nanobind",
35
+ "pytest",
36
+ "ruff",
37
+ "scikit-build-core>=0.11",
38
+ "ty",
39
+ ]
40
+
41
+ [tool.pytest.ini_options]
42
+ testpaths = ["tests"]
43
+
44
+ [tool.ruff]
45
+ line-length = 120
46
+
47
+ [tool.cibuildwheel]
48
+ build = "cp312-manylinux_x86_64"
49
+ archs = ["x86_64"]
50
+ build-frontend = "build"
51
+ test-requires = ["pytest"]
52
+ test-command = "pytest {project}/tests"
53
+
54
+ [tool.cibuildwheel.linux]
55
+ manylinux-x86_64-image = "manylinux_2_34"
56
+ environment = { CMAKE_GENERATOR = "Ninja" }
@@ -0,0 +1,60 @@
1
+ cmake_minimum_required(VERSION 3.24)
2
+
3
+ if(NOT SKBUILD)
4
+ message(FATAL_ERROR "Build should be driven by scikit-build-core")
5
+ endif()
6
+ set(MODULE_NAME "_profileparser")
7
+ set(MODULE_VERSION ${SKBUILD_PROJECT_VERSION})
8
+ project(${MODULE_NAME} VERSION ${MODULE_VERSION} LANGUAGES CXX)
9
+
10
+ find_package(
11
+ Python 3.12 REQUIRED
12
+ COMPONENTS Interpreter Development.Module
13
+ OPTIONAL_COMPONENTS Development.SABIModule
14
+ )
15
+ find_package(nanobind CONFIG REQUIRED)
16
+
17
+ # Create python extension module with nanobind
18
+ nanobind_add_module(${MODULE_NAME}
19
+ STABLE_ABI
20
+ NB_STATIC
21
+ "pyprofileparser.cpp"
22
+ )
23
+
24
+ set_target_properties(${MODULE_NAME} PROPERTIES
25
+ CXX_STANDARD 20
26
+ CXX_STANDARD_REQUIRED ON
27
+ )
28
+ target_compile_definitions(${MODULE_NAME} PRIVATE MODULE_NAME=${MODULE_NAME})
29
+ target_compile_definitions(${MODULE_NAME} PRIVATE MODULE_VERSION=${MODULE_VERSION})
30
+
31
+ add_subdirectory("../cpp" "${CMAKE_CURRENT_BINARY_DIR}/cpp")
32
+ target_link_libraries(${MODULE_NAME} PUBLIC
33
+ libProfileParser::libProfileParser
34
+ )
35
+
36
+ nanobind_add_stub(
37
+ ${MODULE_NAME}_stub
38
+ MODULE ${MODULE_NAME}
39
+ OUTPUT ${MODULE_NAME}.pyi
40
+ PYTHON_PATH $<TARGET_FILE_DIR:${MODULE_NAME}>
41
+ DEPENDS ${MODULE_NAME}
42
+ MARKER_FILE py.typed
43
+ )
44
+
45
+ install(TARGETS ${MODULE_NAME}
46
+ DESTINATION "dioptic/profileparser"
47
+ )
48
+ install(FILES
49
+ ${CMAKE_CURRENT_SOURCE_DIR}/__init__.py
50
+ ${${PROJECT_NAME}_BINARY_DIR}/py.typed
51
+ ${${PROJECT_NAME}_BINARY_DIR}/${MODULE_NAME}.pyi
52
+ DESTINATION "dioptic/profileparser"
53
+ )
54
+
55
+ # Compiler options
56
+ if(MSVC)
57
+ target_compile_options(${MODULE_NAME} PUBLIC /W3 /permissive- /Zc:__cplusplus)
58
+ else()
59
+ target_compile_options(${MODULE_NAME} PRIVATE -Wall -Wextra)
60
+ endif()
@@ -0,0 +1,27 @@
1
+ {
2
+ "version": 3,
3
+ "cmakeMinimumRequired": {
4
+ "major": 3,
5
+ "minor": 24,
6
+ "patch": 0
7
+ },
8
+ "configurePresets": [
9
+ {
10
+ "name": "default",
11
+ "displayName": "Default",
12
+ "description": "Configure with Release build type and LTO enabled",
13
+ "generator": "Ninja",
14
+ "binaryDir": "../build",
15
+ "cacheVariables": {
16
+ "CMAKE_BUILD_TYPE": "Release",
17
+ "CMAKE_INTERPROCEDURAL_OPTIMIZATION": "ON"
18
+ }
19
+ }
20
+ ],
21
+ "buildPresets": [
22
+ {
23
+ "name": "default",
24
+ "configurePreset": "default"
25
+ }
26
+ ]
27
+ }
@@ -0,0 +1,2 @@
1
+ from ._profileparser import *
2
+ from ._profileparser import __version__ as __version__
@@ -15,9 +15,6 @@
15
15
 
16
16
  namespace py = nanobind;
17
17
  using namespace nanobind::literals;
18
- using namespace std::string_view_literals;
19
-
20
- constexpr auto VERSION = "0.3.1"sv;
21
18
 
22
19
  struct PyProfile {
23
20
  PyProfile(std::string source)
@@ -86,8 +83,14 @@ private:
86
83
  };
87
84
 
88
85
 
89
- NB_MODULE(profileparser, m) {
90
- m.attr("__version__") = py::str(VERSION.data(), VERSION.size());
86
+ NB_MODULE(MODULE_NAME, m) {
87
+ #define STRINGIFY(x) #x
88
+ #define MACRO_STRINGIFY(x) STRINGIFY(x)
89
+ #ifdef MODULE_VERSION
90
+ m.attr("__version__") = MACRO_STRINGIFY(MODULE_VERSION);
91
+ #else
92
+ m.attr("__version__") = "dev";
93
+ #endif
91
94
 
92
95
  py::class_<Profile::SourceInfo> PySourceInfo(m, "SourceInfo");
93
96
  PySourceInfo.def_ro("offset", &Profile::SourceInfo::offset);
@@ -0,0 +1,39 @@
1
+
2
+ from dioptic import profileparser
3
+
4
+ PROFILE_SOURCE = """
5
+ Profile {
6
+ description: "Example profile for testing"
7
+
8
+ Value x {
9
+ value: 42
10
+ }
11
+
12
+ application: SomeApplication {
13
+ a: 2 * x
14
+ b: "hello world"
15
+ }
16
+ }
17
+ """
18
+
19
+
20
+ def test_parse_and_validate_roundtrip():
21
+ profile = profileparser.parse(PROFILE_SOURCE)
22
+ profileparser.validate(profile)
23
+
24
+ source = profile.to_source()
25
+ assert isinstance(source, str)
26
+ assert "Profile" in source
27
+ assert "SomeApplication" in source
28
+
29
+
30
+ def test_json_and_line_info():
31
+ profile = profileparser.parse(PROFILE_SOURCE)
32
+
33
+ json_ast = profile.to_json_ast()
34
+ assert isinstance(json_ast, str)
35
+ assert "Profile" in json_ast
36
+
37
+ line_range = profile.line_info(profile.root())
38
+ assert line_range.begin.line >= 1
39
+ assert line_range.end.line >= line_range.begin.line