Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cppython/plugins/conan/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ def publish(self) -> None:
# Add build mode (build everything for publishing)
command_args.extend(['--build', 'missing'])

# Skip test dependencies during publishing
command_args.extend(['-c', 'tools.graph:skip_test=True'])
command_args.extend(['-c', 'tools.build:skip_test=True'])

# Add cmake binary configuration if specified
if self._cmake_binary and self._cmake_binary != 'cmake':
# Quote the path if it contains spaces
Expand Down
7 changes: 7 additions & 0 deletions docs/plugins/conan/configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Configuration

```toml
[tool.cppython.plugins.conan]
remotes = ["remote-name"] # Optional: remotes for publishing
skip_upload = false # Optional: skip upload during publish
```
3 changes: 3 additions & 0 deletions docs/plugins/conan/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Conan Plugin

The Conan plugin integrates with the Conan C++ package manager for dependency management and package publishing.
50 changes: 50 additions & 0 deletions docs/plugins/conan/integration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Conanfile Integration

CPPython uses a dual-file approach.

## `conanfile_base.py` - Auto-generated

**Auto-generated** from your `pyproject.toml` dependencies. **Do not edit manually** - regenerated on every install/update/publish.

Contains a `CPPythonBase` class with dependencies from `[tool.cppython.dependencies]` and test dependencies from `[tool.cppython.dependency-groups.test]`.

## `conanfile.py` - User-customizable

**Created once** if it doesn't exist, then **never modified** by CPPython. Inherits from `CPPythonBase`.

You can customize this file for package metadata like name, version, and settings, additional dependencies beyond `pyproject.toml`, build configuration and CMake integration, and package and export logic.

**Key requirement** - Always call `super().requirements()` and `super().build_requirements()` to inherit managed dependencies.

## Workflow

- First run - Both files are generated
- Subsequent runs - Only `conanfile_base.py` is regenerated; `conanfile.py` is preserved
- Adding dependencies - Update `pyproject.toml` and run `cppython install`

## Migrating Existing Projects

If you have an existing `conanfile.py`, back it up and run `cppython install` to generate both files. Then update your conanfile to inherit from `CPPythonBase`.

```python
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conanfile_base import CPPythonBase # Import the base class


class YourPackage(CPPythonBase): # Inherit from CPPythonBase instead of ConanFile
name = "your-package"
version = "1.0.0"
settings = "os", "compiler", "build_type", "arch"
exports = "conanfile_base.py" # Export the base file

def requirements(self):
super().requirements() # Get CPPython managed dependencies
# Add your custom requirements here
# self.requires("custom-lib/1.0.0")

def build_requirements(self):
super().build_requirements() # Get CPPython managed test dependencies
# Add your custom build requirements here

# ... rest of your configuration
```
Loading