scons-xo-exts-lib 1.0.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.

Potentially problematic release.


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

@@ -0,0 +1,48 @@
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
+
10
+ from SCons.Script import Environment
11
+
12
+ from ..GenericExtensions import execute_command
13
+
14
+
15
+ def uv_venv_action(target, source, env):
16
+ if os.path.exists(".venv"):
17
+ return
18
+ else:
19
+ env.Execute("${UV_EXE} venv")
20
+
21
+
22
+ def uv_sync_action(target, source, env):
23
+ execute_command(env, "${UV_EXE} sync --all-packages")
24
+
25
+
26
+ def uv_pip(env, cmd):
27
+ execute_command(env, "${UV_EXE} pip " + cmd)
28
+
29
+
30
+ def uv_pip_freeze_action(target, source, env):
31
+ output_file = str(target[0])
32
+
33
+ uv_pip(env, f"freeze --exclude-editable > {output_file}")
34
+
35
+
36
+ def uv_build_pkg_action(target, source, env):
37
+ if source:
38
+ flags = " ".join(str(s) for s in source)
39
+ else:
40
+ flags = "--all-packages"
41
+
42
+ execute_command(env, "${UV_EXE} build " + flags)
43
+
44
+
45
+ def uv_pytest_action(target, source, env):
46
+ pytest_exec_flags = env.get("PYTEST_FLAGS", "--capture=no")
47
+
48
+ execute_command(env, f"${{UV_EXE}} run -- pytest {pytest_exec_flags}")
@@ -0,0 +1 @@
1
+ #!/usr/bin/env python
@@ -0,0 +1,18 @@
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
+ from typing import List
9
+
10
+ from SCons.Script import Environment
11
+
12
+ from .GenericExtensions import execute_command
13
+
14
+
15
+ def execute_make(env: Environment, args: List[str]) -> None:
16
+ make_cmd = "make" + " ".join(args)
17
+
18
+ execute_command(env, make_cmd)
@@ -0,0 +1,33 @@
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 re
10
+
11
+
12
+ def get_first_node(nodes):
13
+ if isinstance(nodes, list):
14
+ if len(nodes) != 1:
15
+ raise ValueError("Given nodes is not a one-element list")
16
+
17
+ return nodes[0]
18
+
19
+ return nodes
20
+
21
+
22
+ def get_first_directory(nodes):
23
+ node = get_first_node(nodes=nodes)
24
+
25
+ return os.path.dirname(node.abspath)
26
+
27
+
28
+ def regex_find_node(regex, nodes):
29
+ for node in nodes:
30
+ if re.match(pattern=regex, string=str(node.abspath)):
31
+ return node
32
+
33
+ raise RuntimeError("No file was matched using the specified regex")
@@ -0,0 +1 @@
1
+ #!/usr/bin/env python
@@ -0,0 +1 @@
1
+ #!/usr/bin/env python
@@ -0,0 +1,37 @@
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 subprocess
9
+
10
+ from SCons.Script import Builder
11
+
12
+
13
+ def bazel_action(target, source, env):
14
+ bazel_pkgs = " ".join(str(s) for s in source)
15
+
16
+ bazel_exe = env.get("BAZEL_EXE", "bazelisk")
17
+ bazel_flags = env.get("BAZEL_FLAGS", "")
18
+
19
+ cmd = f"{bazel_exe} build {bazel_flags} {bazel_pkgs}"
20
+ result = subprocess.run(
21
+ args=cmd,
22
+ capture_output=False,
23
+ check=False,
24
+ shell=True,
25
+ )
26
+
27
+ return result.returncode
28
+
29
+
30
+ def generate(env):
31
+ bazel_binary_builder = Builder(action=bazel_action)
32
+
33
+ env.Append(BUILDERS={"BazelBinary": bazel_binary_builder})
34
+
35
+
36
+ def exists(env):
37
+ return env.Detect("bazel")
@@ -0,0 +1,37 @@
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 subprocess
9
+
10
+ from SCons.Script import Builder
11
+
12
+
13
+ def cmake_action(target, source, env):
14
+ cmake_targets = " ".join(str(t) for t in target)
15
+
16
+ cmake_exe = env.get("CMAKE_EXE", "cmake")
17
+ cmake_flags = env.get("CMAKE_FLAGS", "")
18
+
19
+ cmd = f"{cmake_exe} {cmake_flags} {cmake_targets}"
20
+ result = subprocess.run(
21
+ args=cmd,
22
+ capture_output=False,
23
+ check=False,
24
+ shell=True,
25
+ )
26
+
27
+ return result.returncode
28
+
29
+
30
+ def generate(env):
31
+ cmake_binary_builder = Builder(action=cmake_action)
32
+
33
+ env.Append(BUILDERS={"CmakeBinary": cmake_binary_builder})
34
+
35
+
36
+ def exists(env):
37
+ return env.Detect("cmake")
@@ -0,0 +1,177 @@
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 typing import List
12
+
13
+ from SCons.Script import Builder
14
+ from SCons.Script import Environment
15
+
16
+ from scons_xo_exts_lib.BuildSupport import NodeMangling
17
+
18
+
19
+ def _dotnet_get_dotnet_exe(env: Environment) -> str:
20
+ dotnet_exe = env.get("DOTNET_EXE")
21
+
22
+ if dotnet_exe:
23
+ return dotnet_exe
24
+
25
+ try:
26
+ return os.path.join(env["DOTNET_ROOT"], "dotnet")
27
+ except KeyError:
28
+ return "dotnet"
29
+
30
+
31
+ def _dotnet_get_project(source) -> str:
32
+ regex = ".*\\.(cs|fs|vb|)proj$"
33
+
34
+ try:
35
+ node = NodeMangling.regex_find_node(regex=regex, nodes=source)
36
+
37
+ return str(node.abspath)
38
+ except Exception as exception:
39
+ raise RuntimeError("No dotnet project file found", exception)
40
+
41
+
42
+ def _dotnet_command(env: Environment, source, args: List[str]) -> None:
43
+ project_file = _dotnet_get_project(source=source)
44
+ source_directory = os.path.dirname(project_file)
45
+
46
+ extra_variables = {
47
+ "DOTNET_CLI_TELEMETRY_OPTOUT": "1",
48
+ "DOTNET_NOLOGO": "1",
49
+ "DOTNET_SKIP_FIRST_TIME_EXPERIENCE": "1",
50
+ "MSBUILDTERMINALLOGGER": "off",
51
+ }
52
+
53
+ subprocess_env = env.Clone()["ENV"]
54
+ subprocess_env.update(extra_variables)
55
+
56
+ dotnet_exe = _dotnet_get_dotnet_exe(env=env)
57
+ subprocess_args = [dotnet_exe] + args
58
+
59
+ result = subprocess.run(
60
+ args=subprocess_args,
61
+ capture_output=False,
62
+ check=False,
63
+ cwd=source_directory,
64
+ env=subprocess_env,
65
+ )
66
+
67
+ if result.returncode == 0:
68
+ return
69
+
70
+ raise RuntimeError("Dotnet command failed")
71
+
72
+
73
+ def _dotnet_get_configuration(env: Environment) -> str:
74
+ try:
75
+ return env["DOTNET_CONFIGURATION"]
76
+ except KeyError:
77
+ return "Release"
78
+
79
+
80
+ def _dotnet_restore(env: Environment, source) -> None:
81
+ _dotnet_command(
82
+ env=env,
83
+ source=source,
84
+ args=[
85
+ "restore",
86
+ "--force-evaluate",
87
+ "--runtime=linux-x64",
88
+ ],
89
+ )
90
+
91
+
92
+ def _dotnet_build(env: Environment, source) -> None:
93
+ _dotnet_command(
94
+ env=env,
95
+ source=source,
96
+ args=[
97
+ "build",
98
+ "--no-restore",
99
+ "--runtime=linux-x64",
100
+ "--configuration=" + _dotnet_get_configuration(env=env),
101
+ ],
102
+ )
103
+
104
+
105
+ def _dotnet_compile(*args, **kwargs) -> None:
106
+ _dotnet_restore(*args, **kwargs)
107
+ _dotnet_build(*args, **kwargs)
108
+
109
+
110
+ def _dotnet_pack(env: Environment, source, target) -> None:
111
+ target_directory = NodeMangling.get_first_directory(nodes=target)
112
+
113
+ _dotnet_command(
114
+ env=env,
115
+ source=source,
116
+ args=[
117
+ "pack",
118
+ "--no-restore",
119
+ "--runtime=linux-x64",
120
+ "--configuration=" + _dotnet_get_configuration(env=env),
121
+ "--output=" + target_directory,
122
+ ],
123
+ )
124
+
125
+
126
+ def _dotnet_compile_binary(env: Environment, source, target) -> None:
127
+ target_directory = NodeMangling.get_first_directory(nodes=target)
128
+
129
+ _dotnet_command(
130
+ env=env,
131
+ source=source,
132
+ args=[
133
+ "publish",
134
+ "--no-restore",
135
+ "--self-contained",
136
+ "-p:PublishSingleFile=true",
137
+ "--runtime=linux-x64",
138
+ "--configuration=" + _dotnet_get_configuration(env=env),
139
+ "--output=" + target_directory,
140
+ ],
141
+ )
142
+
143
+
144
+ def dotnet_package_build_action(target, source, env: Environment) -> int:
145
+ try:
146
+ _dotnet_compile(env=env, source=source)
147
+ _dotnet_pack(env=env, source=source, target=target)
148
+ except RuntimeError:
149
+ return 1
150
+
151
+ return 0
152
+
153
+
154
+ def dotnet_binary_build_action(target, source, env) -> int:
155
+ try:
156
+ _dotnet_compile(env=env, source=source)
157
+ _dotnet_compile_binary(env=env, source=source, target=target)
158
+ except RuntimeError:
159
+ return 1
160
+
161
+ return 0
162
+
163
+
164
+ def generate(env: Environment) -> None:
165
+ dotnet_binary_builder = Builder(action=dotnet_binary_build_action)
166
+ dotnet_package_builder = Builder(action=dotnet_package_build_action)
167
+
168
+ env.Append(
169
+ BUILDERS={
170
+ "DotnetBinary": dotnet_binary_builder,
171
+ "DotnetPackage": dotnet_package_builder,
172
+ }
173
+ )
174
+
175
+
176
+ def exists(env: Environment):
177
+ return env.Detect("dotnet")
@@ -0,0 +1,51 @@
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")
@@ -0,0 +1,111 @@
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 _elisp_construct_load_path(sources: list) -> str:
18
+ load_path_flags: set[str] = set()
19
+
20
+ for source in sources:
21
+ dir_name = os.path.dirname(str(source))
22
+ load_flag = f"-L {dir_name}"
23
+
24
+ load_path_flags.add(load_flag)
25
+
26
+ return " ".join(load_path_flags)
27
+
28
+
29
+ def _elisp_get_emacs_exe(env: Environment) -> str:
30
+ emacs_exe = env.get("EMACS_EXE")
31
+ emacs_version = env.get("EMACS_VERSION")
32
+
33
+ if not emacs_exe:
34
+ if emacs_version:
35
+ return f"emacs-{emacs_version}"
36
+
37
+ return "emacs"
38
+
39
+ return emacs_exe
40
+
41
+
42
+ def _elisp_get_base_command(env: Environment) -> str:
43
+ exe: str = _elisp_get_emacs_exe(env)
44
+
45
+ exec_flags = env.get("EMACS_EXEC_FLAGS", "-batch -q --no-site-file")
46
+ extra_flags = env.get("EMACS_EXTRA_FLAGS", "")
47
+
48
+ return f"{exe} {exec_flags} {extra_flags}"
49
+
50
+
51
+ def elisp_autoloads_action(target, source, env) -> int:
52
+ directory = NodeMangling.get_first_directory(source[0])
53
+ out = NodeMangling.get_first_node(target).abspath
54
+
55
+ base_args = _elisp_get_base_command(env)
56
+
57
+ func = f'loaddefs-generate \\"{directory}\\" \\"{out}\\"'
58
+ flags = f'--eval "({func})"'
59
+
60
+ cmd = f"{base_args} {flags}"
61
+ result = subprocess.run(
62
+ args=cmd,
63
+ capture_output=False,
64
+ check=False,
65
+ cwd=directory,
66
+ shell=True,
67
+ )
68
+
69
+ return result.returncode
70
+
71
+
72
+ def elisp_binary_action(target, source, env) -> int:
73
+ srcs: str = " ".join(str(s) for s in source)
74
+ load_path: str = _elisp_construct_load_path(sources=source)
75
+
76
+ base_args = _elisp_get_base_command(env)
77
+ comp_flags = env.get("EMACS_COMP_FLAGS", "-L .")
78
+
79
+ func = "batch-byte-compile"
80
+ flags = f"{comp_flags} {load_path} -f {func}"
81
+
82
+ cmd = f"{base_args} {flags} {srcs}"
83
+ result = subprocess.run(
84
+ args=cmd,
85
+ capture_output=False,
86
+ check=False,
87
+ shell=True,
88
+ )
89
+
90
+ return result.returncode
91
+
92
+
93
+ def generate(env: Environment) -> None:
94
+ autoloads_builder = Builder(action=elisp_autoloads_action)
95
+
96
+ binary_builder = Builder(
97
+ action=elisp_binary_action,
98
+ src_suffix=".el",
99
+ suffix=".elc",
100
+ )
101
+
102
+ env.Append(
103
+ BUILDERS={
104
+ "ElispAutoloadsFile": autoloads_builder,
105
+ "ElispBinary": binary_builder,
106
+ }
107
+ )
108
+
109
+
110
+ def exists(env: Environment):
111
+ return env.Detect(progs="elisp")
@@ -0,0 +1,37 @@
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 subprocess
9
+
10
+ from SCons.Script import Builder
11
+
12
+
13
+ def make_action(target, source, env):
14
+ make_targets = " ".join(str(t) for t in target)
15
+
16
+ make_exe = env.get("MAKE_EXE", "make")
17
+ make_flags = env.get("MAKE_FLAGS", "")
18
+
19
+ cmd = f"{make_exe} {make_flags} {make_targets}"
20
+ result = subprocess.run(
21
+ args=cmd,
22
+ capture_output=False,
23
+ check=False,
24
+ shell=True,
25
+ )
26
+
27
+ return result.returncode
28
+
29
+
30
+ def generate(env):
31
+ make_binary_builder = Builder(action=make_action)
32
+
33
+ env.Append(BUILDERS={"MakeBinary": make_binary_builder})
34
+
35
+
36
+ def exists(env):
37
+ return env.Detect("make")
@@ -0,0 +1,37 @@
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 subprocess
9
+
10
+ from SCons.Script import Builder
11
+
12
+
13
+ def ninja_action(target, source, env):
14
+ ninja_targets = " ".join(str(t) for t in target)
15
+
16
+ ninja_exe = env.get("NINJA_EXE", "ninja")
17
+ ninja_flags = env.get("NINJA_FLAGS", "")
18
+
19
+ cmd = f"{ninja_exe} {ninja_flags} {ninja_targets}"
20
+ result = subprocess.run(
21
+ args=cmd,
22
+ capture_output=False,
23
+ check=False,
24
+ shell=True,
25
+ )
26
+
27
+ return result.returncode
28
+
29
+
30
+ def generate(env):
31
+ ninja_binary_builder = Builder(action=ninja_action)
32
+
33
+ env.Append(BUILDERS={"NinjaBinary": ninja_binary_builder})
34
+
35
+
36
+ def exists(env):
37
+ return env.Detect("ninja")
@@ -0,0 +1,50 @@
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
+
13
+ from scons_xo_exts_lib.BuildSupport import NodeMangling
14
+
15
+
16
+ def orgmode_action(target, source, env):
17
+ emacs_exe = env.get("EMACS_EXE", "emacs")
18
+ emacs_exec_flags = env.get("EMACS_EXEC_FLAGS", "-batch -q --no-site-file")
19
+
20
+ cwd = NodeMangling.get_first_directory(source)
21
+
22
+ inp = NodeMangling.get_first_node(source).abspath
23
+ out = NodeMangling.get_first_node(target).abspath
24
+
25
+ ext = os.path.splitext(out)[1][1:]
26
+ fun = f'(org-export-to-file \'{ext} \\"{out}\\")'
27
+
28
+ load_flags = "-l org -l ox-latex"
29
+ flags = f'{emacs_exec_flags} {load_flags} {inp} --eval "{fun}"'
30
+
31
+ cmd = f"{emacs_exe} {flags}"
32
+ result = subprocess.run(
33
+ args=cmd,
34
+ capture_output=False,
35
+ check=False,
36
+ shell=True,
37
+ cwd=cwd,
38
+ )
39
+
40
+ return result.returncode
41
+
42
+
43
+ def generate(env):
44
+ orgmode_file_builder = Builder(action=orgmode_action)
45
+
46
+ env.Append(BUILDERS={"OrgmodeFile": orgmode_file_builder})
47
+
48
+
49
+ def exists(env):
50
+ return env.Detect("orgmode")
@@ -0,0 +1,40 @@
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 subprocess
9
+
10
+ from SCons.Script import Builder
11
+
12
+ from scons_xo_exts_lib.BuildSupport import NodeMangling
13
+
14
+
15
+ def pandoc_action(target, source, env):
16
+ pandoc_exe = env.get("PANDOC_EXE", "pandoc")
17
+ pandoc_flags = env.get("PANDOC_FLAGS", "")
18
+
19
+ inp = NodeMangling.get_first_node(source).abspath
20
+ out = NodeMangling.get_first_node(target).abspath
21
+
22
+ cmd = f"{pandoc_exe} {pandoc_flags} -o {inp} {out}"
23
+ result = subprocess.run(
24
+ args=cmd,
25
+ capture_output=False,
26
+ check=False,
27
+ shell=True,
28
+ )
29
+
30
+ return result.returncode
31
+
32
+
33
+ def generate(env):
34
+ pandoc_binary_builder = Builder(action=pandoc_action)
35
+
36
+ env.Append(BUILDERS={"PandocFile": pandoc_binary_builder})
37
+
38
+
39
+ def exists(env):
40
+ return env.Detect("pandoc")
@@ -0,0 +1,122 @@
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 _racket_get_plt_user_home(env: Environment) -> str:
18
+ try:
19
+ return env["PLTUSERHOME"]
20
+ except Exception:
21
+ raise RuntimeError("PLTUSERHOME is unset, please set it in SCons")
22
+
23
+
24
+ def _racket_get_raco_exe(env: Environment) -> str:
25
+ racket_exe: str = env.get(key="RACKET_EXE", default="racket")
26
+ raco_exe: str = f"{racket_exe} -l raco --"
27
+
28
+ return raco_exe
29
+
30
+
31
+ def _racket_raco(env: Environment, source_node, args: str) -> None:
32
+ plt_user_home: str = _racket_get_plt_user_home(env=env)
33
+ raco: str = _racket_get_raco_exe(env=env)
34
+
35
+ extra_variables = {
36
+ "PLTUSERHOME": plt_user_home,
37
+ }
38
+
39
+ subprocess_env = env.Clone()["ENV"]
40
+ subprocess_env.update(extra_variables)
41
+
42
+ directory: str = NodeMangling.get_first_directory(source_node)
43
+ cmd = f"{raco} {args}"
44
+
45
+ result = subprocess.run(
46
+ args=cmd,
47
+ capture_output=False,
48
+ check=False,
49
+ cwd=directory,
50
+ shell=True,
51
+ )
52
+
53
+ if result.returncode == 0:
54
+ return
55
+
56
+ raise RuntimeError(f"Raco command failed, ran: {cmd}")
57
+
58
+
59
+ def _racket_install_package(env: Environment, source: list) -> None:
60
+ for source_node in source:
61
+ _racket_raco(
62
+ env=env,
63
+ source_node=source_node,
64
+ args="pkg install --auto --skip-installed --no-docs",
65
+ )
66
+
67
+
68
+ def _racket_setup_package(env: Environment, source: list) -> None:
69
+ for source_node in source:
70
+ _racket_raco(
71
+ env=env,
72
+ source_node=source_node,
73
+ args="setup --tidy --avoid-main --no-docs",
74
+ )
75
+
76
+
77
+ def _racket_create_exe(env: Environment, target, source) -> None:
78
+ for target_node, source_node in zip(target, source):
79
+ out: str = target_node.abspath
80
+ inp: str = source_node.abspath
81
+
82
+ _racket_raco(
83
+ env=env,
84
+ source_node=source_node,
85
+ args=f"exe -v --orig-exe -o {out} {inp}",
86
+ )
87
+
88
+
89
+ def racket_library_action(target, source, env) -> int:
90
+ try:
91
+ _racket_install_package(env=env, source=source)
92
+ except RuntimeError:
93
+ return 1
94
+
95
+ return 0
96
+
97
+
98
+ def racket_binary_action(target, source, env) -> int:
99
+ try:
100
+ _racket_install_package(env=env, source=source)
101
+ _racket_setup_package(env=env, source=source)
102
+ _racket_create_exe(env=env, target=target, source=source)
103
+ except RuntimeError:
104
+ return 1
105
+
106
+ return 0
107
+
108
+
109
+ def generate(env: Environment) -> None:
110
+ racket_binary_builder = Builder(action=racket_binary_action)
111
+ racket_library_builder = Builder(action=racket_library_action)
112
+
113
+ env.Append(
114
+ BUILDERS={
115
+ "RacketBinary": racket_binary_builder,
116
+ "RacketLibrary": racket_library_builder,
117
+ }
118
+ )
119
+
120
+
121
+ def exists(env: Environment):
122
+ return env.Detect(progs="racket")
@@ -0,0 +1,32 @@
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
+
10
+ from typing import List
11
+
12
+
13
+ def find_files(path: str) -> List[str]:
14
+ if not os.path.exists(path):
15
+ return []
16
+
17
+ abs_path = os.path.abspath(path)
18
+ files = os.listdir(abs_path)
19
+
20
+ return list(map(lambda f: os.path.join(abs_path, f), files))
21
+
22
+
23
+ def find_last_directory(path: str) -> str:
24
+ files = find_files(path)
25
+
26
+ dirs = (d for d in files if os.path.isdir(d))
27
+ dirs = sorted(dirs, reverse=True)
28
+
29
+ if not dirs:
30
+ raise RuntimeError("No files found and so also no latest directory")
31
+
32
+ return dirs[0]
@@ -0,0 +1,38 @@
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
+
10
+ from shutil import rmtree
11
+
12
+ from SCons.Script import Environment
13
+
14
+
15
+ def execute_command(env: Environment, command: str) -> None:
16
+ result = env.Execute(command)
17
+
18
+ if result:
19
+ raise RuntimeError(f"Command failed, given: {command}")
20
+
21
+
22
+ def remove(path: str, *args, **kwargs):
23
+ pwd = os.getcwd()
24
+
25
+ rmtree(os.path.join(pwd, path), *args, **kwargs)
26
+
27
+
28
+ def find_remove(env: Environment, file_name: str):
29
+ find_exe = env.get("FIND_EXE", "find")
30
+
31
+ rm_exe = env.get("RM_EXE", "rm")
32
+ rm_flags = env.get("RM_FLAGS", "-f -r")
33
+ rm_cmd = f"{rm_exe} {rm_flags}"
34
+
35
+ execute_command(
36
+ env,
37
+ f"{find_exe} . -name '{file_name}' -exec {rm_cmd} {{}} +",
38
+ )
@@ -0,0 +1,53 @@
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
+
10
+ from typing import List
11
+
12
+
13
+ def read_lines(file_path: str) -> List[str]:
14
+ """
15
+ Return all file lines.
16
+ """
17
+
18
+ lines = []
19
+
20
+ with open(file_path) as file:
21
+ lines = file.readlines()
22
+
23
+ return lines
24
+
25
+
26
+ def read_line(file_path: str) -> str:
27
+ """
28
+ Return 1st file line.
29
+ """
30
+
31
+ lines = read_lines(file_path)
32
+
33
+ return lines[0]
34
+
35
+
36
+ def read_version(base_path: str) -> str:
37
+ """
38
+ Return content of a "VERSION" file found at the "base_path".
39
+ """
40
+
41
+ version_file = os.path.join(base_path, "VERSION")
42
+
43
+ return read_line(version_file)
44
+
45
+
46
+ def read_python_version(base_path: str) -> str:
47
+ """
48
+ Return content of a ".python-version" file found at the "base_path".
49
+ """
50
+
51
+ version_file = os.path.join(base_path, ".python-version")
52
+
53
+ return read_line(version_file)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env python
2
+
3
+ """
4
+ Scons extensions library by XGQT.
5
+ """
6
+
7
+ __version__ = "1.0.0"
8
+ __description__ = "Scons extensions library by XGQT"
@@ -0,0 +1,6 @@
1
+ Metadata-Version: 2.4
2
+ Name: scons-xo-exts-lib
3
+ Version: 1.0.0
4
+ Summary: Scons extensions library by XGQT.
5
+ Requires-Python: >=3.12
6
+ Requires-Dist: scons>=4.8.1
@@ -0,0 +1,23 @@
1
+ scons_xo_exts_lib/Find.py,sha256=J5VcXfBjg9kW_o4v8S3ugnv-JKAV6wzD6xrIw1jMerA,767
2
+ scons_xo_exts_lib/GenericExtensions.py,sha256=c56PZZuDHdche-x1ERC6gIcIENAP8ZD20EQkxvTXAz4,916
3
+ scons_xo_exts_lib/Read.py,sha256=sXnCuW1-gMX-MeIpCvx45N8Sqnr8Fb4UsJfGdB8reeA,1042
4
+ scons_xo_exts_lib/__init__.py,sha256=Eza5CXe9vm2-z7K6-duPg2qiceQBWKD0uy6Dend33lY,141
5
+ scons_xo_exts_lib/Actions/Uv.py,sha256=kdocY_tAvzA4awBs4f6djy4Hku4alXh_L7Vy7llNprY,1172
6
+ scons_xo_exts_lib/Actions/__init__.py,sha256=-JIt3g1eBf4bVQNNQd4JBeQNA7o0LK0W9tYKKX_r5s8,22
7
+ scons_xo_exts_lib/BuildSupport/Make.py,sha256=JG7Wi_G9vQeU9UyKTnN8D8akzmrhFYhsQH2zDmO1-u8,472
8
+ scons_xo_exts_lib/BuildSupport/NodeMangling.py,sha256=ynoh1GqQo1BHrNmlzugKsXHjlJkh9QuByGQAl8-UCdY,780
9
+ scons_xo_exts_lib/BuildSupport/__init__.py,sha256=-JIt3g1eBf4bVQNNQd4JBeQNA7o0LK0W9tYKKX_r5s8,22
10
+ scons_xo_exts_lib/Builders/__init__.py,sha256=-JIt3g1eBf4bVQNNQd4JBeQNA7o0LK0W9tYKKX_r5s8,22
11
+ scons_xo_exts_lib/Builders/bazel.py,sha256=eFJZysWV4v63RapZI2Xg0S1FgDJfLbpYtGElx6qENj8,866
12
+ scons_xo_exts_lib/Builders/cmake.py,sha256=FoWPK-GUv56aswFdrE6JWqtTIKE2oymPKi_C2ZmNHGo,863
13
+ scons_xo_exts_lib/Builders/dotnet.py,sha256=AD-OGbQuvCd1LuJSDtfdCE1OOKB8NQ4_hujaEvfZMbk,4426
14
+ scons_xo_exts_lib/Builders/dune.py,sha256=tO_gMTnEDanr4C9MDWG2CcggByWaaXCjYHyhDiH1pFY,1277
15
+ scons_xo_exts_lib/Builders/elisp.py,sha256=T7j4z6mvCXz1gd9oPoOLqOiVE3YLoY3q6y5wwhZAw8U,2723
16
+ scons_xo_exts_lib/Builders/make.py,sha256=fa_cZjR-lTVqFGLjm5EyDBwVxcaaZCL-2h_QKb6RCzU,848
17
+ scons_xo_exts_lib/Builders/ninja.py,sha256=FEOMGfTbMWOE2cSlOu9FPXJjYw-uOCY2tfSM-5XFao4,863
18
+ scons_xo_exts_lib/Builders/orgmode.py,sha256=iyu4O0xWWVZqx_LNhBb5i1Dt30iuE8VpwmmDNQSMJ4U,1273
19
+ scons_xo_exts_lib/Builders/pandoc.py,sha256=CAPyV9K1gdL_XWFodXpw8bEiFhu2_CvV8qNHWdKbifA,985
20
+ scons_xo_exts_lib/Builders/racket.py,sha256=yDj_YYtVk15SqrXrjLb8efbYjR8j6VGpLU2pYAVID5I,3171
21
+ scons_xo_exts_lib-1.0.0.dist-info/WHEEL,sha256=_2ozNFCLWc93bK4WKHCO-eDUENDlo-dgc9cU3qokYO4,82
22
+ scons_xo_exts_lib-1.0.0.dist-info/METADATA,sha256=DbEXjnGDrH6ta2z9kKJJF6Dy4_wARbg55-QV5AXbxL4,156
23
+ scons_xo_exts_lib-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: flit 3.11.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any