cpp-pd-code-simplify-interface 0.1.4__tar.gz → 0.1.6__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cpp-pd-code-simplify-interface
3
- Version: 0.1.4
3
+ Version: 0.1.6
4
4
  Summary: Python interface for cpp-pd-code-simplify with runtime C++ compilation.
5
5
  License-Expression: MIT
6
6
  Author: GGN_2015
@@ -34,6 +34,11 @@ use, the package compiles a cached local dynamic library through
34
34
  `cpp-simple-interface`; later calls reuse that library through `ctypes`. A C++14
35
35
  compiler compatible with `g++` must be available at runtime.
36
36
 
37
+ The core C++ source and header are not stored as permanent generated copies in
38
+ this subproject. The custom Poetry build backend syncs them from the repository
39
+ root during `poetry build`, embeds them in the wheel and sdist, then removes the
40
+ temporary copies from the working tree.
41
+
37
42
  Calls use the C++ library's default preprocessing pipeline: R1-move removal
38
43
  followed by nugatory-crossing removal, then iterative mid-simplification.
39
44
 
@@ -51,7 +56,8 @@ The default `max_paths=-1` uses deterministic heuristic green-path sampling in
51
56
  the C++ backend. Use `ban_heuristic=True` to request exhaustive green-path
52
57
  enumeration for a manageable input. Use `reduction_round=K` to cap applied
53
58
  mid-simplification rounds; the default `-1` runs until stable. Use
54
- `verbose=True` to forward C++ progress logs to stderr.
59
+ `verbose=True` to forward timestamped C++ progress logs to stderr. Verbose log
60
+ lines use local wall-clock time in `YYYY-MM-DD HH:MM:SS` format.
55
61
 
56
62
  Batch use:
57
63
 
@@ -14,6 +14,11 @@ use, the package compiles a cached local dynamic library through
14
14
  `cpp-simple-interface`; later calls reuse that library through `ctypes`. A C++14
15
15
  compiler compatible with `g++` must be available at runtime.
16
16
 
17
+ The core C++ source and header are not stored as permanent generated copies in
18
+ this subproject. The custom Poetry build backend syncs them from the repository
19
+ root during `poetry build`, embeds them in the wheel and sdist, then removes the
20
+ temporary copies from the working tree.
21
+
17
22
  Calls use the C++ library's default preprocessing pipeline: R1-move removal
18
23
  followed by nugatory-crossing removal, then iterative mid-simplification.
19
24
 
@@ -31,7 +36,8 @@ The default `max_paths=-1` uses deterministic heuristic green-path sampling in
31
36
  the C++ backend. Use `ban_heuristic=True` to request exhaustive green-path
32
37
  enumeration for a manageable input. Use `reduction_round=K` to cap applied
33
38
  mid-simplification rounds; the default `-1` runs until stable. Use
34
- `verbose=True` to forward C++ progress logs to stderr.
39
+ `verbose=True` to forward timestamped C++ progress logs to stderr. Verbose log
40
+ lines use local wall-clock time in `YYYY-MM-DD HH:MM:SS` format.
35
41
 
36
42
  Batch use:
37
43
 
@@ -15,17 +15,12 @@ from poetry.core.masonry import api as poetry_api
15
15
  PROJECT_ROOT = Path(__file__).resolve().parents[1]
16
16
  REPO_ROOT = PROJECT_ROOT.parents[1]
17
17
 
