diff --git a/README.md b/README.md
index f481f6a..068103c 100644
--- a/README.md
+++ b/README.md
@@ -75,7 +75,7 @@ The `[optional_options]` can be one or multiple of:
- `HWS_SAMPLING_INTERVAL=100ms` (default: `100ms`): set the sampling interval in milliseconds
- `HWS_ENABLE_PYTHON_BINDINGS=ON|OFF` (default: `ON`): enable Python bindings
-### Installing
+### Installing via CMake
The library supports the `install` target:
@@ -95,6 +95,17 @@ export PYTHONPATH=${CMAKE_INSTALL_PREFIX}/lib:${CMAKE_INSTALL_PREFIX}/lib64:${PY
**Note:** when using Intel GPUs, the `CMAKE_MODULE_PATH` should be updated to point to our `cmake` directory containing the
`Findlevel_zero.cmake` file and `export ZES_ENABLE_SYSMAN=1` should be set.
+### Installing via pip
+
+The library is also available via pip:
+
+```bash
+pip install hardware-sampling
+```
+
+This pip install behaves **as if** no additional CMake options were provided.
+This means that only the hardware is supported for which the respective vendor libraries was available at the point of the `pip install hardware-sampling` invocation.
+
## Available samples
The sampling type `fixed` denotes samples that are gathered once per hardware samples like maximum clock frequencies or
@@ -307,7 +318,7 @@ plt.show()
```
-
+
## License
diff --git a/bindings/CMakeLists.txt b/bindings/CMakeLists.txt
index 5cf0e46..93d8e98 100644
--- a/bindings/CMakeLists.txt
+++ b/bindings/CMakeLists.txt
@@ -68,4 +68,9 @@ include(GNUInstallDirs)
# install Python bindings
install(TARGETS ${HWS_PYTHON_BINDINGS_LIBRARY_NAME}
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" # all shared lib files
+)
+
+# install the __init__.py file so Python recognizes the package when installed via pip
+install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/__init__.py"
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}"
)
\ No newline at end of file
diff --git a/bindings/__init__.py b/bindings/__init__.py
new file mode 100644
index 0000000..f4badd4
--- /dev/null
+++ b/bindings/__init__.py
@@ -0,0 +1,5 @@
+# import all bindings from the compiled hws module
+from .HardwareSampling import *
+# explicitly set the module level attributes
+__doc__ = HardwareSampling.__doc__
+__version__ = HardwareSampling.__version__
\ No newline at end of file
diff --git a/bindings/main.cpp b/bindings/main.cpp
index f3dca3f..3f062e7 100644
--- a/bindings/main.cpp
+++ b/bindings/main.cpp
@@ -5,6 +5,8 @@
* See the LICENSE.md file in the project root for full license information.
*/
+#include "hws/version.hpp" // hws::version::version
+
#include "pybind11/pybind11.h" // PYBIND11_MODULE, py::module_
#include // std::string_view
@@ -28,6 +30,7 @@ void init_version(py::module_ &);
PYBIND11_MODULE(HardwareSampling, m) {
m.doc() = "Hardware Sampling for CPUs and GPUs";
+ m.attr("__version__") = hws::version::version;
init_event(m);
init_sample_category(m);
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 0000000..489641a
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,43 @@
+[build-system]
+requires = ["scikit-build-core"]
+build-backend = "scikit_build_core.build"
+# set the necessary CMake build options
+[tool.scikit-build]
+cmake.args = [
+ "-DCMAKE_INSTALL_LIBDIR=HardwareSampling",
+ "-DCMAKE_INSTALL_BINDIR=HardwareSampling",
+ "-DCMAKE_INSTALL_INCLUDEDIR=HardwareSampling",
+ "-DCMAKE_INSTALL_MANDIR=HardwareSampling",
+ "-DCMAKE_INSTALL_DATAROOTDIR=HardwareSampling/cmake",
+ "-DCMAKE_INSTALL_RPATH=$ORIGIN"
+]
+sdist.exclude = ["build*/", "dist/", "docs/html/", ".github", "examples", "install", ".clang*", ".clion*", ".gitignore"]
+# project specific metadata
+[project]
+name = "hardware_sampling"
+version = "1.1.0"
+description = "hws - Hardware Sampling for GPUs and CPUs (e.g., clock frequencies, memory consumption, temperatures, or energy draw)"
+readme = "README.md"
+license = { file = "LICENSE" }
+authors = [
+ { name = "Marcel Breyer" }
+]
+maintainers = [
+ { name = "University of Stuttgart IPVS - SC", email = "sc@ipvs.uni-stuttgart.de" }
+]
+requires-python = ">=3.8"
+classifiers = [
+ "Development Status :: 5 - Production/Stable",
+ "Environment :: GPU",
+ "Intended Audience :: Science/Research",
+ "License :: OSI Approved :: MIT License",
+ "Natural Language :: English",
+ "Operating System :: POSIX :: Linux",
+ "Programming Language :: C++",
+ "Programming Language :: Python :: 3"
+]
+# project specific URLs
+[project.urls]
+documentation = "https://sc-sgs.github.io/hardware_sampling/"
+repository = "https://github.com/SC-SGS/hardware_sampling.git"
+issues = "https://github.com/SC-SGS/hardware_sampling/issues"
\ No newline at end of file