spl-core 7.5.1__py3-none-any.whl → 7.6.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.
spl_core/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "7.5.1"
1
+ __version__ = "7.6.0"
@@ -0,0 +1,120 @@
1
+ import json
2
+ import zipfile
3
+ from dataclasses import dataclass
4
+ from pathlib import Path
5
+ from typing import List, Optional
6
+
7
+
8
+ class ArchiveArtifactsCollection:
9
+ """
10
+ Collection of artifacts to be archived.
11
+ This class collects artifacts from a list of paths, handling both individual files and directories.
12
+ It supports absolute paths and ensures that the paths are relative to the build directory when archived.
13
+ """
14
+
15
+ @dataclass
16
+ class ArchiveArtifact:
17
+ """
18
+ Represents a single artifact to be archived.
19
+ This class holds the archive path (relative to the build directory) and the absolute path of the artifact.
20
+ It is used to ensure that artifacts are correctly archived with their intended paths.
21
+ """
22
+
23
+ archive_path: Path
24
+ absolute_path: Path
25
+
26
+ def __init__(self, artifacts: List[Path], build_dir: Path):
27
+ self.build_dir = build_dir
28
+ self.archive_artifacts: List[ArchiveArtifactsCollection.ArchiveArtifact] = []
29
+ for artifact in artifacts:
30
+ # Convert all artifacts to absolute paths first
31
+ artifact_path = artifact.resolve() if not artifact.is_absolute() else artifact
32
+
33
+ # Handle directories by recursively adding all files within them
34
+ if artifact_path.is_dir():
35
+ for file_artifact in artifact_path.glob("**/*"):
36
+ if file_artifact.is_file():
37
+ # Calculate the relative path from build_dir for the archive
38
+ if file_artifact.is_relative_to(build_dir.absolute()):
39
+ archive_path = file_artifact.relative_to(build_dir.absolute())
40
+ else:
41
+ # If not relative to build_dir, just use the filename
42
+ archive_path = Path(file_artifact.name)
43
+
44
+ self.archive_artifacts.append(self.ArchiveArtifact(archive_path=archive_path, absolute_path=file_artifact))
45
+ else:
46
+ # Handle individual files
47
+ # Calculate the relative path from build_dir for the archive
48
+ if artifact_path.is_relative_to(build_dir.absolute()):
49
+ archive_path = artifact_path.relative_to(build_dir.absolute())
50
+ else:
51
+ # If not relative to build_dir, just use the filename
52
+ archive_path = Path(artifact_path.name)
53
+
54
+ self.archive_artifacts.append(self.ArchiveArtifact(archive_path=archive_path, absolute_path=artifact_path))
55
+
56
+ def create_archive(self, zip_filename: Optional[str] = None) -> Path:
57
+ """
58
+ Create a zip file containing the collected artifacts.
59
+ Args:
60
+ zip_filename: Optional custom name for the zip file (without extension).
61
+ If None, defaults to "artifacts.zip"
62
+ Returns:
63
+ Path: The path to the created zip file.
64
+ Raises:
65
+ Exception: If there is an error creating the zip file.
66
+ """
67
+ if zip_filename is None:
68
+ zip_path = self.build_dir / "artifacts.zip"
69
+ else:
70
+ # Ensure the filename has .zip extension
71
+ if not zip_filename.endswith(".zip"):
72
+ zip_filename += ".zip"
73
+ zip_path = self.build_dir / zip_filename
74
+
75
+ # Delete the file if it already exists
76
+ if zip_path.exists():
77
+ zip_path.unlink()
78
+
79
+ try:
80
+ with zipfile.ZipFile(zip_path, "w") as zip_file:
81
+ for artifact in self.archive_artifacts:
82
+ zip_file.write(artifact.absolute_path, arcname=artifact.archive_path)
83
+ print(f"Zip file created at: {zip_path}")
84
+ return zip_path
85
+ except Exception as e:
86
+ print(f"Error creating artifacts zip file: {e}")
87
+ raise e
88
+
89
+ def create_json(self, json_filename: Optional[str] = None) -> Path:
90
+ """
91
+ Create a JSON file containing the collected artifacts.
92
+ Args:
93
+ json_filename: Optional custom name for the JSON file (without extension).
94
+ If None, defaults to "artifacts.json"
95
+ Returns:
96
+ Path: The path to the created JSON file.
97
+ Raises:
98
+ Exception: If there is an error creating the JSON file.
99
+ """
100
+ if json_filename is None:
101
+ json_path = self.build_dir / "artifacts.json"
102
+ else:
103
+ # Ensure the filename has .json extension
104
+ if not json_filename.endswith(".json"):
105
+ json_filename += ".json"
106
+ json_path = self.build_dir / json_filename
107
+
108
+ # Delete the file if it already exists
109
+ if json_path.exists():
110
+ json_path.unlink()
111
+
112
+ try:
113
+ json_content = {
114
+ "artifacts": [str(artifact.archive_path.as_posix()) for artifact in self.archive_artifacts],
115
+ }
116
+ json_path.write_text(json.dumps(json_content, indent=4))
117
+ return json_path
118
+ except Exception as e:
119
+ print(f"Error creating artifacts JSON file: {e}")
120
+ raise e
@@ -9,6 +9,11 @@ from spl_core.test_utils.spl_build import SplBuild
9
9
 
10
10
 
11
11
  class BaseVariantTestRunner(ABC):
12
+ """
13
+ Obsolete class for running tests on a specific variant of the SPL.
14
+ Instead use SplBuild directly in your test cases.
15
+ """
16
+
12
17
  @property
