hatch-cpp 0.1.9__tar.gz → 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/PKG-INFO +19 -5
  2. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/README.md +14 -0
  3. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/__init__.py +1 -1
  4. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/plugin.py +4 -0
  5. hatch_cpp-0.2.1/hatch_cpp/tests/test_hatch_build.py +46 -0
  6. {hatch_cpp-0.1.9/hatch_cpp/tests/test_project_cmake_vcpkg → hatch_cpp-0.2.1/hatch_cpp/tests/test_project_cmake}/pyproject.toml +1 -1
  7. hatch_cpp-0.2.1/hatch_cpp/tests/test_project_hatch_build/pyproject.toml +36 -0
  8. hatch_cpp-0.2.1/hatch_cpp/tests/test_project_nanobind/cpp/project/basic.cpp +2 -0
  9. hatch_cpp-0.2.1/hatch_cpp/tests/test_project_nanobind/cpp/project/basic.hpp +7 -0
  10. hatch_cpp-0.2.1/hatch_cpp/tests/test_project_pybind_vcpkg/project/__init__.py +0 -0
  11. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/toolchains/cmake.py +3 -3
  12. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/pyproject.toml +8 -7
  13. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/.gitignore +0 -0
  14. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/LICENSE +0 -0
  15. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/config.py +0 -0
  16. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/hooks.py +0 -0
  17. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_project_basic/cpp/project/basic.cpp +0 -0
  18. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_project_basic/cpp/project/basic.hpp +0 -0
  19. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_project_basic/project/__init__.py +0 -0
  20. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_project_basic/pyproject.toml +0 -0
  21. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_project_cmake/CMakeLists.txt +0 -0
  22. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_project_cmake/Makefile +0 -0
  23. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_project_cmake/cpp/project/basic.cpp +0 -0
  24. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_project_cmake/cpp/project/basic.hpp +0 -0
  25. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_project_cmake/project/__init__.py +0 -0
  26. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_project_cmake/project/include/project/basic.hpp +0 -0
  27. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_project_cmake_vcpkg/CMakeLists.txt +0 -0
  28. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_project_cmake_vcpkg/Makefile +0 -0
  29. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_project_cmake_vcpkg/cpp/project/basic.cpp +0 -0
  30. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_project_cmake_vcpkg/cpp/project/basic.hpp +0 -0
  31. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_project_cmake_vcpkg/project/__init__.py +0 -0
  32. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_project_cmake_vcpkg/project/include/project/basic.hpp +0 -0
  33. {hatch_cpp-0.1.9/hatch_cpp/tests/test_project_cmake → hatch_cpp-0.2.1/hatch_cpp/tests/test_project_cmake_vcpkg}/pyproject.toml +0 -0
  34. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_project_cmake_vcpkg/vcpkg.json +0 -0
  35. {hatch_cpp-0.1.9/hatch_cpp/tests/test_project_nanobind → hatch_cpp-0.2.1/hatch_cpp/tests/test_project_hatch_build}/cpp/project/basic.cpp +0 -0
  36. {hatch_cpp-0.1.9/hatch_cpp/tests/test_project_nanobind → hatch_cpp-0.2.1/hatch_cpp/tests/test_project_hatch_build}/cpp/project/basic.hpp +0 -0
  37. {hatch_cpp-0.1.9/hatch_cpp/tests/test_project_limited_api → hatch_cpp-0.2.1/hatch_cpp/tests/test_project_hatch_build}/project/__init__.py +0 -0
  38. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_project_limited_api/cpp/project/basic.cpp +0 -0
  39. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_project_limited_api/cpp/project/basic.hpp +0 -0
  40. {hatch_cpp-0.1.9/hatch_cpp/tests/test_project_nanobind → hatch_cpp-0.2.1/hatch_cpp/tests/test_project_limited_api}/project/__init__.py +0 -0
  41. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_project_limited_api/pyproject.toml +0 -0
  42. {hatch_cpp-0.1.9/hatch_cpp/tests/test_project_override_classes → hatch_cpp-0.2.1/hatch_cpp/tests/test_project_nanobind}/project/__init__.py +0 -0
  43. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_project_nanobind/pyproject.toml +0 -0
  44. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_project_override_classes/cpp/project/basic.cpp +0 -0
  45. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_project_override_classes/cpp/project/basic.hpp +0 -0
  46. {hatch_cpp-0.1.9/hatch_cpp/tests/test_project_override_toolchain → hatch_cpp-0.2.1/hatch_cpp/tests/test_project_override_classes}/project/__init__.py +0 -0
  47. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_project_override_classes/pyproject.toml +0 -0
  48. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_project_override_toolchain/cpp/project/basic.cpp +0 -0
  49. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_project_override_toolchain/cpp/project/basic.hpp +0 -0
  50. {hatch_cpp-0.1.9/hatch_cpp/tests/test_project_pybind → hatch_cpp-0.2.1/hatch_cpp/tests/test_project_override_toolchain}/project/__init__.py +0 -0
  51. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_project_override_toolchain/pyproject.toml +0 -0
  52. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_project_pybind/cpp/project/basic.cpp +0 -0
  53. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_project_pybind/cpp/project/basic.hpp +0 -0
  54. {hatch_cpp-0.1.9/hatch_cpp/tests/test_project_pybind_vcpkg → hatch_cpp-0.2.1/hatch_cpp/tests/test_project_pybind}/project/__init__.py +0 -0
  55. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_project_pybind/pyproject.toml +0 -0
  56. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_project_pybind_vcpkg/cpp/project/basic.cpp +0 -0
  57. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_project_pybind_vcpkg/cpp/project/basic.hpp +0 -0
  58. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_project_pybind_vcpkg/pyproject.toml +0 -0
  59. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_project_pybind_vcpkg/vcpkg.json +0 -0
  60. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_projects.py +0 -0
  61. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/tests/test_structs.py +0 -0
  62. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/toolchains/__init__.py +0 -0
  63. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/toolchains/common.py +0 -0
  64. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/toolchains/vcpkg.py +0 -0
  65. {hatch_cpp-0.1.9 → hatch_cpp-0.2.1}/hatch_cpp/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hatch-cpp
