Skip to main content

skbuild-conan: A conan extension for scikit-build

PyBind11 and scitkit-build enable us to easily write native C++-modules for Python. However, you get problems if your C++-code has dependencies. This extension tries to make defining C++-dependencies as easy as defining the Python-dependencies. This way you can easily add any C++-library that has a conan recipe to your Python-project.

This project originates from our need to use complex C++-libraries in Python projects and missing any nice option to include C++-dependencies. For a few projects, we wrote individual code to fetch the dependencies or just added instructions on how to install them (which of course can scare pure Python users).

This project is currently just nice interface to hacks we accumulated. We try to make it as universal and robust as possible as we rely on this for multiple projects, but we are working fast-paced and will quickly abandon this tool once there is something better.

We (TU Braunschweig, Algorithms Group) are not affiliated with scikit-build or conan.

Installation

You can simply add "skbuild_conan@git+https://github.com/d-krupke/skbuild-conan.git", to requires=[...] in pyproject.toml. E.g. The pyproject.toml could look like this

[build-system]
requires = [
    "conan>=2.0.0",
    "setuptools",
    "scikit-build>=0.17.3",
    "skbuild_conan@git+https://github.com/d-krupke/skbuild-conan.git",
    "cmake>=3.23",
    "ninja",
]
build-backend = "setuptools.build_meta"

If you want to use for example setup.py build, you need to install skbuild_conan to your environment. You can do so by pip install skbuild_conan@git+https://github.com/d-krupke/skbuild-conan.git. We will also add this tool to PyPI soon.

Usage

The usage is very similar to scitkit-build (and setuptools). We just added a few additional arguments to setup().

See how to use scikit-build first, as this is just a small extension to it.

The added options are

  • conanfile: Path to the folder with the conanfile.[py|txt]. By default the root is assumed. The conanfile can be used to define the dependencies. Alternatively, you can also use conan_requirements to define the conan dependencies without a conanfile. This option is exclusive. If you define conan_requirements, this option is ignored.
  • conan_recipes: List of paths to further conan recipes. The conan package index is far from perfect, so often you need to build your own recipes. You don't always want to upload those, so this argument gives you the option to integrate local recipes. Just the path to the folder containing the conanfile.py.
  • conan_requirements: Instead of providing a conanfile, you can simply state the dependencies here. E.g. ["fmt/[>=10.0.0]"] to add fmt in version >=10.0.0.
  • conan_profile_settings: Overwrite conan profile settings. Sometimes necessary because of ABI-problems, etc.
  • wrapped_setup: The setup-method that is going to be wrapped. This would allow you to extend already extended setup functions. By default, it is the setup of skbuild, which extends the setup of setuptools.
  • conan_output_folder: The folder where conan will write the generated files. No real reason to change it unless the default creates conflicts with some other tool.
  • cmake_args: This is actually an argument of skbuild but we will extend it. It hands cmake custom arguments. We use it to tell cmake about the conan modules.

An example usage could be as follows

from skbuild_conan import setup
from setuptools import find_packages

setup(  # https://scikit-build.readthedocs.io/en/latest/usage.html#setup-options
    name="simple_skbuild_conan_example",
    version="0.1.0",
    packages=find_packages("src"),  # Include all packages in `./src`.
    package_dir={"": "src"},  # The root for our python package is in `./src`.
    python_requires=">=3.7",  # lowest python version supported.
    install_requires=[],  # Python Dependencies
    conan_requirements=["fmt/[>=10.0.0]"],  # C++ Dependencies
    cmake_minimum_required_version="3.23",
)

See ./examples/simple_skbuild_conan_example for a full example.

Contribution

We are happy about any contribution and also about reported issues. Sometimes it can take some time before we are able to take care of something, as we need to prioritize quite often.

Changelog

  • 0.1.3 Fixing bug if no settings are given.
  • 0.1.2 Moved workaround into setup to make it more explicit.
  • 0.1.1 First tested and apparently working version.

Release files for skbuild-conan 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for skbuild-conan 0.1.3
File Size Uploaded
skbuild_conan-0.1.3.tar.gz 7.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for skbuild-conan 0.1.3
File Interpreter ABI Platform
skbuild_conan-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 15.3 kB

Release files / skbuild_conan-0.1.3.tar.gz

Download URL skbuild_conan-0.1.3.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
77140baacb903a4eddbb9faf7f845993d871e6ac721b88443f7bee9636cdde29
BLAKE2b-256 checksum
How to use checksums
e6ded722b138ffa6892dd4a9b764ef1576e71ff59e81449b295157f8e0ed127a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.1 CPython/3.11.3

Release files / skbuild_conan-0.1.3-py3-none-any.whl

Download URL skbuild_conan-0.1.3-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
15afb775baeeeaefe2fa82c2c4afeea5f1a9a3aefdce268feb93cac87da117f3
BLAKE2b-256 checksum
How to use checksums
2323cbbf21787e8280139da0434ad32df654939f9355a55d493d2a985afabf63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.1 CPython/3.11.3

Release history Release notifications | RSS feed

1.6.0

2 release files

1.5.0

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.2.0

2 release files

0.1.4

2 release files

This release

0.1.3 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page