scons-xo-exts-lib 1.0.2__tar.gz → 1.2.0__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 (28) hide show
  1. scons_xo_exts_lib-1.2.0/PKG-INFO +39 -0
  2. scons_xo_exts_lib-1.2.0/README.md +25 -0
  3. scons_xo_exts_lib-1.2.0/pyproject.toml +28 -0
  4. {scons_xo_exts_lib-1.0.2 → scons_xo_exts_lib-1.2.0}/src/scons_xo_exts_lib/BuildSupport/NodeMangling.py +0 -3
  5. {scons_xo_exts_lib-1.0.2 → scons_xo_exts_lib-1.2.0}/src/scons_xo_exts_lib/Builders/bazel.py +2 -0
  6. {scons_xo_exts_lib-1.0.2 → scons_xo_exts_lib-1.2.0}/src/scons_xo_exts_lib/Builders/cmake.py +2 -0
  7. {scons_xo_exts_lib-1.0.2 → scons_xo_exts_lib-1.2.0}/src/scons_xo_exts_lib/Builders/dotnet.py +4 -2
  8. {scons_xo_exts_lib-1.0.2 → scons_xo_exts_lib-1.2.0}/src/scons_xo_exts_lib/Builders/dune.py +3 -2
  9. {scons_xo_exts_lib-1.0.2 → scons_xo_exts_lib-1.2.0}/src/scons_xo_exts_lib/Builders/elisp.py +20 -3
  10. scons_xo_exts_lib-1.2.0/src/scons_xo_exts_lib/Builders/elixir.py +67 -0
  11. {scons_xo_exts_lib-1.0.2 → scons_xo_exts_lib-1.2.0}/src/scons_xo_exts_lib/Builders/make.py +2 -0
  12. scons_xo_exts_lib-1.2.0/src/scons_xo_exts_lib/Builders/meson.py +44 -0
  13. {scons_xo_exts_lib-1.0.2 → scons_xo_exts_lib-1.2.0}/src/scons_xo_exts_lib/Builders/ninja.py +7 -2
  14. scons_xo_exts_lib-1.2.0/src/scons_xo_exts_lib/Builders/orgmode.py +109 -0
  15. {scons_xo_exts_lib-1.0.2 → scons_xo_exts_lib-1.2.0}/src/scons_xo_exts_lib/Builders/pandoc.py +2 -0
  16. {scons_xo_exts_lib-1.0.2 → scons_xo_exts_lib-1.2.0}/src/scons_xo_exts_lib/Builders/racket.py +1 -0
  17. {scons_xo_exts_lib-1.0.2 → scons_xo_exts_lib-1.2.0}/src/scons_xo_exts_lib/__init__.py +1 -1
  18. scons_xo_exts_lib-1.0.2/PKG-INFO +0 -6
  19. scons_xo_exts_lib-1.0.2/pyproject.toml +0 -16
  20. scons_xo_exts_lib-1.0.2/src/scons_xo_exts_lib/Builders/orgmode.py +0 -50
  21. {scons_xo_exts_lib-1.0.2 → scons_xo_exts_lib-1.2.0}/src/scons_xo_exts_lib/Actions/Uv.py +0 -0
  22. {scons_xo_exts_lib-1.0.2 → scons_xo_exts_lib-1.2.0}/src/scons_xo_exts_lib/Actions/__init__.py +0 -0
  23. {scons_xo_exts_lib-1.0.2 → scons_xo_exts_lib-1.2.0}/src/scons_xo_exts_lib/BuildSupport/Make.py +0 -0
  24. {scons_xo_exts_lib-1.0.2 → scons_xo_exts_lib-1.2.0}/src/scons_xo_exts_lib/BuildSupport/__init__.py +0 -0
  25. {scons_xo_exts_lib-1.0.2 → scons_xo_exts_lib-1.2.0}/src/scons_xo_exts_lib/Builders/__init__.py +0 -0
  26. {scons_xo_exts_lib-1.0.2 → scons_xo_exts_lib-1.2.0}/src/scons_xo_exts_lib/Find.py +0 -0
  27. {scons_xo_exts_lib-1.0.2 → scons_xo_exts_lib-1.2.0}/src/scons_xo_exts_lib/GenericExtensions.py +0 -0
  28. {scons_xo_exts_lib-1.0.2 → scons_xo_exts_lib-1.2.0}/src/scons_xo_exts_lib/Read.py +0 -0
