hatch-cpp 0.0.0__tar.gz → 0.1.7__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 (49) hide show
  1. hatch_cpp-0.1.7/.gitignore +170 -0
  2. {hatch_cpp-0.0.0 → hatch_cpp-0.1.7}/LICENSE +1 -1
  3. hatch_cpp-0.1.7/PKG-INFO +72 -0
  4. hatch_cpp-0.1.7/README.md +35 -0
  5. hatch_cpp-0.1.7/hatch_cpp/__init__.py +5 -0
  6. hatch_cpp-0.1.7/hatch_cpp/hooks.py +10 -0
  7. hatch_cpp-0.1.7/hatch_cpp/plugin.py +113 -0
  8. hatch_cpp-0.1.7/hatch_cpp/structs.py +319 -0
  9. hatch_cpp-0.1.7/hatch_cpp/tests/test_project_basic/cpp/project/basic.cpp +5 -0
  10. hatch_cpp-0.1.7/hatch_cpp/tests/test_project_basic/cpp/project/basic.hpp +17 -0
  11. hatch_cpp-0.1.7/hatch_cpp/tests/test_project_basic/project/__init__.py +0 -0
  12. hatch_cpp-0.1.7/hatch_cpp/tests/test_project_basic/pyproject.toml +35 -0
  13. hatch_cpp-0.1.7/hatch_cpp/tests/test_project_cmake/CMakeLists.txt +92 -0
  14. hatch_cpp-0.1.7/hatch_cpp/tests/test_project_cmake/Makefile +140 -0
  15. hatch_cpp-0.1.7/hatch_cpp/tests/test_project_cmake/cpp/project/basic.cpp +5 -0
  16. hatch_cpp-0.1.7/hatch_cpp/tests/test_project_cmake/cpp/project/basic.hpp +17 -0
  17. hatch_cpp-0.1.7/hatch_cpp/tests/test_project_cmake/project/__init__.py +0 -0
  18. hatch_cpp-0.1.7/hatch_cpp/tests/test_project_cmake/pyproject.toml +39 -0
  19. hatch_cpp-0.1.7/hatch_cpp/tests/test_project_limited_api/cpp/project/basic.cpp +5 -0
  20. hatch_cpp-0.1.7/hatch_cpp/tests/test_project_limited_api/cpp/project/basic.hpp +17 -0
  21. hatch_cpp-0.1.7/hatch_cpp/tests/test_project_limited_api/project/__init__.py +0 -0
  22. hatch_cpp-0.1.7/hatch_cpp/tests/test_project_limited_api/pyproject.toml +35 -0
  23. hatch_cpp-0.1.7/hatch_cpp/tests/test_project_nanobind/cpp/project/basic.cpp +2 -0
  24. hatch_cpp-0.1.7/hatch_cpp/tests/test_project_nanobind/cpp/project/basic.hpp +7 -0
  25. hatch_cpp-0.1.7/hatch_cpp/tests/test_project_nanobind/project/__init__.py +0 -0
  26. hatch_cpp-0.1.7/hatch_cpp/tests/test_project_nanobind/pyproject.toml +35 -0
  27. hatch_cpp-0.1.7/hatch_cpp/tests/test_project_override_classes/cpp/project/basic.cpp +5 -0
  28. hatch_cpp-0.1.7/hatch_cpp/tests/test_project_override_classes/cpp/project/basic.hpp +17 -0
  29. hatch_cpp-0.1.7/hatch_cpp/tests/test_project_override_classes/project/__init__.py +0 -0
  30. hatch_cpp-0.1.7/hatch_cpp/tests/test_project_override_classes/pyproject.toml +37 -0
  31. hatch_cpp-0.1.7/hatch_cpp/tests/test_project_pybind/cpp/project/basic.cpp +6 -0
  32. hatch_cpp-0.1.7/hatch_cpp/tests/test_project_pybind/cpp/project/basic.hpp +9 -0
  33. hatch_cpp-0.1.7/hatch_cpp/tests/test_project_pybind/project/__init__.py +0 -0
  34. hatch_cpp-0.1.7/hatch_cpp/tests/test_project_pybind/pyproject.toml +35 -0
  35. hatch_cpp-0.1.7/hatch_cpp/tests/test_projects.py +54 -0
  36. hatch_cpp-0.1.7/hatch_cpp/tests/test_structs.py +48 -0
  37. hatch_cpp-0.1.7/hatch_cpp/toolchains/__init__.py +0 -0
  38. hatch_cpp-0.1.7/hatch_cpp/toolchains/cmake.py +0 -0
  39. hatch_cpp-0.1.7/hatch_cpp/utils.py +12 -0
  40. hatch_cpp-0.1.7/pyproject.toml +132 -0
  41. hatch_cpp-0.0.0/PKG-INFO +0 -224
  42. hatch_cpp-0.0.0/README.md +0 -1
  43. hatch_cpp-0.0.0/hatch_cpp.egg-info/PKG-INFO +0 -224
  44. hatch_cpp-0.0.0/hatch_cpp.egg-info/SOURCES.txt +0 -8
  45. hatch_cpp-0.0.0/hatch_cpp.egg-info/dependency_links.txt +0 -1
  46. hatch_cpp-0.0.0/hatch_cpp.egg-info/top_level.txt +0 -1
  47. hatch_cpp-0.0.0/pyproject.toml +0 -29
  48. hatch_cpp-0.0.0/setup.cfg +0 -4
  49. hatch_cpp-0.0.0/setup.py +0 -1
