Skip to main content

Cross-platform C++ library with Python bindings via pybind11

Project description

MyLib (pybind11 Version)

A cross-platform C++ library with a Python interface using pybind11.

Features

  • C++ core logic
  • Pythonic interface via pybind11
  • Builds on Windows, Linux, and macOS
  • Packaged using scikit-build-core
  • Visual Studio 2022 solution generation via CMake
  • Includes C++ and Python tests

🛠 Build & Install Locally (Python)

Step 1: Install Build Requirements

pip install scikit-build-core pybind11[global] build

Step 2: Install the Package

pip install .

Or build a wheel:

python -m build

🧪 Python Usage

from mylib import MyLib

lib = MyLib()
lib.do_work()
print(lib.get_counter())
lib.reset_counter()

To run tests:

python tests/test_python.py

🧰 C++ Development & Testing (Visual Studio 2022)

Step 1: Open Visual Studio 2022 Developer Command Prompt

Launch "x64 Native Tools Command Prompt for VS 2022"

Step 2: Create Build Directory and Generate Solution

cd mylib
mkdir build
cd build
cmake .. -G "Visual Studio 17 2022" -A x64

This generates MyLib.sln which you can open with Visual Studio.

Step 3: Build in Release Mode

cmake --build . --config Release

Step 4: Run the C++ Test

./Release/test_mylib.exe

🚀 Publish to PyPI

Step 1: Create an Account

Step 2: Install Twine

pip install twine

Step 3: Build the Package

python -m build

Step 4: Upload to PyPI

twine upload dist/*

Use __token__ as your username and paste the token when prompted.


🧱 Project Layout

mylib/
├── CMakeLists.txt
├── pyproject.toml
├── README.md
├── src/
│   ├── CMakeLists.txt
│   ├── mylib.cpp
│   └── test.cpp
├── tests/
│   └── test_python.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

acube3_mylib-0.1.0-cp310-cp310-win_amd64.whl (2.9 kB view details)

Uploaded CPython 3.10Windows x86-64

File details

Details for the file acube3_mylib-0.1.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for acube3_mylib-0.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 bd02a39d52da301b28ce37d6a4aa31dadd4d962900dd95ea21123ce0f0992795
MD5 462fb5abd02b91754f57665a9bf757a0
BLAKE2b-256 6e83c5d2055e08112b72a5b95ec772af92ee477d02fecc68bc6242a52939cb82

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page