scons-xo-exts-lib 1.0.0__tar.gz → 1.0.2__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.

Potentially problematic release.


This version of scons-xo-exts-lib might be problematic. Click here for more details.

Files changed (23) hide show
  1. {scons_xo_exts_lib-1.0.0 → scons_xo_exts_lib-1.0.2}/PKG-INFO +1 -1
  2. scons_xo_exts_lib-1.0.2/src/scons_xo_exts_lib/Builders/dune.py +109 -0
  3. {scons_xo_exts_lib-1.0.0 → scons_xo_exts_lib-1.0.2}/src/scons_xo_exts_lib/Builders/pandoc.py +3 -3
  4. {scons_xo_exts_lib-1.0.0 → scons_xo_exts_lib-1.0.2}/src/scons_xo_exts_lib/Read.py +1 -1
  5. {scons_xo_exts_lib-1.0.0 → scons_xo_exts_lib-1.0.2}/src/scons_xo_exts_lib/__init__.py +1 -1
  6. scons_xo_exts_lib-1.0.0/src/scons_xo_exts_lib/Builders/dune.py +0 -51
  7. {scons_xo_exts_lib-1.0.0 → scons_xo_exts_lib-1.0.2}/pyproject.toml +0 -0
  8. {scons_xo_exts_lib-1.0.0 → scons_xo_exts_lib-1.0.2}/src/scons_xo_exts_lib/Actions/Uv.py +0 -0
  9. {scons_xo_exts_lib-1.0.0 → scons_xo_exts_lib-1.0.2}/src/scons_xo_exts_lib/Actions/__init__.py +0 -0
  10. {scons_xo_exts_lib-1.0.0 → scons_xo_exts_lib-1.0.2}/src/scons_xo_exts_lib/BuildSupport/Make.py +0 -0
  11. {scons_xo_exts_lib-1.0.0 → scons_xo_exts_lib-1.0.2}/src/scons_xo_exts_lib/BuildSupport/NodeMangling.py +0 -0
  12. {scons_xo_exts_lib-1.0.0 → scons_xo_exts_lib-1.0.2}/src/scons_xo_exts_lib/BuildSupport/__init__.py +0 -0
  13. {scons_xo_exts_lib-1.0.0 → scons_xo_exts_lib-1.0.2}/src/scons_xo_exts_lib/Builders/__init__.py +0 -0
  14. {scons_xo_exts_lib-1.0.0 → scons_xo_exts_lib-1.0.2}/src/scons_xo_exts_lib/Builders/bazel.py +0 -0
  15. {scons_xo_exts_lib-1.0.0 → scons_xo_exts_lib-1.0.2}/src/scons_xo_exts_lib/Builders/cmake.py +0 -0
  16. {scons_xo_exts_lib-1.0.0 → scons_xo_exts_lib-1.0.2}/src/scons_xo_exts_lib/Builders/dotnet.py +0 -0
  17. {scons_xo_exts_lib-1.0.0 → scons_xo_exts_lib-1.0.2}/src/scons_xo_exts_lib/Builders/elisp.py +0 -0
  18. {scons_xo_exts_lib-1.0.0 → scons_xo_exts_lib-1.0.2}/src/scons_xo_exts_lib/Builders/make.py +0 -0
  19. {scons_xo_exts_lib-1.0.0 → scons_xo_exts_lib-1.0.2}/src/scons_xo_exts_lib/Builders/ninja.py +0 -0
  20. {scons_xo_exts_lib-1.0.0 → scons_xo_exts_lib-1.0.2}/src/scons_xo_exts_lib/Builders/orgmode.py +0 -0
  21. {scons_xo_exts_lib-1.0.0 → scons_xo_exts_lib-1.0.2}/src/scons_xo_exts_lib/Builders/racket.py +0 -0
  22. {scons_xo_exts_lib-1.0.0 → scons_xo_exts_lib-1.0.2}/src/scons_xo_exts_lib/Find.py +0 -0
  23. {scons_xo_exts_lib-1.0.0 → scons_xo_exts_lib-1.0.2}/src/scons_xo_exts_lib/GenericExtensions.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scons-xo-exts-lib
3
- Version: 1.0.0
3
+ Version: 1.0.2
4
4
  Summary: Scons extensions library by XGQT.
5
5
  Requires-Python: >=3.12
6
6
  Requires-Dist: scons>=4.8.1
