hatch-cpp 0.1.0__tar.gz → 0.1.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.
- {hatch_cpp-0.1.0 → hatch_cpp-0.1.1}/.gitignore +5 -0
- {hatch_cpp-0.1.0 → hatch_cpp-0.1.1}/PKG-INFO +1 -1
- hatch_cpp-0.1.1/hatch_cpp/__init__.py +1 -0
- {hatch_cpp-0.1.0 → hatch_cpp-0.1.1}/hatch_cpp/plugin.py +6 -2
- {hatch_cpp-0.1.0 → hatch_cpp-0.1.1}/hatch_cpp/structs.py +24 -11
- {hatch_cpp-0.1.0 → hatch_cpp-0.1.1}/hatch_cpp/tests/test_project_basic.py +7 -1
- {hatch_cpp-0.1.0 → hatch_cpp-0.1.1}/pyproject.toml +2 -2
- hatch_cpp-0.1.0/hatch_cpp/__init__.py +0 -1
- {hatch_cpp-0.1.0 → hatch_cpp-0.1.1}/LICENSE +0 -0
- {hatch_cpp-0.1.0 → hatch_cpp-0.1.1}/README.md +0 -0
- {hatch_cpp-0.1.0 → hatch_cpp-0.1.1}/hatch_cpp/__main__.py +0 -0
- {hatch_cpp-0.1.0 → hatch_cpp-0.1.1}/hatch_cpp/hooks.py +0 -0
- {hatch_cpp-0.1.0 → hatch_cpp-0.1.1}/hatch_cpp/tests/test_all.py +0 -0
- {hatch_cpp-0.1.0 → hatch_cpp-0.1.1}/hatch_cpp/tests/test_project_basic/basic_project/__init__.py +0 -0
- {hatch_cpp-0.1.0 → hatch_cpp-0.1.1}/hatch_cpp/tests/test_project_basic/cpp/basic-project/basic.cpp +0 -0
- {hatch_cpp-0.1.0 → hatch_cpp-0.1.1}/hatch_cpp/tests/test_project_basic/cpp/basic-project/basic.hpp +0 -0
- {hatch_cpp-0.1.0 → hatch_cpp-0.1.1}/hatch_cpp/tests/test_project_basic/pyproject.toml +0 -0
- {hatch_cpp-0.1.0 → hatch_cpp-0.1.1}/hatch_cpp/toolchains/__init__.py +0 -0
- {hatch_cpp-0.1.0 → hatch_cpp-0.1.1}/hatch_cpp/toolchains/cmake.py +0 -0
- {hatch_cpp-0.1.0 → hatch_cpp-0.1.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.
|
|
3
|
+
Version: 0.1.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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.1"
|
|
@@ -43,10 +43,14 @@ class HatchCppBuildHook(BuildHookInterface[HatchCppBuildConfig]):
|
|
|
43
43
|
libraries = [HatchCppLibrary(**library_kwargs) for library_kwargs in library_kwargs]
|
|
44
44
|
platform = HatchCppPlatform.default()
|
|
45
45
|
if config.toolchain == "raw":
|
|
46
|
-
# g++ basic-project/basic.cpp -I. -I/opt/homebrew/opt/python@3.11/Frameworks/Python.framework/Versions/3.11/include/python3.11/ -undefined dynamic_lookup -fPIC -shared -o extension.so
|
|
47
46
|
build_plan = HatchCppBuildPlan(libraries=libraries, platform=platform)
|
|
48
47
|
build_plan.generate()
|
|
49
|
-
|
|
48
|
+
if config.verbose:
|
|
49
|
+
for command in build_plan.commands:
|
|
50
|
+
self._logger.info(command)
|
|
51
|
+
build_plan.execute()
|
|
52
|
+
build_plan.cleanup()
|
|
53
|
+
|
|
50
54
|
# build_kwargs = config.build_kwargs
|
|
51
55
|
# if version == "editable":
|
|
52
56
|
# build_kwargs = config.editable_build_kwargs or build_kwargs
|
|
@@ -2,7 +2,8 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from dataclasses import dataclass, field
|
|
4
4
|
from os import environ, system
|
|
5
|
-
from
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from sys import executable, platform as sys_platform
|
|
6
7
|
from sysconfig import get_path
|
|
7
8
|
from typing import Literal
|
|
8
9
|
|
|
@@ -80,7 +81,7 @@ class HatchCppPlatform(object):
|
|
|
80
81
|
raise Exception(f"Unrecognized toolchain: {CC}, {CXX}")
|
|
81
82
|
return HatchCppPlatform(cc=CC, cxx=CXX, platform=platform, toolchain=toolchain)
|
|
82
83
|
|
|
83
|
-
def
|
|
84
|
+
def get_compile_flags(self, library: HatchCppLibrary) -> str:
|
|
84
85
|
flags = ""
|
|
85
86
|
if self.toolchain == "gcc":
|
|
86
87
|
flags = f"-I{get_path('include')}"
|
|
@@ -109,21 +110,28 @@ class HatchCppPlatform(object):
|
|
|
109
110
|
elif self.toolchain == "msvc":
|
|
110
111
|
flags = f"/I{get_path('include')} "
|
|
111
112
|
flags += " ".join(f"/I{d}" for d in library.include_dirs)
|
|
112
|
-
flags += " /LD"
|
|
113
113
|
flags += " " + " ".join(library.extra_compile_args)
|
|
114
114
|
flags += " " + " ".join(library.extra_link_args)
|
|
115
115
|
flags += " " + " ".join(library.extra_objects)
|
|
116
|
-
flags += " " + " ".join(f"{lib}.lib" for lib in library.libraries)
|
|
117
|
-
flags += " " + " ".join(f"/LIBPATH:{lib}" for lib in library.library_dirs)
|
|
118
116
|
flags += " " + " ".join(f"/D{macro}" for macro in library.define_macros)
|
|
119
117
|
flags += " " + " ".join(f"/U{macro}" for macro in library.undef_macros)
|
|
120
|
-
flags +=
|
|
121
|
-
flags += f" /
|
|
118
|
+
flags += " /EHsc /DWIN32 /LD"
|
|
119
|
+
flags += f" /Fo:{library.name}.obj"
|
|
120
|
+
flags += f" /Fe:{library.name}.pyd"
|
|
121
|
+
flags += " /link /DLL"
|
|
122
|
+
if (Path(executable).parent / "libs").exists():
|
|
123
|
+
flags += f" /LIBPATH:{str(Path(executable).parent / 'libs')}"
|
|
124
|
+
flags += " " + " ".join(f"{lib}.lib" for lib in library.libraries)
|
|
125
|
+
flags += " " + " ".join(f"/LIBPATH:{lib}" for lib in library.library_dirs)
|
|
122
126
|
# clean
|
|
123
127
|
while flags.count(" "):
|
|
124
128
|
flags = flags.replace(" ", " ")
|
|
125
129
|
return flags
|
|
126
130
|
|
|
131
|
+
def get_link_flags(self, library: HatchCppLibrary) -> str:
|
|
132
|
+
flags = ""
|
|
133
|
+
return flags
|
|
134
|
+
|
|
127
135
|
|
|
128
136
|
@dataclass
|
|
129
137
|
class HatchCppBuildPlan(object):
|
|
@@ -134,13 +142,18 @@ class HatchCppBuildPlan(object):
|
|
|
134
142
|
def generate(self):
|
|
135
143
|
self.commands = []
|
|
136
144
|
for library in self.libraries:
|
|
137
|
-
flags = self.platform.
|
|
145
|
+
flags = self.platform.get_compile_flags(library)
|
|
138
146
|
self.commands.append(f"{self.platform.cc} {' '.join(library.sources)} {flags}")
|
|
139
147
|
return self.commands
|
|
140
148
|
|
|
141
|
-
def execute(self
|
|
149
|
+
def execute(self):
|
|
142
150
|
for command in self.commands:
|
|
143
|
-
if verbose:
|
|
144
|
-
print(f"Running command: {command}")
|
|
145
151
|
system(command)
|
|
146
152
|
return self.commands
|
|
153
|
+
|
|
154
|
+
def cleanup(self):
|
|
155
|
+
if self.platform.platform == "win32":
|
|
156
|
+
for library in self.libraries:
|
|
157
|
+
temp_obj = Path(f"{library.name}.obj")
|
|
158
|
+
if temp_obj.exists():
|
|
159
|
+
temp_obj.unlink()
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
from os import listdir
|
|
2
|
+
from pathlib import Path
|
|
2
3
|
from shutil import rmtree
|
|
3
4
|
from subprocess import check_output
|
|
4
|
-
from sys import platform
|
|
5
|
+
from sys import path, platform
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
class TestProject:
|
|
@@ -20,3 +21,8 @@ class TestProject:
|
|
|
20
21
|
assert "extension.pyd" in listdir("hatch_cpp/tests/test_project_basic/basic_project")
|
|
21
22
|
else:
|
|
22
23
|
assert "extension.so" in listdir("hatch_cpp/tests/test_project_basic/basic_project")
|
|
24
|
+
here = Path(__file__).parent / "test_project_basic"
|
|
25
|
+
path.insert(0, str(here))
|
|
26
|
+
import basic_project.extension
|
|
27
|
+
|
|
28
|
+
assert basic_project.extension.hello() == "A string"
|
|
@@ -8,7 +8,7 @@ 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.
|
|
11
|
+
version = "0.1.1"
|
|
12
12
|
requires-python = ">=3.9"
|
|
13
13
|
keywords = [
|
|
14
14
|
"hatch",
|
|
@@ -59,7 +59,7 @@ Repository = "https://github.com/python-project-templates/hatch-cpp"
|
|
|
59
59
|
Homepage = "https://github.com/python-project-templates/hatch-cpp"
|
|
60
60
|
|
|
61
61
|
[tool.bumpversion]
|
|
62
|
-
current_version = "0.1.
|
|
62
|
+
current_version = "0.1.1"
|
|
63
63
|
commit = true
|
|
64
64
|
tag = false
|
|
65
65
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.1.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hatch_cpp-0.1.0 → hatch_cpp-0.1.1}/hatch_cpp/tests/test_project_basic/basic_project/__init__.py
RENAMED
|
File without changes
|
{hatch_cpp-0.1.0 → hatch_cpp-0.1.1}/hatch_cpp/tests/test_project_basic/cpp/basic-project/basic.cpp
RENAMED
|
File without changes
|
{hatch_cpp-0.1.0 → hatch_cpp-0.1.1}/hatch_cpp/tests/test_project_basic/cpp/basic-project/basic.hpp
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|