From 93ef043615af8b8c2b8d071b1ec11c143d4276a0 Mon Sep 17 00:00:00 2001 From: Asher Norland Date: Mon, 17 Nov 2025 07:57:39 -0800 Subject: [PATCH 1/3] Conan Doc Folder --- docs/plugins/conan/configuration.md | 7 +++++++ docs/plugins/conan/index.md | 3 +++ docs/plugins/conan/integration.md | 29 +++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 docs/plugins/conan/configuration.md create mode 100644 docs/plugins/conan/index.md create mode 100644 docs/plugins/conan/integration.md diff --git a/docs/plugins/conan/configuration.md b/docs/plugins/conan/configuration.md new file mode 100644 index 0000000..b11b656 --- /dev/null +++ b/docs/plugins/conan/configuration.md @@ -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 +``` diff --git a/docs/plugins/conan/index.md b/docs/plugins/conan/index.md new file mode 100644 index 0000000..b5a62de --- /dev/null +++ b/docs/plugins/conan/index.md @@ -0,0 +1,3 @@ +# Conan Plugin + +The Conan plugin integrates with the Conan C++ package manager for dependency management and package publishing. diff --git a/docs/plugins/conan/integration.md b/docs/plugins/conan/integration.md new file mode 100644 index 0000000..4d57856 --- /dev/null +++ b/docs/plugins/conan/integration.md @@ -0,0 +1,29 @@ +# 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`, follow these steps. + +**TODO** From 868e2858f607f1ef426ff3226dc62daa3986c55c Mon Sep 17 00:00:00 2001 From: Asher Norland Date: Mon, 17 Nov 2025 08:20:42 -0800 Subject: [PATCH 2/3] Update integration.md --- docs/plugins/conan/integration.md | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/docs/plugins/conan/integration.md b/docs/plugins/conan/integration.md index 4d57856..f925c61 100644 --- a/docs/plugins/conan/integration.md +++ b/docs/plugins/conan/integration.md @@ -24,6 +24,27 @@ You can customize this file for package metadata like name, version, and setting ## Migrating Existing Projects -If you have an existing `conanfile.py`, follow these steps. +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`. -**TODO** +```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 +``` From 9f4bf883f9fa860899d4a01deb4192f881f97004 Mon Sep 17 00:00:00 2001 From: Asher Norland Date: Tue, 18 Nov 2025 14:28:20 -0800 Subject: [PATCH 3/3] Update plugin.py --- cppython/plugins/conan/plugin.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cppython/plugins/conan/plugin.py b/cppython/plugins/conan/plugin.py index a4cad9e..077a0ca 100644 --- a/cppython/plugins/conan/plugin.py +++ b/cppython/plugins/conan/plugin.py @@ -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