@@ -0,0 +1,39 @@
1
+ Metadata-Version: 2.4
2
+ Name: scons-xo-exts-lib
3
+ Version: 1.2.0
4
+ Summary: Scons extensions library by XGQT.
5
+ Author-email: Maciej Barć <xgqt@xgqt.org>
6
+ Requires-Python: >=3.12
7
+ Description-Content-Type: text/markdown
8
+ Classifier: Environment :: Console
9
+ Classifier: Operating System :: POSIX
10
+ Classifier: Programming Language :: Python :: 3 :: Only
11
+ Requires-Dist: scons>=4.8.1
12
+ Project-URL: Home, https://gitlab.com/xgqt/xgqt-python-lib-scons-xo-exts/
13
+
14
+ # SCons XO Exts
15
+
16
+ SCons extensions
17
+
18
+ ## About
19
+
20
+ Extensions for SCons, includes Python libraries and builders.
21
+
22
+ ## Repository
23
+
24
+ Upstream repository is <https://gitlab.com/xgqt/xgqt-python-lib-scons-xo-exts/>.
25
+
26
+ ## Package
27
+
28
+ Download from PYPI: <https://pypi.org/project/scons-xo-exts-lib/>.
29
+
30
+ ## License
31
+
32
+ ### Code
33
+
34
+ Code in this project is licensed under the MPL, version 2.0.
35
+
36
+ This Source Code Form is subject to the terms of the Mozilla Public
37
+ License, v. 2.0. If a copy of the MPL was not distributed with this
38
+ file, You can obtain one at http://mozilla.org/MPL/2.0/.
39
+
@@ -0,0 +1,25 @@
1
+ # SCons XO Exts
2
+
3
+ SCons extensions
4
+
5
+ ## About
6
+
7
+ Extensions for SCons, includes Python libraries and builders.
8
+
9
+ ## Repository
10
+
11
+ Upstream repository is <https://gitlab.com/xgqt/xgqt-python-lib-scons-xo-exts/>.
12
+
13
+ ## Package
14
+
15
+ Download from PYPI: <https://pypi.org/project/scons-xo-exts-lib/>.
16
+
17
+ ## License
18
+
19
+ ### Code
20
+
21
+ Code in this project is licensed under the MPL, version 2.0.
22
+
23
+ This Source Code Form is subject to the terms of the Mozilla Public
24
+ License, v. 2.0. If a copy of the MPL was not distributed with this
25
+ file, You can obtain one at http://mozilla.org/MPL/2.0/.
@@ -0,0 +1,28 @@
1
+ [project]
2
+ name = "scons-xo-exts-lib"
3
+ dynamic = [
4
+ "description",
5
+ "version",
6
+ ]
7
+ authors = [
8
+ {name = "Maciej Barć", email = "xgqt@xgqt.org"},
9
+ ]
10
+ readme = "README.md"
11
+ classifiers = [
12
+ "Environment :: Console",
13
+ "Operating System :: POSIX",
14
+ "Programming Language :: Python :: 3 :: Only",
15
+ ]
16
+ requires-python = ">=3.12"
17
+ dependencies = [
18
+ "scons>=4.8.1",
19
+ ]
20
+
21
+ [project.urls]
22
+ Home = "https://gitlab.com/xgqt/xgqt-python-lib-scons-xo-exts/"
23
+
24
+ [build-system]
25
+ build-backend = "flit_core.buildapi"
26
+ requires = [
27
+ "flit_core >=3.2,<4",
28
+ ]
@@ -11,9 +11,6 @@ import re
11
11
 
12
12
  def get_first_node(nodes):
13
13
  if isinstance(nodes, list):
14
- if len(nodes) != 1:
15
- raise ValueError("Given nodes is not a one-element list")
16
-
17
14
  return nodes[0]
18
15
 
19
16
  return nodes
@@ -17,6 +17,8 @@ def bazel_action(target, source, env):
17
17
  bazel_flags = env.get("BAZEL_FLAGS", "")
18
18
 
19
19
  cmd = f"{bazel_exe} build {bazel_flags} {bazel_pkgs}"