18
- SOURCE_FILES = [
18
+ EMBEDDED_SOURCE_FILES = [
19
19
  (
20
20
  REPO_ROOT / "src" / "pdcode_simplify.cpp",
21
21
  PROJECT_ROOT / "cpp_pd_code_simplify_interface" / "data" / "src" / "pdcode_simplify.cpp",
22
22
  "cpp_pd_code_simplify_interface/data/src/pdcode_simplify.cpp",
23
23
  ),
24
- (
25
- PROJECT_ROOT / "cpp_pd_code_simplify_interface" / "data" / "src" / "native_interface.cpp",
26
- PROJECT_ROOT / "cpp_pd_code_simplify_interface" / "data" / "src" / "native_interface.cpp",
27
- "cpp_pd_code_simplify_interface/data/src/native_interface.cpp",
28
- ),
29
24
  (
30
25
  REPO_ROOT / "include" / "pdcode_simplify" / "pdcode_simplify.hpp",
31
26
  PROJECT_ROOT
@@ -38,23 +33,39 @@ SOURCE_FILES = [
38
33
  ),
39
34
  ]
40
35
 
36
+ STATIC_SOURCE_FILES = [
37
+ (
38
+ PROJECT_ROOT / "cpp_pd_code_simplify_interface" / "data" / "src" / "native_interface.cpp",
39
+ PROJECT_ROOT / "cpp_pd_code_simplify_interface" / "data" / "src" / "native_interface.cpp",
40
+ "cpp_pd_code_simplify_interface/data/src/native_interface.cpp",
41
+ ),
42
+ ]
43
+
44
+ SOURCE_FILES = EMBEDDED_SOURCE_FILES + STATIC_SOURCE_FILES
45
+
41
46
 
42
47
  def _sync_cpp_sources() -> None:
43
48
  missing = []
44
- for source, target, _ in SOURCE_FILES:
49
+ for source, target, _ in EMBEDDED_SOURCE_FILES:
45
50
  if source.exists():
46
- if source.resolve() != target.resolve():
51
+ if (
52
+ source.resolve() != target.resolve()
53
+ and (not target.exists() or source.read_bytes() != target.read_bytes())
54
+ ):
47
55
  target.parent.mkdir(parents=True, exist_ok=True)
48
56
  shutil.copyfile(source, target)
49
57
  elif not target.exists():
50
58
  missing.append((source, target))
59
+ for source, target, _ in STATIC_SOURCE_FILES:
60
+ if not source.exists() and not target.exists():
61
+ missing.append((source, target))
51
62
  if missing:
52
63
  details = ", ".join(f"{source} or {target}" for source, target in missing)
53
64
  raise FileNotFoundError(f"cpp-pd-code-simplify source files were not found: {details}")
54
65
 
55
66
 
56
67
  def _clean_cpp_sources() -> None:
57
- for source, target, _ in SOURCE_FILES:
68
+ for source, target, _ in EMBEDDED_SOURCE_FILES:
58
69
  if source.exists() and target.exists() and source.resolve() != target.resolve():
59
70
  target.unlink()
60
71
 
@@ -2,7 +2,9 @@
2
2
 
3
3
  #include <cstdlib>
4
4
  #include <cstring>
5
+ #include <ctime>
5
6
  #include <exception>
7
+ #include <iomanip>
6
8
  #include <iostream>
7
9
  #include <sstream>
8
10
  #include <string>
@@ -10,6 +12,24 @@
10
12
 
11
13
  namespace {
12
14
 
15
+ std::string local_timestamp() {
16
+ const std::time_t now = std::time(nullptr);
17
+ std::tm local{};
18
+ #if defined(_WIN32)
19
+ localtime_s(&local, &now);
20
+ #else
21
+ localtime_r(&now, &local);
22
+ #endif
23
+ std::ostringstream out;
24
+ out << std::put_time(&local, "%Y-%m-%d %H:%M:%S");
25
+ return out.str();
26
+ }
27
+
28
+ void print_progress_log(const std::string& message) {
29
+ std::cerr << "[pdcode-simplify " << local_timestamp() << "] "
30
+ << message << '\n';
31
+ }
32
+
13
33
  bool denotes_crossingless_unknot(const std::string& text) {
14
34
  std::string compact;
15
35
  for (char c : text) {
@@ -129,7 +149,7 @@ char* pdcode_simplify_run_json(
129
149
  options.ban_heuristic = ban_heuristic != 0;
130
150
  options.verbose = verbose != 0;
131
151
  options.progress = [](const std::string& message) {
132
- std::cerr << "[pdcode-simplify] " << message << '\n';
152
+ print_progress_log(message);
133
153
  };
134
154
 
135
155
  const pdcode_simplify::PDCode code = pdcode_simplify::parse_pd_code(text);
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "cpp-pd-code-simplify-interface"
3
- version = "0.1.4"
3
+ version = "0.1.6"
4
4
  description = "Python interface for cpp-pd-code-simplify with runtime C++ compilation."
5
5
  authors = [
6
6
  {name = "GGN_2015", email = "neko@jlulug.org"}
@@ -24,9 +24,7 @@ cpp-pd-code-simplify-interface = "cpp_pd_code_simplify_interface.main:main"
24
24
  packages = [{ include = "cpp_pd_code_simplify_interface" }]
25
25
  include = [
26
26
  { path = "build_backend/cpp_pd_code_simplify_interface_build_backend.py", format = ["sdist"] },
27
- { path = "cpp_pd_code_simplify_interface/data/src/native_interface.cpp", format = ["sdist", "wheel"] },
28
- { path = "cpp_pd_code_simplify_interface/data/src/pdcode_simplify.cpp", format = ["sdist", "wheel"] },
29
- { path = "cpp_pd_code_simplify_interface/data/include/pdcode_simplify/pdcode_simplify.hpp", format = ["sdist", "wheel"] }
27
+ { path = "cpp_pd_code_simplify_interface/data/src/native_interface.cpp", format = ["sdist", "wheel"] }
30
28
  ]
31
29
 
32
30
  [build-system]