@@ -0,0 +1,109 @@
1
+ #!/usr/bin/env python
2
+
3
+ # This Source Code Form is subject to the terms of the Mozilla Public
4
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
5
+ # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
+
7
+
8
+ import os
9
+ import subprocess
10
+
11
+ from SCons.Script import Builder
12
+ from SCons.Script import Environment
13
+
14
+ from scons_xo_exts_lib.BuildSupport import NodeMangling
15
+
16
+
17
+ def _get_dune_project(source: list):
18
+ for source_node in source:
19
+ path = source_node.abspath
20
+
21
+ if "dune-project" in path:
22
+ return path
23
+
24
+ raise RuntimeError("No dune-project in specified sources")
25
+
26
+
27
+ def _dune_command(env: Environment, args_string: str, cwd: str) -> int:
28
+ dune_exe = env.get("DUNE_EXE", "dune")
29
+ dune_flags = env.get("DUNE_FLAGS", "--display=short")
30
+
31
+ command = f"{dune_exe} {args_string} {dune_flags}"
32
+
33
+ result = subprocess.run(
34
+ args=command,
35
+ capture_output=False,
36
+ check=False,
37
+ cwd=cwd,
38
+ shell=True,
39
+ )
40
+
41
+ return result.returncode
42
+
43
+
44
+ def _dune_get_install_prefix(target) -> str:
45
+ """
46
+ Guess the install prefix for "dune install --prefix=...".
47
+ """
48
+
49
+ separators = ["/bin/", "/lib/"]
50
+
51
+ target_node = NodeMangling.get_first_node(target)
52
+ path = str(target_node)
53
+
54
+ try:
55
+ for separator in separators:
56
+ if separator in path:
57
+ substrings = path.split(sep=separator, maxsplit=1)
58
+ prefix = substrings[0]
59
+
60
+ return os.path.abspath(prefix)
61
+
62
+ raise RuntimeError("Separator not found in target")
63
+
64
+ except Exception:
65
+ raise RuntimeError(f"Could not guess prefix, given: {path}")
66
+
67
+
68
+ def dune_build_action(target, source, env) -> int:
69
+ dune_project = _get_dune_project(source=source)
70
+ dune_base_dir = os.path.dirname(dune_project)
71
+
72
+ result = _dune_command(
73
+ env=env,
74
+ args_string="build @install",
75
+ cwd=dune_base_dir,
76
+ )
77
+
78
+ return result
79
+
80
+
81
+ def dune_image_action(target, source, env) -> int:
82
+ dune_project = _get_dune_project(source=source)
83
+ dune_base_dir = os.path.dirname(dune_project)
84
+
85
+ install_prefix = _dune_get_install_prefix(target=target)
86
+
87
+ result = _dune_command(
88
+ env=env,
89
+ args_string=f"install --prefix={install_prefix}",
90
+ cwd=dune_base_dir,
91
+ )
92
+
93
+ return result
94
+
95
+
96
+ def generate(env: Environment) -> None:
97
+ dune_binary_builder = Builder(action=dune_build_action)
98
+ dune_image_builder = Builder(action=dune_image_action)
99
+
100
+ env.Append(
101
+ BUILDERS={
102
+ "DuneBinary": dune_binary_builder,
103
+ "DuneImage": dune_image_builder,
104
+ },
105
+ )
106
+
107
+
108
+ def exists(env: Environment):
109
+ return env.Detect("dune")
@@ -19,7 +19,7 @@ def pandoc_action(target, source, env):
19
19
  inp = NodeMangling.get_first_node(source).abspath
20
20
  out = NodeMangling.get_first_node(target).abspath
21
21
 
22
- cmd = f"{pandoc_exe} {pandoc_flags} -o {inp} {out}"
22
+ cmd = f"{pandoc_exe} {pandoc_flags} -o {out} {inp}"
23
23
  result = subprocess.run(
24
24
  args=cmd,
25
25
  capture_output=False,
@@ -31,9 +31,9 @@ def pandoc_action(target, source, env):
31
31
 
32
32
 
33
33
  def generate(env):
34
- pandoc_binary_builder = Builder(action=pandoc_action)
34
+ pandoc_file_builder = Builder(action=pandoc_action)
35
35
 
36
- env.Append(BUILDERS={"PandocFile": pandoc_binary_builder})
36
+ env.Append(BUILDERS={"PandocFile": pandoc_file_builder})
37
37
 
38
38
 
39
39
  def exists(env):
@@ -30,7 +30,7 @@ def read_line(file_path: str) -> str:
30
30
 
31
31
  lines = read_lines(file_path)
32
32
 
33
- return lines[0]
33
+ return lines[0].strip()
34
34
 
35
35
 
36
36
  def read_version(base_path: str) -> str:
@@ -4,5 +4,5 @@
4
4
  Scons extensions library by XGQT.
5
5
  """
6
6
 
7
- __version__ = "1.0.0"
7
+ __version__ = "1.0.2"
8
8
  __description__ = "Scons extensions library by XGQT"
@@ -1,51 +0,0 @@
1
- #!/usr/bin/env python
2
-
3
- # This Source Code Form is subject to the terms of the Mozilla Public
4
- # License, v. 2.0. If a copy of the MPL was not distributed with this
5
- # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
-
7
-
8
- import os
9
- import subprocess
10
-
11
- from SCons.Script import Builder
12
- from SCons.Script import Environment
13
-
14
-
15
- def _get_dune_project(sources: list):
16
- for source in sources:
17
- source_str = str(source)
18
-
19
- if "dune-project" in source_str:
20
- return source_str
21
-
22
- raise RuntimeError("No dune-project in specified sources")
23
-
24
-
25
- def dune_build_action(target, source, env) -> int:
26
- dune_project = _get_dune_project(sources=source)
27
- dune_base_dir = os.path.dirname(dune_project)
28
-
29
- dune_exe = env.get("DUNE_EXE", "dune")
30
- dune_flags = env.get("DUNE_FLAGS", "--display=short")
31
-
32
- cmd = f"{dune_exe} build {dune_flags} @install"
33
- result = subprocess.run(
34
- args=cmd,
35
- capture_output=False,
36
- check=False,
37
- cwd=dune_base_dir,
38
- shell=True,
39
- )
40
-
41
- return result.returncode
42
-
43
-
44
- def generate(env: Environment) -> None:
45
- dune_binary_builder = Builder(action=dune_build_action)
46
-
47
- env.Append(BUILDERS={"DuneBinary": dune_binary_builder})
48
-
49
-
50
- def exists(env: Environment):
51
- return env.Detect("dune")