3
- Version: 0.1.9
3
+ Version: 0.2.1
4
4
  Summary: Hatch plugin for C++ builds
5
5
  Project-URL: Repository, https://github.com/python-project-templates/hatch-cpp
6
6
  Project-URL: Homepage, https://github.com/python-project-templates/hatch-cpp
@@ -12,7 +12,6 @@ Classifier: Development Status :: 3 - Alpha
12
12
  Classifier: License :: OSI Approved :: Apache Software License
13
13
  Classifier: Programming Language :: Python
14
14
  Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3.9
16
15
  Classifier: Programming Language :: Python :: 3.10
17
16
  Classifier: Programming Language :: Python :: 3.11
18
17
  Classifier: Programming Language :: Python :: 3.12
@@ -20,15 +19,16 @@ Classifier: Programming Language :: Python :: 3.13
20
19
  Classifier: Programming Language :: Python :: 3.14
21
20
  Classifier: Programming Language :: Python :: Implementation :: CPython
22
21
  Classifier: Programming Language :: Python :: Implementation :: PyPy
23
- Requires-Python: >=3.9
24
- Requires-Dist: hatchling>=1.20
22
+ Requires-Python: >=3.10
23
+ Requires-Dist: hatch-build<0.5,>=0.4
24
+ Requires-Dist: hatchling
25
25
  Requires-Dist: pydantic
26
26
  Provides-Extra: develop
27
27
  Requires-Dist: build; extra == 'develop'
28
28
  Requires-Dist: bump-my-version; extra == 'develop'
29
29
  Requires-Dist: check-manifest; extra == 'develop'
30
30
  Requires-Dist: codespell<2.5,>=2.4; extra == 'develop'
31
- Requires-Dist: hatch-build; extra == 'develop'
31
+ Requires-Dist: hatch-build>=0.3.2; extra == 'develop'
32
32
  Requires-Dist: hatchling; extra == 'develop'
33
33
  Requires-Dist: mdformat-tables>=1; extra == 'develop'
34
34
  Requires-Dist: mdformat<1.1,>=0.7.22; extra == 'develop'
@@ -128,6 +128,20 @@ cmake_env_args = {} # env-specific cmake args to pass
128
128
  include_flags = {} # include flags to pass -D
129
129
  ```
130
130
 
131
+ ### CLI
132
+
133
+ `hatch-cpp` is integrated with [`hatch-build`](https://github.com/python-project-templates/hatch-build) to allow easy configuration of options via command line:
134
+
135
+ ```bash
136
+ hatch-build \
137
+ -- \
138
+ --verbose \
139
+ --platform linux \
140
+ --vcpkg.vcpkg a/path/to/vcpkg.json \
141
+ --libraries.0.binding pybind11 \
142
+ --libraries.0.include-dirs cpp,another-dir
143
+ ```
144
+
131
145
  ### Environment Variables
132
146
 
133
147
  `hatch-cpp` will respect standard environment variables for compiler control.
@@ -83,6 +83,20 @@ cmake_env_args = {} # env-specific cmake args to pass
83
83
  include_flags = {} # include flags to pass -D
84
84
  ```
85
85
 
