hardwarey 0.0.0__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.
@@ -0,0 +1,178 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ concurrency:
8
+ group: ${{ github.workflow }}-${{ github.ref }}
9
+ cancel-in-progress: true
10
+
11
+ permissions:
12
+ contents: read
13
+
14
+ jobs:
15
+ linux-gcc:
16
+ name: Linux - GCC
17
+ runs-on: ubuntu-latest
18
+
19
+ steps:
20
+ - name: Checkout repository
21
+ uses: actions/checkout@v6
22
+ with:
23
+ persist-credentials: false
24
+
25
+ - name: Set up Python
26
+ uses: actions/setup-python@v6
27
+ with:
28
+ python-version: "3.14"
29
+ cache: pip
30
+
31
+ - name: Install dependencies
32
+ run: |
33
+ python -m pip install --upgrade pip
34
+ python -m pip install pybind11 ninja
35
+
36
+ - name: Configure
37
+ run: cmake -S . -B build -G Ninja -DHARDWAREY_BUILD_TESTS=ON -Dpybind11_DIR=$(python -m pybind11 --cmakedir)
38
+
39
+ - name: Build
40
+ run: cmake --build build
41
+
42
+ - name: Test
43
+ run: ctest --test-dir build --output-on-failure
44
+
45
+ linux-clang:
46
+ name: Linux - Clang
47
+ runs-on: ubuntu-latest
48
+
49
+ steps:
50
+ - name: Checkout repository
51
+ uses: actions/checkout@v6
52
+ with:
53
+ persist-credentials: false
54
+
55
+ - name: Set up Python
56
+ uses: actions/setup-python@v6
57
+ with:
58
+ python-version: "3.14"
59
+ cache: pip
60
+
61
+ - name: Install dependencies
62
+ run: |
63
+ python -m pip install --upgrade pip
64
+ python -m pip install pybind11 ninja
65
+ sudo apt-get update
66
+ sudo apt-get install -y clang
67
+
68
+ - name: Configure
69
+ run: CC=clang CXX=clang++ cmake -S . -B build -G Ninja -DHARDWAREY_BUILD_TESTS=ON -Dpybind11_DIR=$(python -m pybind11 --cmakedir)
70
+
71
+ - name: Build
72
+ run: cmake --build build
73
+
74
+ - name: Test
75
+ run: ctest --test-dir build --output-on-failure
76
+
77
+ windows-msvc:
78
+ name: Windows - MSVC
79
+ runs-on: windows-latest
80
+
81
+ steps:
82
+ - name: Checkout repository
83
+ uses: actions/checkout@v6
84
+ with:
85
+ persist-credentials: false
86
+
87
+ - name: Set up Python
88
+ uses: actions/setup-python@v6
89
+ with:
90
+ python-version: "3.14"
91
+ cache: pip
92
+
93
+ - name: Install dependencies
94
+ run: |
95
+ python -m pip install --upgrade pip
96
+ python -m pip install pybind11 ninja
97
+
98
+ - name: Verify Python environment
99
+ run: |
100
+ python --version
101
+ python -m pybind11 --cmakedir
102
+
103
+ - name: Configure
104
+ shell: pwsh
105
+ run: |
106
+ $pythonExe = python -c "import sys; print(sys.executable)"
107
+ $pybind11Dir = python -m pybind11 --cmakedir
108
+ cmake -S . -B build `
109
+ "-DPython_EXECUTABLE=$pythonExe" `
110
+ "-Dpybind11_DIR=$pybind11Dir" `
111
+ "-DHARDWAREY_BUILD_TESTS=ON"
112
+
113
+ - name: Build
114
+ run: cmake --build build --config Release
115
+
116
+ - name: Test
117
+ run: ctest --test-dir build -C Release --output-on-failure
118
+
119
+ macos-apple-clang:
120
+ name: macOS - Apple Clang
121
+ runs-on: macos-latest
122
+
123
+ steps:
124
+ - name: Checkout repository
125
+ uses: actions/checkout@v6
126
+ with:
127
+ persist-credentials: false
128
+
129
+ - name: Set up Python
130
+ uses: actions/setup-python@v6
131
+ with:
132
+ python-version: "3.14"
133
+ cache: pip
134
+
135
+ - name: Install dependencies
136
+ run: |
137
+ python -m pip install --upgrade pip
138
+ python -m pip install pybind11 ninja
139
+
140
+ - name: Configure
141
+ run: cmake -S . -B build -G Ninja -DHARDWAREY_BUILD_TESTS=ON -Dpybind11_DIR=$(python -m pybind11 --cmakedir)
142
+
143
+ - name: Build
144
+ run: cmake --build build
145
+
146
+ - name: Test
147
+ run: ctest --test-dir build --output-on-failure
148
+
149
+ python:
150
+ name: Python ${{ matrix.python-version }}
151
+ runs-on: ubuntu-latest
152
+ strategy:
153
+ fail-fast: false
154
+ matrix:
155
+ python-version:
156
+ - "3.10"
157
+ - "3.11"
158
+ - "3.12"
159
+ - "3.13"
160
+ - "3.14"
161
+
162
+ steps:
163
+ - name: Checkout repository
164
+ uses: actions/checkout@v6
165
+ with:
166
+ persist-credentials: false
167
+
168
+ - name: Set up Python
169
+ uses: actions/setup-python@v6
170
+ with:
171
+ python-version: ${{ matrix.python-version }}
172
+ cache: pip
173
+
174
+ - name: Install hardwarey
175
+ run: python -m pip install .
176
+
177
+ - name: Test import
178
+ run: python -c "import hardwarey; print(hardwarey); print(hardwarey.threads())"
@@ -0,0 +1,88 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ permissions:
8
+ contents: read
9
+
10
+ jobs:
11
+ build_wheels:
12
+ name: Build wheels on ${{ matrix.os }}
13
+ runs-on: ${{ matrix.os }}
14
+ strategy:
15
+ fail-fast: false
16
+ matrix:
17
+ os:
18
+ - ubuntu-latest
19
+ - windows-latest
20
+ - macos-15-intel
21
+ - macos-14
22
+
23
+ steps:
24
+ - name: Check out repository
25
+ uses: actions/checkout@v6
26
+ with:
27
+ persist-credentials: false
28
+
29
+ - name: Build and test wheels
30
+ uses: pypa/cibuildwheel@v4.2.0
31
+ env:
32
+ CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-* cp313-* cp314-*"
33
+ CIBW_ARCHS: auto64
34
+ CIBW_TEST_REQUIRES: pytest
35
+ CIBW_TEST_COMMAND: "pytest {project}/tests"
36
+
37
+ - name: Upload wheel artifacts
38
+ uses: actions/upload-artifact@v4
39
+ with:
40
+ name: distributions-wheels-${{ matrix.os }}
41
+ path: wheelhouse/*.whl
42
+ if-no-files-found: error
43
+
44
+ build_sdist:
45
+ name: Build source distribution
46
+ runs-on: ubuntu-latest
47
+
48
+ steps:
49
+ - name: Check out repository
50
+ uses: actions/checkout@v6
51
+ with:
52
+ persist-credentials: false
53
+
54
+ - name: Set up Python
55
+ uses: actions/setup-python@v6
56
+ with:
57
+ python-version: "3.14"
58
+
59
+ - name: Build source distribution
60
+ run: pipx run build --sdist --outdir dist
61
+
62
+ - name: Upload source artifact
63
+ uses: actions/upload-artifact@v4
64
+ with:
65
+ name: distributions-sdist
66
+ path: dist/*.tar.gz
67
+ if-no-files-found: error
68
+
69
+ publish:
70
+ name: Publish distributions to PyPI
71
+ needs: [build_wheels, build_sdist]
72
+ runs-on: ubuntu-latest
73
+ environment:
74
+ name: pypi
75
+ url: https://pypi.org/project/hardwarey/
76
+ permissions:
77
+ id-token: write
78
+
79
+ steps:
80
+ - name: Download distributions
81
+ uses: actions/download-artifact@v5
82
+ with:
83
+ pattern: distributions-*
84
+ path: dist
85
+ merge-multiple: true
86
+
87
+ - name: Publish distributions to PyPI
88
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,45 @@
1
+ name: Build wheels
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ tags: ["v*"]
7
+ pull_request:
8
+ workflow_dispatch:
9
+
10
+ permissions:
11
+ contents: read
12
+
13
+ jobs:
14
+ build_wheels:
15
+ name: Wheels on ${{ matrix.os }}
16
+ runs-on: ${{ matrix.os }}
17
+ strategy:
18
+ fail-fast: false
19
+ matrix:
20
+ os:
21
+ - ubuntu-latest
22
+ - windows-latest
23
+ - macos-15-intel
24
+ - macos-14
25
+
26
+ steps:
27
+ - name: Check out repository
28
+ uses: actions/checkout@v6
29
+ with:
30
+ persist-credentials: false
31
+
32
+ - name: Build and test wheels
33
+ uses: pypa/cibuildwheel@v4.2.0
34
+ env:
35
+ CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-* cp313-* cp314-*"
36
+ CIBW_ARCHS: auto64
37
+ CIBW_TEST_REQUIRES: pytest
38
+ CIBW_TEST_COMMAND: "pytest {project}/tests"
39
+
40
+ - name: Upload wheels
41
+ uses: actions/upload-artifact@v4
42
+ with:
43
+ name: wheels-${{ matrix.os }}
44
+ path: wheelhouse/*.whl
45
+ if-no-files-found: error
@@ -0,0 +1,53 @@
1
+ # Python bytecode and caches
2
+ __pycache__/
3
+ *.py[cod]
4
+ .pytest_cache/
5
+ .mypy_cache/
6
+ .ruff_cache/
7
+ .coverage
8
+ .coverage.*
9
+ htmlcov/
10
+
11
+ # Virtual environments
12
+ .venv/
13
+ .venv-*/
14
+ venv/
15
+ env/
16
+
17
+ # Python packaging
18
+ build/
19
+ dist/
20
+ _skbuild/
21
+ *.egg-info/
22
+
23
+ # Compiled native artifacts
24
+ *.so
25
+ *.dylib
26
+ *.dll
27
+ *.a
28
+ *.lib
29
+ *.o
30
+ *.obj
31
+
32
+ # CMake and build-system output
33
+ cmake-build-*/
34
+ CMakeFiles/
35
+ CMakeCache.txt
36
+ cmake_install.cmake
37
+ compile_commands.json
38
+ install_manifest.txt
39
+ Makefile
40
+ build.ninja
41
+ .ninja_deps
42
+ .ninja_log
43
+
44
+ # Editors and operating systems
45
+ .idea/
46
+ .vscode/
47
+ *.swp
48
+ *.swo
49
+ *~
50
+ .DS_Store
51
+ Thumbs.db
52
+ main.py
53
+ build-gtest/
@@ -0,0 +1,59 @@
1
+ cmake_minimum_required(VERSION 3.20)
2
+
3
+ project(hardwarey VERSION 0.0.0 LANGUAGES CXX)
4
+
5
+ option(HARDWAREY_BUILD_TESTS "Build hardwarey C++ tests" OFF)
6
+
7
+ set(CMAKE_CXX_STANDARD 17)
8
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
9
+ set(CMAKE_CXX_EXTENSIONS OFF)
10
+
11
+ set(PYBIND11_FINDPYTHON ON)
12
+ find_package(pybind11 CONFIG REQUIRED)
13
+
14
+ add_library(hardwarey_core STATIC
15
+ src/cpu.cpp
16
+ )
17
+ target_include_directories(hardwarey_core
18
+ PUBLIC
19
+ ${PROJECT_SOURCE_DIR}/include
20
+ )
21
+ set_target_properties(hardwarey_core PROPERTIES
22
+ POSITION_INDEPENDENT_CODE ON
23
+ )
24
+
25
+ pybind11_add_module(_core MODULE
26
+ src/bindings.cpp
27
+ )
28
+ target_link_libraries(_core PRIVATE hardwarey_core)
29
+
30
+ install(TARGETS _core
31
+ LIBRARY DESTINATION hardwarey
32
+ RUNTIME DESTINATION hardwarey
33
+ )
34
+
35
+ if(HARDWAREY_BUILD_TESTS)
36
+ enable_testing()
37
+
38
+ include(FetchContent)
39
+ FetchContent_Declare(
40
+ googletest
41
+ GIT_REPOSITORY https://github.com/google/googletest.git
42
+ GIT_TAG v1.17.0
43
+ GIT_SHALLOW TRUE
44
+ )
45
+ set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
46
+ FetchContent_MakeAvailable(googletest)
47
+
48
+ add_executable(hardwarey_cpu_test
49
+ tests/test_cpu.cpp
50
+ )
51
+ target_link_libraries(hardwarey_cpu_test
52
+ PRIVATE
53
+ hardwarey_core
54
+ GTest::gtest_main
55
+ )
56
+
57
+ include(GoogleTest)
58
+ gtest_discover_tests(hardwarey_cpu_test)
59
+ endif()
@@ -0,0 +1,42 @@
1
+ Metadata-Version: 2.2
2
+ Name: hardwarey
3
+ Version: 0.0.0
4
+ Summary: A generic C++ project with Python bindings powered by pybind11
5
+ Requires-Python: >=3.9
6
+ Description-Content-Type: text/markdown
7
+
8
+ # hardwarey
9
+
10
+ A minimal C++17 project exposed to Python with pybind11. The example binding
11
+ reports the number of concurrent threads supported by the host CPU.
12
+
13
+ ## Layout
14
+
15
+ ```text
16
+ include/hardwarey/ Public C++ headers
17
+ src/ C++ implementation and Python bindings
18
+ python/hardwarey/ Python package
19
+ tests/ Python tests
20
+ ```
21
+
22
+ ## Build and install
23
+
24
+ Create and activate a virtual environment, then run:
25
+
26
+ ```bash
27
+ python -m pip install --upgrade pip
28
+ python -m pip install -e .
29
+ ```
30
+
31
+ To run the tests:
32
+
33
+ ```bash
34
+ python -m pip install pytest
35
+ pytest
36
+ ```
37
+
38
+ Run the example with:
39
+
40
+ ```bash
41
+ python main.py
42
+ ```
@@ -0,0 +1,35 @@
1
+ # hardwarey
2
+
3
+ A minimal C++17 project exposed to Python with pybind11. The example binding
4
+ reports the number of concurrent threads supported by the host CPU.
5
+
6
+ ## Layout
7
+
8
+ ```text
9
+ include/hardwarey/ Public C++ headers
10
+ src/ C++ implementation and Python bindings
11
+ python/hardwarey/ Python package
12
+ tests/ Python tests
13
+ ```
14
+
15
+ ## Build and install
16
+
17
+ Create and activate a virtual environment, then run:
18
+
19
+ ```bash
20
+ python -m pip install --upgrade pip
21
+ python -m pip install -e .
22
+ ```
23
+
24
+ To run the tests:
25
+
26
+ ```bash
27
+ python -m pip install pytest
28
+ pytest
29
+ ```
30
+
31
+ Run the example with:
32
+
33
+ ```bash
34
+ python main.py
35
+ ```
@@ -0,0 +1,7 @@
1
+ #pragma once
2
+
3
+ namespace hardwarey {
4
+
5
+ unsigned int threads();
6
+
7
+ } // namespace hardwarey
@@ -0,0 +1,20 @@
1
+ [build-system]
2
+ requires = [
3
+ "scikit-build-core>=0.10",
4
+ "pybind11>=2.12",
5
+ ]
6
+ build-backend = "scikit_build_core.build"
7
+
8
+ [project]
9
+ name = "hardwarey"
10
+ version = "0.0.0"
11
+ description = "A generic C++ project with Python bindings powered by pybind11"
12
+ readme = "README.md"
13
+ requires-python = ">=3.9"
14
+
15
+ [tool.scikit-build]
16
+ wheel.packages = ["python/hardwarey"]
17
+ cmake.build-type = "Release"
18
+
19
+ [tool.pytest.ini_options]
20
+ testpaths = ["tests"]
@@ -0,0 +1,6 @@
1
+ """Python interface for hardwarey."""
2
+
3
+ from ._core import threads
4
+
5
+ __all__ = ["threads"]
6
+ __version__ = "0.0.0"
@@ -0,0 +1,11 @@
1
+ #include <pybind11/pybind11.h>
2
+
3
+ #include "hardwarey/cpu.hpp"
4
+
5
+ namespace py = pybind11;
6
+
7
+ PYBIND11_MODULE(_core, module) {
8
+ module.doc() = "Python bindings for hardwarey";
9
+
10
+ module.def("threads", &hardwarey::threads, "Get the number of threads available on the CPU");
11
+ }
@@ -0,0 +1,11 @@
1
+ #include <thread>
2
+
3
+ #include "hardwarey/cpu.hpp"
4
+
5
+ namespace hardwarey {
6
+
7
+ unsigned int threads() {
8
+ return std::thread::hardware_concurrency();
9
+ }
10
+
11
+ } // namespace hardwarey
@@ -0,0 +1,5 @@
1
+ import hardwarey
2
+
3
+
4
+ def test_threads():
5
+ assert hardwarey.threads() > 0
@@ -0,0 +1,9 @@
1
+ #include <thread>
2
+
3
+ #include <gtest/gtest.h>
4
+
5
+ #include "hardwarey/cpu.hpp"
6
+
7
+ TEST(CpuTest, ReportsHardwareConcurrency) {
8
+ EXPECT_EQ(hardwarey::threads(), std::thread::hardware_concurrency());
9
+ }