13
18
  def variant(self) -> str:
14
19
  return re.sub(r"^Test_", "", self.__class__.__name__).replace("__", "/")
@@ -12,11 +12,15 @@ from spl_core.common.command_line_executor import CommandLineExecutor
12
12
 
13
13
  @dataclass
14
14
  class ArchiveArtifact:
15
+ """Obsolete class for storing archive artifacts."""
16
+
15
17
  archive_path: Path
16
18
  absolute_path: Path
17
19
 
18
20
 
19
21
  class ArtifactsCollection:
22
+ """Obsolete class for collecting artifacts to be archived."""
23
+
20
24
  def __init__(self, artifacts: List[Path], build_dir: Path):
21
25
  self.archive_artifacts: List[ArchiveArtifact] = []
22
26
  for artifact in artifacts:
@@ -161,7 +165,7 @@ class SplBuild:
161
165
 
162
166
  def create_artifacts_archive(self, expected_artifacts: List[Path]) -> Path:
163
167
  """
164
- Create a zip file containing the collected artifacts.
168
+ Obsolete method for creating an archive of artifacts.
165
169
 
166
170
  Args:
167
171
  expected_artifacts: List of Path of artifacts which should be archived
@@ -192,7 +196,7 @@ class SplBuild:
192
196
 
193
197
  def create_artifacts_json(self, expected_artifacts: List[Path]) -> Path:
194
198
  """
195
- Create a JSON file listing the collected artifacts.
199
+ Obsolete method to create a JSON file listing the collected artifacts.
196
200
 
197
201
  Returns:
198
202
  Path: The path to the created JSON file.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: spl-core
3
- Version: 7.5.1
3
+ Version: 7.6.0
4
4
  Summary: Software Product Line Support for CMake
5
5
  License: MIT
6
6
  Author: Avengineers
@@ -1,4 +1,4 @@
1
- spl_core/__init__.py,sha256=7vQ6Qcfa2cKVApeGf8DgZrqPj1SIk9k4gQziWrjB-ug,22
1
+ spl_core/__init__.py,sha256=RS7ZvpeTsPTr9tY3yeVA3qW0ISlF5jRmARJfzG9UJLs,22
2
2
  spl_core/__run.py,sha256=DphnN7_Bjiw_mOOztsHxTDHS8snz1g2MMWAaJpZxPKM,361
3
3
  spl_core/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  spl_core/common/command_line_executor.py,sha256=GHIMpNiMD_eP44vq7L_HiC08aKt7lgW_wn_omU6REwQ,2217
@@ -60,10 +60,11 @@ spl_core/kickstart/templates/project/tools/toolchains/clang/toolchain.cmake,sha2
60
60
  spl_core/kickstart/templates/project/tools/toolchains/gcc/toolchain.cmake,sha256=AmLzPyhTgfc_Dsre4AlsvSOkVGW6VswWvrEnUL8JLhA,183
61
61
  spl_core/main.py,sha256=_hL4j155WZMXog_755bgAH1PeUwvTdJZvVdVw9EWhvo,1225
62
62
  spl_core/spl.cmake,sha256=W8h-Zj-N302qxMrRG8MhoEkJ0io92bWGp4Y5r8LBQnc,4535
63
- spl_core/test_utils/base_variant_test_runner.py,sha256=0q3jejtj4aEPnlK2mTsgVEaxMP6TZ3Isq-JqZvBeZNo,3653
64
- spl_core/test_utils/spl_build.py,sha256=wRCtCgnptQaB4Tc_shAmcjJid9mxdYLR910G-PTL9TI,8090
65
- spl_core-7.5.1.dist-info/LICENSE,sha256=UjjA0o8f5tT3wVm7qodTLAhPWLl6kgVyn9FPAd1VeYY,1099
66
- spl_core-7.5.1.dist-info/METADATA,sha256=WxByLTGkaMnj8OggCewHYYfmgovm_QTHYtQKUtNH81o,5157
67
- spl_core-7.5.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
68
- spl_core-7.5.1.dist-info/entry_points.txt,sha256=18_sdVY93N1GVBiAHxQ_F9ZM-bBvOmVMOMn7PNe2EqU,45
69
- spl_core-7.5.1.dist-info/RECORD,,
63
+ spl_core/test_utils/archive_artifacts_collection.py,sha256=x7LH5dGIvssyhXsTFzB6rjgb5D2efKvHVpnjId3MNDk,5126
64
+ spl_core/test_utils/base_variant_test_runner.py,sha256=Oq27lkJlpB_y-p2_8S23F5zjn1438HW148q-hQNz3EY,3795
65
+ spl_core/test_utils/spl_build.py,sha256=o3MCWYRb769bXut_9EM_ZEweRKH7SSAuajh9277mKuI,8233
66
+ spl_core-7.6.0.dist-info/LICENSE,sha256=UjjA0o8f5tT3wVm7qodTLAhPWLl6kgVyn9FPAd1VeYY,1099
67
+ spl_core-7.6.0.dist-info/METADATA,sha256=Huw1KNDwaxEKkGMYwclTYg3cg_n-8HU6KfbTmXRktko,5157
68
+ spl_core-7.6.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
69
+ spl_core-7.6.0.dist-info/entry_points.txt,sha256=18_sdVY93N1GVBiAHxQ_F9ZM-bBvOmVMOMn7PNe2EqU,45
70
+ spl_core-7.6.0.dist-info/RECORD,,