@@ -0,0 +1,170 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.a
8
+ *.so
9
+ *.obj
10
+ *.dll
11
+ *.exp
12
+ *.lib
13
+
14
+ # Distribution / packaging
15
+ .Python
16
+ env/
17
+ build/
18
+ develop-eggs/
19
+ dist/
20
+ downloads/
21
+ eggs/
22
+ .eggs/
23
+ include/
24
+ lib/
25
+ lib64/
26
+ parts/
27
+ sdist/
28
+ var/
29
+ *.egg-info/
30
+ .installed.cfg
31
+ *.egg
32
+
33
+ # PyInstaller
34
+ # Usually these files are written by a python script from a template
35
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
36
+ *.manifest
37
+ *.spec
38
+
39
+ # Installer logs
40
+ pip-log.txt
41
+ pip-delete-this-directory.txt
42
+
43
+ # Unit test / coverage reports
44
+ htmlcov/
45
+ .tox/
46
+ .coverage
47
+ .coverage.*
48
+ .cache
49
+ python_junit.xml
50
+ junit.xml
51
+ nosetests.xml
52
+ coverage.xml
53
+ *,cover
54
+ .hypothesis/
55
+ .pytest_cache
56
+ .ruff_cache
57
+ js/playwright-report
58
+
59
+ # Translations
60
+ *.mo
61
+ *.pot
62
+
63
+ # Django stuff:
64
+ *.log
65
+ local_settings.py
66
+
67
+ # Flask instance folder
68
+ instance/
69
+
70
+ # Scrapy stuff:
71
+ .scrapy
72
+
73
+ # Sphinx documentation
74
+ docs/_build/
75
+ docs/source
76
+
77
+ # PyBuilder
78
+ target/
79
+
80
+ # IPython Notebook
81
+ .ipynb_checkpoints
82
+ *.ipynb
83
+ .autoversion
84
+
85
+ # pyenv
86
+ .python-version
87
+
88
+ # celery beat schedule file
89
+ celerybeat-schedule
90
+
91
+ # dotenv
92
+ .env
93
+
94
+ # virtualenv
95
+ venv/
96
+ ENV/
97
+
98
+ # Spyder project settings
99
+ .spyderproject
100
+
101
+ # Rope project settings
102
+ .ropeproject
103
+
104
+ # =========================
105
+ # Operating System Files
106
+ # =========================
107
+
108
+ # OSX
109
+ # =========================
110
+
111
+ .DS_Store
112
+ .AppleDouble
113
+ .LSOverride
114
+
115
+ # Thumbnails
116
+ ._*
117
+
118
+ # Files that might appear in the root of a volume
119
+ .DocumentRevisions-V100
120
+ .fseventsd
121
+ .Spotlight-V100
122
+ .TemporaryItems
123
+ .Trashes
124
+ .VolumeIcon.icns
125
+
126
+ # Directories potentially created on remote AFP share
127
+ .AppleDB
128
+ .AppleDesktop
129
+ Network Trash Folder
130
+ Temporary Items
131
+ .apdisk
132
+
133
+ # Windows
134
+ # =========================
135
+
136
+ # Windows image file caches
137
+ Thumbs.db
138
+ ehthumbs.db
139
+
140
+ # Folder config file
141
+ Desktop.ini
142
+
143
+ # Recycle Bin used on file shares
144
+ $RECYCLE.BIN/
145
+
146
+ # Windows Installer files
147
+ *.cab
148
+ *.msi
149
+ *.msm
150
+ *.msp
151
+
152
+ # Windows shortcuts
153
+ *.lnk
154
+
155
+
156
+ # NPM
157
+ # ----
158
+ **/node_modules/
159
+
160
+ # Coverage data
161
+ # -------------
162
+ **/coverage/
163
+
164
+ # Notebook and lab extensions
165
+
166
+ nbprint/extension/*
167
+ nbprint/templates/nbprint/static/*
168
+ nbprint/voila/static/*
169
+ tmp.html
170
+ examples/output/
@@ -186,7 +186,7 @@
186
186
  same "printed page" as the copyright notice for easier
187
187
  identification within third-party archives.
188
188
 
189
- Copyright 2024, the hatch-cpp authors
189
+ Copyright [yyyy] [name of copyright owner]
190
190
 
191
191
  Licensed under the Apache License, Version 2.0 (the "License");
192
192
  you may not use this file except in compliance with the License.
@@ -0,0 +1,72 @@
1
+ Metadata-Version: 2.4
2
+ Name: hatch-cpp
3
+ Version: 0.1.7
4
+ Summary: Hatch plugin for C++ builds
5
+ Project-URL: Repository, https://github.com/python-project-templates/hatch-cpp
6
+ Project-URL: Homepage, https://github.com/python-project-templates/hatch-cpp
7
+ Author-email: the hatch-cpp authors <t.paine154@gmail.com>
8
+ License: Apache-2.0
9
+ License-File: LICENSE
10
+ Keywords: build,c++,cmake,cpp,hatch,python
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Programming Language :: Python
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: Implementation :: CPython
20
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
21
+ Requires-Python: >=3.9
22
+ Requires-Dist: hatchling>=1.20
23
+ Requires-Dist: pydantic
24
+ Provides-Extra: develop
25
+ Requires-Dist: build; extra == 'develop'
26
+ Requires-Dist: bump-my-version; extra == 'develop'
27
+ Requires-Dist: check-manifest; extra == 'develop'
28
+ Requires-Dist: nanobind; extra == 'develop'
29
+ Requires-Dist: pybind11; extra == 'develop'
30
+ Requires-Dist: pytest; extra == 'develop'
31
+ Requires-Dist: pytest-cov; extra == 'develop'
32
+ Requires-Dist: ruff<0.9,>=0.3; extra == 'develop'
33
+ Requires-Dist: toml; extra == 'develop'
34
+ Requires-Dist: twine; extra == 'develop'
35
+ Requires-Dist: wheel; extra == 'develop'
36
+ Description-Content-Type: text/markdown
37
+
38
+ # hatch-cpp
39
+
40
+ Hatch plugin for C++ builds
41
+
42
+ [![Build Status](https://github.com/python-project-templates/hatch-cpp/actions/workflows/build.yml/badge.svg?branch=main&event=push)](https://github.com/python-project-templates/hatch-cpp/actions/workflows/build.yml)
43
+ [![codecov](https://codecov.io/gh/python-project-templates/hatch-cpp/branch/main/graph/badge.svg)](https://codecov.io/gh/python-project-templates/hatch-cpp)
44
+ [![License](https://img.shields.io/github/license/python-project-templates/hatch-cpp)](https://github.com/python-project-templates/hatch-cpp)
45
+ [![PyPI](https://img.shields.io/pypi/v/hatch-cpp.svg)](https://pypi.python.org/pypi/hatch-cpp)
46
+
47
+ ## Overview
48
+
49
+ A simple, extensible C++ build plugin for [hatch](https://hatch.pypa.io/latest/).
50
+
51
+ ```toml
52
+ [tool.hatch.build.hooks.hatch-cpp]
53
+ libraries = [
54
+ {name = "project/extension", sources = ["cpp/project/basic.cpp"], include-dirs = ["cpp"]}
55
+ ]
56
+ ```
57
+
58
+ For more complete systems, see:
59
+ - [scikit-build-core](https://github.com/scikit-build/scikit-build-core)
60
+ - [setuptools](https://setuptools.pypa.io/en/latest/userguide/ext_modules.html)
61
+
62
+ ## Environment Variables
63
+ | Name | Default | Description |
64
+ |:-----|:--------|:------------|
65
+ |`CC`| | |
66
+ |`CXX`| | |
67
+ |`LD`| | |
68
+ |`HATCH_CPP_PLATFORM`| | |
69
+ |`HATCH_CPP_DISABLE_CCACHE`| | |
70
+
71
+ > [!NOTE]
72
+ > This library was generated using [copier](https://copier.readthedocs.io/en/stable/) from the [Base Python Project Template repository](https://github.com/python-project-templates/base).
@@ -0,0 +1,35 @@
1
+ # hatch-cpp
2
+
3
+ Hatch plugin for C++ builds
4
+
5
+ [![Build Status](https://github.com/python-project-templates/hatch-cpp/actions/workflows/build.yml/badge.svg?branch=main&event=push)](https://github.com/python-project-templates/hatch-cpp/actions/workflows/build.yml)
6
+ [![codecov](https://codecov.io/gh/python-project-templates/hatch-cpp/branch/main/graph/badge.svg)](https://codecov.io/gh/python-project-templates/hatch-cpp)
7
+ [![License](https://img.shields.io/github/license/python-project-templates/hatch-cpp)](https://github.com/python-project-templates/hatch-cpp)
8
+ [![PyPI](https://img.shields.io/pypi/v/hatch-cpp.svg)](https://pypi.python.org/pypi/hatch-cpp)
9
+
10
+ ## Overview
11
+
12
+ A simple, extensible C++ build plugin for [hatch](https://hatch.pypa.io/latest/).
13
+
14
+ ```toml
15
+ [tool.hatch.build.hooks.hatch-cpp]
16
+ libraries = [
17
+ {name = "project/extension", sources = ["cpp/project/basic.cpp"], include-dirs = ["cpp"]}
18
+ ]
19
+ ```
20
+
21
+ For more complete systems, see:
22
+ - [scikit-build-core](https://github.com/scikit-build/scikit-build-core)
23
+ - [setuptools](https://setuptools.pypa.io/en/latest/userguide/ext_modules.html)
24
+
25
+ ## Environment Variables
26
+ | Name | Default | Description |
27
+ |:-----|:--------|:------------|
28
+ |`CC`| | |
29
+ |`CXX`| | |
30
+ |`LD`| | |
31
+ |`HATCH_CPP_PLATFORM`| | |
32
+ |`HATCH_CPP_DISABLE_CCACHE`| | |
33
+
34
+ > [!NOTE]
35
+ > This library was generated using [copier](https://copier.readthedocs.io/en/stable/) from the [Base Python Project Template repository](https://github.com/python-project-templates/base).
@@ -0,0 +1,5 @@
1
+ __version__ = "0.1.7"
2
+
3
+ from .hooks import hatch_register_build_hook
4
+ from .plugin import HatchCppBuildHook
5
+ from .structs import *
@@ -0,0 +1,10 @@
1
+ from typing import Type
2
+
3
+ from hatchling.plugin import hookimpl
4
+
5
+ from .plugin import HatchCppBuildHook
6
+
7
+
8
+ @hookimpl
9
+ def hatch_register_build_hook() -> Type[HatchCppBuildHook]:
10
+ return HatchCppBuildHook
@@ -0,0 +1,113 @@
1
+ from __future__ import annotations
2
+
3
+ from logging import getLogger
4
+ from os import getenv
5
+ from pathlib import Path
6
+ from platform import machine as platform_machine
7
+ from sys import platform as sys_platform, version_info
8
+ from typing import Any
9
+
10
+ from hatchling.builders.hooks.plugin.interface import BuildHookInterface
11
+
12
+ from .structs import HatchCppBuildConfig, HatchCppBuildPlan
13
+ from .utils import import_string
14
+
15
+ __all__ = ("HatchCppBuildHook",)
16
+
17
+
18
+ class HatchCppBuildHook(BuildHookInterface[HatchCppBuildConfig]):
19
+ """The hatch-cpp build hook."""
20
+
21
+ PLUGIN_NAME = "hatch-cpp"
22
+ _logger = getLogger(__name__)
23
+
24
+ def initialize(self, version: str, build_data: dict[str, Any]) -> None:
25
+ """Initialize the plugin."""
26
+ # Log some basic information
27
+ project_name = self.metadata.config["project"]["name"]
28
+ self._logger.info("Initializing hatch-cpp plugin version %s", version)
29
+ self._logger.info(f"Running hatch-cpp: {project_name}")
30
+
31
+ # Only run if creating wheel
32
+ # TODO: Add support for specify sdist-plan
33
+ if self.target_name != "wheel":
34
+ self._logger.info("ignoring target name %s", self.target_name)
35
+ return
36
+
37
+ # Skip if SKIP_HATCH_CPP is set
38
+ # TODO: Support CLI once https://github.com/pypa/hatch/pull/1743
39
+ if getenv("SKIP_HATCH_CPP"):
40
+ self._logger.info("Skipping the build hook since SKIP_HATCH_CPP was set")
41
+ return
42
+
43
+ # Get build config class or use default
44
+ build_config_class = import_string(self.config["build-config-class"]) if "build-config-class" in self.config else HatchCppBuildConfig
45
+
46
+ # Instantiate build config
47
+ config = build_config_class(name=project_name, **self.config)
48
+
49
+ # Get build plan class or use default
50
+ build_plan_class = import_string(self.config["build-plan-class"]) if "build-plan-class" in self.config else HatchCppBuildPlan
51
+
52
+ # Instantiate builder
53
+ build_plan = build_plan_class(**config.model_dump())
54
+
55
+ # Generate commands
56
+ build_plan.generate()
57
+
58
+ # Log commands if in verbose mode
59
+ if config.verbose:
60
+ for command in build_plan.commands:
61
+ self._logger.warning(command)
62
+
63
+ # Execute build plan
64
+ build_plan.execute()
65
+
66
+ # Perform any cleanup actions
67
+ build_plan.cleanup()
68
+
69
+ if build_plan.libraries:
70
+ # force include libraries
71
+ for library in build_plan.libraries:
72
+ name = library.get_qualified_name(build_plan.platform.platform)
73
+ build_data["force_include"][name] = name
74
+
75
+ build_data["pure_python"] = False
76
+ machine = platform_machine()
77
+ version_major = version_info.major
78
+ version_minor = version_info.minor
79
+ if "darwin" in sys_platform:
80
+ os_name = "macosx_11_0"
81
+ elif "linux" in sys_platform:
82
+ os_name = "linux"
83
+ else:
84
+ os_name = "win"
85
+ if all([lib.py_limited_api for lib in build_plan.libraries]):
86
+ build_data["tag"] = f"cp{version_major}{version_minor}-abi3-{os_name}_{machine}"
87
+ else:
88
+ build_data["tag"] = f"cp{version_major}{version_minor}-cp{version_major}{version_minor}-{os_name}_{machine}"
89
+ else:
90
+ build_data["pure_python"] = False
91
+ machine = platform_machine()
92
+ version_major = version_info.major
93
+ version_minor = version_info.minor
94
+ # TODO abi3
95
+ if "darwin" in sys_platform:
96
+ os_name = "macosx_11_0"
97
+ elif "linux" in sys_platform:
98
+ os_name = "linux"
99
+ else:
100
+ os_name = "win"
101
+ build_data["tag"] = f"cp{version_major}{version_minor}-cp{version_major}{version_minor}-{os_name}_{machine}"
102
+
103
+ # force include libraries
104
+ for path in Path(".").rglob("*"):
105
+ if path.is_dir():
106
+ continue
107
+ if str(path).startswith(str(build_plan.cmake.build)) or str(path).startswith("dist"):
108
+ continue
109
+ if path.suffix in (".pyd", ".dll", ".so", ".dylib"):
110
+ build_data["force_include"][str(path)] = str(path)
111
+
112
+ for path in build_data["force_include"]:
113
+ self._logger.warning(f"Force include: {path}")