hatch-cpp 0.1.9__py3-none-any.whl → 0.2.0__py3-none-any.whl
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.
- hatch_cpp/__init__.py +1 -1
- hatch_cpp/plugin.py +4 -0
- hatch_cpp/tests/test_hatch_build.py +46 -0
- hatch_cpp/tests/test_project_cmake/pyproject.toml +1 -1
- hatch_cpp/tests/test_project_hatch_build/cpp/project/basic.cpp +2 -0
- hatch_cpp/tests/test_project_hatch_build/cpp/project/basic.hpp +7 -0
- hatch_cpp/tests/test_project_hatch_build/project/__init__.py +0 -0
- hatch_cpp/tests/test_project_hatch_build/pyproject.toml +36 -0
- hatch_cpp/toolchains/cmake.py +3 -3
- {hatch_cpp-0.1.9.dist-info → hatch_cpp-0.2.0.dist-info}/METADATA +18 -4
- {hatch_cpp-0.1.9.dist-info → hatch_cpp-0.2.0.dist-info}/RECORD +14 -9
- {hatch_cpp-0.1.9.dist-info → hatch_cpp-0.2.0.dist-info}/WHEEL +0 -0
- {hatch_cpp-0.1.9.dist-info → hatch_cpp-0.2.0.dist-info}/entry_points.txt +0 -0
- {hatch_cpp-0.1.9.dist-info → hatch_cpp-0.2.0.dist-info}/licenses/LICENSE +0 -0
hatch_cpp/__init__.py
CHANGED
hatch_cpp/plugin.py
CHANGED
|
@@ -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"
|
|
File without changes
|
|
@@ -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
|
+
]
|
hatch_cpp/toolchains/cmake.py
CHANGED
|
@@ -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,
|
|
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,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hatch-cpp
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
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,7 +19,8 @@ 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.
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Requires-Dist: hatch-build<0.5,>=0.4
|
|
24
24
|
Requires-Dist: hatchling>=1.20
|
|
25
25
|
Requires-Dist: pydantic
|
|
26
26
|
Provides-Extra: develop
|
|
@@ -28,7 +28,7 @@ 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.
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
hatch_cpp/__init__.py,sha256=
|
|
1
|
+
hatch_cpp/__init__.py,sha256=0H1fLq61dXqP3350HHLIwqt8Nb1zw8zIz5TsIkYHASQ,114
|
|
2
2
|
hatch_cpp/config.py,sha256=8UIdlc6fHEBNgjmLZ1op3x-16BARxx4GJHPwAFQlOUw,3641
|
|
3
3
|
hatch_cpp/hooks.py,sha256=SQkF5WJIgzw-8rvlTzuQvBqdP6K3fHgnh6CZOZFag50,203
|
|
4
|
-
hatch_cpp/plugin.py,sha256=
|
|
4
|
+
hatch_cpp/plugin.py,sha256=pywarl9lNXMMYmYa0OMT2Q3VQGvViusaa0-tZbMA1W4,4523
|
|
5
5
|
hatch_cpp/utils.py,sha256=lxd3U3aMYsTS6DYMc1y17MR16LzgRzv92f_xh87LSg8,297
|
|
6
|
+
hatch_cpp/tests/test_hatch_build.py,sha256=q2IKTFi3Pq99UsOyL84V-C9VtFUs3ZcA9UlA8lpRW54,1553
|
|
6
7
|
hatch_cpp/tests/test_projects.py,sha256=vs-kHdiHM7pCqM3oGQsSryq5blRi0HyK5QFfHxlJDi8,1773
|
|
7
8
|
hatch_cpp/tests/test_structs.py,sha256=cpzbPLneEbEONzXmPS1S9PL9mbhya4udc4eqTpU9w6w,2576
|
|
8
9
|
hatch_cpp/tests/test_project_basic/pyproject.toml,sha256=eqM1UVpNmJWDfsuO18ZG_VOV9I4tAWgsM5Dhf49X8Nc,694
|
|
@@ -11,7 +12,7 @@ hatch_cpp/tests/test_project_basic/cpp/project/basic.hpp,sha256=SO5GhPj8k3RzWrfH
|
|
|
11
12
|
hatch_cpp/tests/test_project_basic/project/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
13
|
hatch_cpp/tests/test_project_cmake/CMakeLists.txt,sha256=J6ijT9x9uSuisNEVIdFVgc_AstU9hbmIUbwvdjn_4GU,2795
|
|
13
14
|
hatch_cpp/tests/test_project_cmake/Makefile,sha256=Vfr65pvnktWTUeuvpMWqIxDR-7V9MT4PQAyj-WHG_pI,4357
|
|
14
|
-
hatch_cpp/tests/test_project_cmake/pyproject.toml,sha256=
|
|
15
|
+
hatch_cpp/tests/test_project_cmake/pyproject.toml,sha256=judDNJ0qYM6-ocGXtUEHQlUzyj8GsF5qoJ-jPDsIAdA,815
|
|
15
16
|
hatch_cpp/tests/test_project_cmake/cpp/project/basic.cpp,sha256=gQ2nmdLqIdgaqxSKvkN_vbp6Iv_pAoVIHETXPRnALb0,117
|
|
16
17
|
hatch_cpp/tests/test_project_cmake/cpp/project/basic.hpp,sha256=SO5GhPj8k3RzWrfH37lFSDc8w1Vf3yqTUhxmr1hnoko,422
|
|
17
18
|
hatch_cpp/tests/test_project_cmake/project/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -24,6 +25,10 @@ hatch_cpp/tests/test_project_cmake_vcpkg/cpp/project/basic.cpp,sha256=gQ2nmdLqId
|
|
|
24
25
|
hatch_cpp/tests/test_project_cmake_vcpkg/cpp/project/basic.hpp,sha256=SO5GhPj8k3RzWrfH37lFSDc8w1Vf3yqTUhxmr1hnoko,422
|
|
25
26
|
hatch_cpp/tests/test_project_cmake_vcpkg/project/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
27
|
hatch_cpp/tests/test_project_cmake_vcpkg/project/include/project/basic.hpp,sha256=SO5GhPj8k3RzWrfH37lFSDc8w1Vf3yqTUhxmr1hnoko,422
|
|
28
|
+
hatch_cpp/tests/test_project_hatch_build/pyproject.toml,sha256=CyOB1ZhiqqBQOZJoROVIRew66DVjoN2tIqBlQA-F_V8,812
|
|
29
|
+
hatch_cpp/tests/test_project_hatch_build/cpp/project/basic.cpp,sha256=L4v9AUveWWQX8Z2GMRREsEGLz-A_NCeuX0KiyppDmbc,30
|
|
30
|
+
hatch_cpp/tests/test_project_hatch_build/cpp/project/basic.hpp,sha256=AK2FKdlqBwH5jnRUdJXSbWvRr-gSVsUKSG0PiYNsW7A,155
|
|
31
|
+
hatch_cpp/tests/test_project_hatch_build/project/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
27
32
|
hatch_cpp/tests/test_project_limited_api/pyproject.toml,sha256=k_2y7YpZP5I-KPvKOZLmnHqoKXVE2oVM8fjxtRKoTo0,726
|
|
28
33
|
hatch_cpp/tests/test_project_limited_api/cpp/project/basic.cpp,sha256=gQ2nmdLqIdgaqxSKvkN_vbp6Iv_pAoVIHETXPRnALb0,117
|
|
29
34
|
hatch_cpp/tests/test_project_limited_api/cpp/project/basic.hpp,sha256=SO5GhPj8k3RzWrfH37lFSDc8w1Vf3yqTUhxmr1hnoko,422
|
|
@@ -50,11 +55,11 @@ hatch_cpp/tests/test_project_pybind_vcpkg/cpp/project/basic.cpp,sha256=MT3eCSQKr
|
|
|
50
55
|
hatch_cpp/tests/test_project_pybind_vcpkg/cpp/project/basic.hpp,sha256=LZSfCfhLY_91MBOxtnvDk7DcceO-9GhCHKpMnAjGe18,146
|
|
51
56
|
hatch_cpp/tests/test_project_pybind_vcpkg/project/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
52
57
|
hatch_cpp/toolchains/__init__.py,sha256=anza4tXKxauobWMOUrxX3sEO0qs7sp6VdLXhLae3vkY,64
|
|
53
|
-
hatch_cpp/toolchains/cmake.py,sha256=
|
|
58
|
+
hatch_cpp/toolchains/cmake.py,sha256=VQYYqiOu0ZEF0IBuep35Xad7jryWy04-dHYYf7c0XgY,3331
|
|
54
59
|
hatch_cpp/toolchains/common.py,sha256=nBAGQ9B5a7yNgOgohUCsbnDAJACrdQ8lt5dFyb7IXMs,10076
|
|
55
60
|
hatch_cpp/toolchains/vcpkg.py,sha256=fx9lo5EH3HVqg9Fnh5EO67gNsAXcza9eZz4S-Y8piJ0,2097
|
|
56
|
-
hatch_cpp-0.
|
|
57
|
-
hatch_cpp-0.
|
|
58
|
-
hatch_cpp-0.
|
|
59
|
-
hatch_cpp-0.
|
|
60
|
-
hatch_cpp-0.
|
|
61
|
+
hatch_cpp-0.2.0.dist-info/METADATA,sha256=MVd4nLoYpRqU8nWMxmX1bH5uCjdV2gdOUQX-Gh8UxYw,5906
|
|
62
|
+
hatch_cpp-0.2.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
63
|
+
hatch_cpp-0.2.0.dist-info/entry_points.txt,sha256=RgXfjpD4iwomJQK5n7FnPkXzb5fOnF5v3DI5hbkgVcw,30
|
|
64
|
+
hatch_cpp-0.2.0.dist-info/licenses/LICENSE,sha256=FWyFTpd5xXEz50QpGDtsyIv6dgR2z_dHdoab_Nq_KMw,11452
|
|
65
|
+
hatch_cpp-0.2.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|