86
+ ### CLI
87
+
88
+ `hatch-cpp` is integrated with [`hatch-build`](https://github.com/python-project-templates/hatch-build) to allow easy configuration of options via command line:
89
+
90
+ ```bash
91
+ hatch-build \
92
+ -- \
93
+ --verbose \
94
+ --platform linux \
95
+ --vcpkg.vcpkg a/path/to/vcpkg.json \
96
+ --libraries.0.binding pybind11 \
97
+ --libraries.0.include-dirs cpp,another-dir
98
+ ```
99
+
86
100
  ### Environment Variables
87
101
 
88
102
  `hatch-cpp` will respect standard environment variables for compiler control.
@@ -1,4 +1,4 @@
1
- __version__ = "0.1.9"
1
+ __version__ = "0.2.1"
2
2
 
3
3
  from .config import *
4
4
  from .hooks import *
@@ -7,6 +7,7 @@ from platform import machine as platform_machine
7
7
  from sys import platform as sys_platform, version_info
8
8
  from typing import Any
9
9
 
10
+ from hatch_build import parse_extra_args_model
10
11
  from hatchling.builders.hooks.plugin.interface import BuildHookInterface
11
12
 
12
13
  from .config import HatchCppBuildConfig, HatchCppBuildPlan
@@ -52,6 +53,9 @@ class HatchCppBuildHook(BuildHookInterface[HatchCppBuildConfig]):
52
53
  # Instantiate builder
53
54
  build_plan = build_plan_class(**config.model_dump())
54
55
 
56
+ # Parse override args
57
+ parse_extra_args_model(build_plan)
58
+
55
59
  # Generate commands
56
60
  build_plan.generate()
57
61
 
@@ -0,0 +1,46 @@
1
+ from os import listdir
2
+ from pathlib import Path
3
+ from shutil import rmtree
4
+ from subprocess import check_call
5
+ from sys import modules, path, platform
6
+
7
+
8
+ class TestHatchBuild:
9
+ def test_hatch_build(self):
10
+ project = "test_project_hatch_build"
11
+
12
+ rmtree(f"hatch_cpp/tests/{project}/project/extension.so", ignore_errors=True)
13
+ rmtree(f"hatch_cpp/tests/{project}/project/extension.pyd", ignore_errors=True)
14
+ modules.pop("project", None)
15
+ modules.pop("project.extension", None)
16
+
17
+ # compile
18
+ check_call(
19
+ [
20
+ "hatch-build",
21
+ "--hooks-only",
22
+ "--",
23
+ "--libraries.0.name=project/extension",
24
+ "--libraries.0.sources=cpp/project/basic.cpp",
25
+ "--libraries.0.include-dirs=cpp",
26
+ "--libraries.0.binding=nanobind",
27
+ ],
28
+ cwd=f"hatch_cpp/tests/{project}",
29
+ )
30
+
31
+ # assert built
32
+
33
+ if project == "test_project_limited_api" and platform != "win32":
34
+ assert "extension.abi3.so" in listdir(f"hatch_cpp/tests/{project}/project")
35
+ else:
36
+ if platform == "win32":
37
+ assert "extension.pyd" in listdir(f"hatch_cpp/tests/{project}/project")
38
+ else:
39
+ assert "extension.so" in listdir(f"hatch_cpp/tests/{project}/project")
40
+
41
+ # import
42
+ here = Path(__file__).parent / project
43
+ path.insert(0, str(here))
44
+ import project.extension
45
+
46
+ assert project.extension.hello() == "A string"
@@ -29,7 +29,7 @@ packages = ["project"]
29
29
  packages = ["project"]
30
30
 
31
31
  [tool.hatch.build.hooks.hatch-cpp]
32
- verbose = true
32
+ verbose = false
33
33
 
34
34
  [tool.hatch.build.hooks.hatch-cpp.cmake]
35
35
  root = "CMakeLists.txt"
@@ -0,0 +1,36 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.20"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "hatch-cpp-test-project-nanobind"
7
+ description = "Basic test project for hatch-cpp"
8
+ version = "0.1.0"
9
+ requires-python = ">=3.9"
10
+ dependencies = [
11
+ "hatchling>=1.20",
12
+ "hatch-cpp",
13
+ ]
14
+
15
+ [tool.hatch.build]
16
+ artifacts = [
17
+ "project/*.dll",
18
+ "project/*.dylib",
19
+ "project/*.so",
20
+ ]
21
+
22
+ [tool.hatch.build.sources]
23
+ src = "/"
24
+
25
+ [tool.hatch.build.targets.sdist]
26
+ packages = ["project"]
27
+
28
+ [tool.hatch.build.targets.wheel]
29
+ packages = ["project"]
30
+
31
+ [tool.hatch.build.hooks.hatch-cpp]
32
+ verbose = true
33
+ libraries = [
34
+ # {name = "project/extension", sources = ["cpp/project/basic.cpp"], include-dirs = ["cpp"], binding = "nanobind"},
35
+ {name = "wrong", sources = ["wrong"], include-dirs = ["wrong"], binding = "generic"},
36
+ ]
@@ -0,0 +1,2 @@
1
+ #include "project/basic.hpp"
2
+
@@ -0,0 +1,7 @@
1
+ #pragma once
2
+ #include <nanobind/nanobind.h>
3
+ #include <nanobind/stl/string.h>
4
+
5
+ NB_MODULE(extension, m) {
6
+ m.def("hello", []() { return "A string"; });
7
+ }
@@ -3,7 +3,7 @@ from __future__ import annotations
3
3
  from os import environ
4
4
  from pathlib import Path
5
5
  from sys import version_info
6
- from typing import Any, Dict, Optional
6
+ from typing import Any, Dict, Optional, Union
7
7
 
8
8
  from pydantic import BaseModel, Field
9
9
 
@@ -23,7 +23,7 @@ DefaultMSVCGenerator = {
23
23
 
24
24
 
25
25
  class HatchCppCmakeConfiguration(BaseModel):
26
- root: Path
26
+ root: Optional[Path] = None
27
27
  build: Path = Field(default_factory=lambda: Path("build"))
28
28
  install: Optional[Path] = Field(default=None)
29
29
 
@@ -31,7 +31,7 @@ class HatchCppCmakeConfiguration(BaseModel):
31
31
  cmake_args: Dict[str, str] = Field(default_factory=dict)
32
32
  cmake_env_args: Dict[Platform, Dict[str, str]] = Field(default_factory=dict)
33
33
 
34
- include_flags: Optional[Dict[str, Any]] = Field(default=None)
34
+ include_flags: Optional[Dict[str, Union[str, int, float, bool]]] = Field(default=None)
35
35
 
36
36
  def generate(self, config) -> Dict[str, Any]:
37
37
  commands = []
@@ -1,5 +1,5 @@
1
1
  [build-system]
2
- requires = ["hatchling>=1.20"]
2
+ requires = ["hatchling"]
3
3
  build-backend = "hatchling.build"
4
4
 
5
5
  [project]
@@ -8,8 +8,8 @@ authors = [{name = "the hatch-cpp authors", email = "t.paine154@gmail.com"}]
8
8
  description = "Hatch plugin for C++ builds"
9
9
  readme = "README.md"
10
10
  license = { text = "Apache-2.0" }
11
- version = "0.1.9"
12
- requires-python = ">=3.9"
11
+ version = "0.2.1"
12
+ requires-python = ">=3.10"
13
13
  keywords = [
14
14
  "hatch",
15
15
  "python",
@@ -18,6 +18,7 @@ keywords = [
18
18
  "c++",
19
19
  "cmake",
20
20
  ]
21
+
21
22
  classifiers = [
22
23
  "Development Status :: 3 - Alpha",
23
24
  "License :: OSI Approved :: Apache Software License",
@@ -25,7 +26,6 @@ classifiers = [
25
26
  "Programming Language :: Python :: Implementation :: CPython",
26
27
  "Programming Language :: Python :: Implementation :: PyPy",
27
28
  "Programming Language :: Python :: 3",
28
- "Programming Language :: Python :: 3.9",
29
29
  "Programming Language :: Python :: 3.10",
30
30
  "Programming Language :: Python :: 3.11",
31
31
  "Programming Language :: Python :: 3.12",
@@ -34,7 +34,8 @@ classifiers = [
34
34
  ]
35
35
 
36
36
  dependencies = [
37
- "hatchling>=1.20",
37
+ "hatchling",
38
+ "hatch-build>=0.4,<0.5",
38
39
  "pydantic",
39
40
  ]
40
41
 
@@ -45,7 +46,7 @@ develop = [
45
46
  "check-manifest",
46
47
  "codespell>=2.4,<2.5",
47
48
  "hatchling",
48
- "hatch-build",
49
+ "hatch-build>=0.3.2",
49
50
  "mdformat>=0.7.22,<1.1",
50
51
  "mdformat-tables>=1",
51
52
  "pytest",
@@ -73,7 +74,7 @@ Repository = "https://github.com/python-project-templates/hatch-cpp"
73
74
  Homepage = "https://github.com/python-project-templates/hatch-cpp"
74
75
 
75
76
  [tool.bumpversion]
76
- current_version = "0.1.9"
77
+ current_version = "0.2.1"
77
78
  commit = true
78
79
  tag = false
79
80
  commit_args = "-s"
File without changes
File without changes
File without changes
File without changes
File without changes