20
+ print(cmd)
21
+
20
22
  result = subprocess.run(
21
23
  args=cmd,
22
24
  capture_output=False,
@@ -17,6 +17,8 @@ def cmake_action(target, source, env):
17
17
  cmake_flags = env.get("CMAKE_FLAGS", "")
18
18
 
19
19
  cmd = f"{cmake_exe} {cmake_flags} {cmake_targets}"
20
+ print(cmd)
21
+
20
22
  result = subprocess.run(
21
23
  args=cmd,
22
24
  capture_output=False,
@@ -54,10 +54,12 @@ def _dotnet_command(env: Environment, source, args: List[str]) -> None:
54
54
  subprocess_env.update(extra_variables)
55
55
 
56
56
  dotnet_exe = _dotnet_get_dotnet_exe(env=env)
57
- subprocess_args = [dotnet_exe] + args
57
+
58
+ cmd = [dotnet_exe] + args
59
+ print(cmd)
58
60
 
59
61
  result = subprocess.run(
60
- args=subprocess_args,
62
+ args=cmd,
61
63
  capture_output=False,
62
64
  check=False,
63
65
  cwd=source_directory,
@@ -28,10 +28,11 @@ def _dune_command(env: Environment, args_string: str, cwd: str) -> int:
28
28
  dune_exe = env.get("DUNE_EXE", "dune")
29
29
  dune_flags = env.get("DUNE_FLAGS", "--display=short")
30
30
 
31
- command = f"{dune_exe} {args_string} {dune_flags}"
31
+ cmd = f"{dune_exe} {args_string} {dune_flags}"
32
+ print(cmd)
32
33
 
33
34
  result = subprocess.run(
34
- args=command,
35
+ args=cmd,
35
36
  capture_output=False,
36
37
  check=False,
37
38
  cwd=cwd,
@@ -8,6 +8,8 @@
8
8
  import os
9
9
  import subprocess
10
10
 
11
+ from SCons.Node import FS
12
+
11
13
  from SCons.Script import Builder
12
14
  from SCons.Script import Environment
13
15
 
@@ -15,13 +17,24 @@ from scons_xo_exts_lib.BuildSupport import NodeMangling
15
17
 
16
18
 
17
19
  def _elisp_construct_load_path(sources: list) -> str:
20
+ """
21
+ :param sources: list of files to construct a load path from
22
+ :returns: Emacs load path command-line options
23
+ """
24
+
18
25
  load_path_flags: set[str] = set()
19
26
 
20
27
  for source in sources:
21
- dir_name = os.path.dirname(str(source))
22
- load_flag = f"-L {dir_name}"
28
+ if isinstance(source, FS.File):
29
+ dir_name = source.get_dir().relpath
30
+ else:
31
+ dir_name = os.path.dirname(str(source))
32
+
33
+ # Then check if the directory **really** exists.
34
+ if dir_name and os.path.exists(dir_name):
35
+ load_flag = f"-L {dir_name}"
23
36
 
24
- load_path_flags.add(load_flag)
37
+ load_path_flags.add(load_flag)
25
38
 
26
39
  return " ".join(load_path_flags)
27
40
 
@@ -58,6 +71,8 @@ def elisp_autoloads_action(target, source, env) -> int:
58
71
  flags = f'--eval "({func})"'
59
72
 
60
73
  cmd = f"{base_args} {flags}"
74
+ print(cmd)
75
+
61
76
  result = subprocess.run(
62
77
  args=cmd,
63
78
  capture_output=False,
@@ -80,6 +95,8 @@ def elisp_binary_action(target, source, env) -> int:
80
95
  flags = f"{comp_flags} {load_path} -f {func}"
81
96
 
82
97
  cmd = f"{base_args} {flags} {srcs}"
98
+ print(cmd)
99
+
83
100
  result = subprocess.run(
84
101
  args=cmd,
85
102
  capture_output=False,
@@ -0,0 +1,67 @@
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_mix_project(source: list):
16
+ for source_node in source:
17
+ path = source_node.abspath
18
+
19
+ if "mix.exs" in path:
20
+ return path
21
+
22
+ raise RuntimeError("No mix-project in specified sources")
23
+
24
+
25
+ def _mix_command(env: Environment, args_string: str, cwd: str) -> int:
26
+ mix_exe = env.get(key="MIX_EXE", default="mix")
27
+ mix_flags = env.get(key="MIX_FLAGS", default="")
28
+
29
+ cmd = f"{mix_exe} {args_string} {mix_flags}"
30
+ print(cmd)
31
+
32
+ result = subprocess.run(
33
+ args=cmd,
34
+ capture_output=False,
35
+ check=False,
36
+ cwd=cwd,
37
+ shell=True,
38
+ )
39
+
40
+ return result.returncode
41
+
42
+
43
+ def elixir_build_action(target, source, env) -> int:
44
+ elixir_project = _get_mix_project(source=source)
45
+ elixir_base_dir = os.path.dirname(elixir_project)
46
+
47
+ result = _mix_command(
48
+ env=env,
49
+ args_string="escript.build",
50
+ cwd=elixir_base_dir,
51
+ )
52
+
53
+ return result
54
+
55
+
56
+ def generate(env: Environment) -> None:
57
+ elixir_binary_builder = Builder(action=elixir_build_action)
58
+
59
+ env.Append(
60
+ BUILDERS={
61
+ "ElixirBinary": elixir_binary_builder,
62
+ },
63
+ )
64
+
65
+
66
+ def exists(env: Environment):
67
+ return env.Detect("elixir")
@@ -17,6 +17,8 @@ def make_action(target, source, env):
17
17
  make_flags = env.get("MAKE_FLAGS", "")
18
18
 
19
19
  cmd = f"{make_exe} {make_flags} {make_targets}"
20
+ print(cmd)
21
+
20
22
  result = subprocess.run(
21
23
  args=cmd,
22
24
  capture_output=False,
@@ -0,0 +1,44 @@
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 meson_action(target, source, env):
17
+ source_dir = NodeMangling.get_first_directory(nodes=source)
18
+ builddir = NodeMangling.get_first_directory(nodes=target)
19
+
20
+ meson_exe = env.get("MESON_EXE", "meson")
21
+ meson_flags = env.get("MESON_FLAGS", "")
22
+
23
+ cmd = f"{meson_exe} setup --reconfigure {meson_flags} {builddir}"
24
+ print(cmd)
25
+
26
+ result = subprocess.run(
27
+ args=cmd,
28
+ cwd=source_dir,
29
+ capture_output=False,
30
+ check=False,
31
+ shell=True,
32
+ )
33
+
34
+ return result.returncode
35
+
36
+
37
+ def generate(env):
38
+ meson_builddir_builder = Builder(action=meson_action)
39
+
40
+ env.Append(BUILDERS={"MesonBuilddir": meson_builddir_builder})
41
+
42
+
43
+ def exists(env):
44
+ return env.Detect("meson")
@@ -9,16 +9,21 @@ import subprocess
9
9
 
10
10
  from SCons.Script import Builder
11
11
 
12
+ from scons_xo_exts_lib.BuildSupport import NodeMangling
13
+
12
14
 
13
15
  def ninja_action(target, source, env):
14
- ninja_targets = " ".join(str(t) for t in target)
16
+ source_dir = NodeMangling.get_first_directory(nodes=source)
15
17
 
16
18
  ninja_exe = env.get("NINJA_EXE", "ninja")
17
19
  ninja_flags = env.get("NINJA_FLAGS", "")
18
20
 
19
- cmd = f"{ninja_exe} {ninja_flags} {ninja_targets}"
21
+ cmd = f"{ninja_exe} {ninja_flags} -C ."
22
+ print(cmd)
23
+
20
24
  result = subprocess.run(
21
25
  args=cmd,
26
+ cwd=source_dir,
22
27
  capture_output=False,
23
28
  check=False,
24
29
  shell=True,
@@ -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 shutil import move
12
+
13
+ from SCons.Script import Builder
14
+
15
+ from scons_xo_exts_lib.BuildSupport import NodeMangling
16
+
17
+
18
+ def _orgmode_extension_to_backend(file_extension: str) -> list[str]:
19
+ match file_extension:
20
+ case "info":
21
+ return "texinfo"
22
+ case "markdown":
23
+ return "md"
24
+ case "pdf":
25
+ return "latex"
26
+ case "texi":
27
+ return "texinfo"
28
+ case _:
29
+ return file_extension
30
+
31
+
32
+ def _orgmode_extension_to_libraries(file_extension: str) -> list[str]:
33
+ elisp_libs = []
34
+
35
+ backend = _orgmode_extension_to_backend(file_extension=file_extension)
36
+
37
+ if backend != file_extension:
38
+ elisp_libs.append(f"ox-{backend}")
39
+
40
+ return elisp_libs
41
+
42
+
43
+ def _orgmode_get_export_flags(target_file: str, source_file: str) -> str:
44
+ file_extension = os.path.splitext(target_file)[1][1:]
45
+ backend = _orgmode_extension_to_backend(file_extension=file_extension)
46
+
47
+ if file_extension == "texi":
48
+ fun = "org-texinfo-export-to-texinfo"
49
+ else:
50
+ fun = f"org-{backend}-export-to-{file_extension}"
51
+
52
+ load_elisp_libs = [
53
+ "org",
54
+ "ox-latex",
55
+ ]
56
+
57
+ extension_libs = _orgmode_extension_to_libraries(file_extension=file_extension)
58
+
59
+ load_elisp_libs.extend(extension_libs)
60
+
61
+ load_flags = " ".join([f"-l {s}" for s in load_elisp_libs])
62
+ flags = f"{load_flags} {source_file} -f {fun}"
63
+
64
+ return flags
65
+
66
+
67
+ def orgmode_action(target, source, env):
68
+ emacs_exe = env.get("EMACS_EXE", "emacs")
69
+ emacs_exec_flags = env.get("EMACS_EXEC_FLAGS", "-batch -q --no-site-file")
70
+
71
+ cwd = NodeMangling.get_first_directory(source)
72
+
73
+ inp = NodeMangling.get_first_node(source).abspath
74
+ out = NodeMangling.get_first_node(target).abspath
75
+
76
+ orgmode_flags = _orgmode_get_export_flags(target_file=out, source_file=inp)
77
+ flags = f"{emacs_exec_flags} {orgmode_flags}"
78
+
79
+ cmd = f"{emacs_exe} {flags}"
80
+
81
+ print(cmd)
82
+
83
+ result = subprocess.run(
84
+ args=cmd,
85
+ capture_output=False,
86
+ check=False,
87
+ shell=True,
88
+ cwd=cwd,
89
+ )
90
+
91
+ # When the target basename is different than export basename we have to do
92
+ # a file move.
93
+ if not os.path.exists(out):
94
+ out_extension = os.path.splitext(out)[1]
95
+ inp_basename = os.path.splitext(inp)[0]
96
+
97
+ move(f"{inp_basename}{out_extension}", out)
98
+
99
+ return result.returncode
100
+
101
+
102
+ def generate(env):
103
+ orgmode_file_builder = Builder(action=orgmode_action)
104
+
105
+ env.Append(BUILDERS={"OrgmodeFile": orgmode_file_builder})
106
+
107
+
108
+ def exists(env):
109
+ return env.Detect("orgmode")
@@ -20,6 +20,8 @@ def pandoc_action(target, source, env):
20
20
  out = NodeMangling.get_first_node(target).abspath
21
21
 
22
22
  cmd = f"{pandoc_exe} {pandoc_flags} -o {out} {inp}"
23
+ print(cmd)
24
+
23
25
  result = subprocess.run(
24
26
  args=cmd,
25
27
  capture_output=False,
@@ -41,6 +41,7 @@ def _racket_raco(env: Environment, source_node, args: str) -> None:
41
41
 
42
42
  directory: str = NodeMangling.get_first_directory(source_node)
43
43
  cmd = f"{raco} {args}"
44
+ print(cmd)
44
45
 
45
46
  result = subprocess.run(
46
47
  args=cmd,
@@ -4,5 +4,5 @@
4
4
  Scons extensions library by XGQT.
5
5
  """
6
6
 
7
- __version__ = "1.0.2"
7
+ __version__ = "1.2.0"
8
8
  __description__ = "Scons extensions library by XGQT"
@@ -1,6 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: scons-xo-exts-lib
3
- Version: 1.0.2
4
- Summary: Scons extensions library by XGQT.
5
- Requires-Python: >=3.12
6
- Requires-Dist: scons>=4.8.1
@@ -1,16 +0,0 @@
1
- [project]
2
- name = "scons-xo-exts-lib"
3
- dynamic = [
4
- "description",
5
- "version",
6
- ]
7
- requires-python = ">=3.12"
8
- dependencies = [
9
- "scons>=4.8.1",
10
- ]
11
-
12
- [build-system]
13
- build-backend = "flit_core.buildapi"
14
- requires = [
15
- "flit_core >=3.2,<4",
16
- ]
@@ -1,50 +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
-
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")