py-app-dev 2.2.0__tar.gz → 2.3.1__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.1
2
2
  Name: py-app-dev
3
- Version: 2.2.0
3
+ Version: 2.3.1
4
4
  Summary: My application development modules.
5
5
  Home-page: https://github.com/cuinixam/python-app-dev
6
6
  License: MIT
@@ -16,6 +16,7 @@ Classifier: Programming Language :: Python :: 3
16
16
  Classifier: Programming Language :: Python :: 3.10
17
17
  Classifier: Programming Language :: Python :: 3.11
18
18
  Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
19
20
  Classifier: Topic :: Software Development :: Libraries
20
21
  Requires-Dist: loguru (>=0.7.1,<0.8.0)
21
22
  Requires-Dist: mashumaro (>=3.9.1,<4.0.0)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "py-app-dev"
3
- version = "2.2.0"
3
+ version = "2.3.1"
4
4
  description = "My application development modules."
5
5
  authors = ["cuinixam <me@cuinixam.com>"]
6
6
  license = "MIT"
@@ -0,0 +1 @@
1
+ __version__ = "2.3.1"
@@ -10,6 +10,9 @@ from .logging import logger
10
10
 
11
11
 
12
12
  class Runnable(ABC):
13
+ def __init__(self, needs_dependency_management: bool = True) -> None:
14
+ self.needs_dependency_management = needs_dependency_management
15
+
13
16
  @abstractmethod
14
17
  def run(self) -> int:
15
18
  """Run and return exit code."""
@@ -115,6 +118,12 @@ class Executor:
115
118
  return RunInfoStatus.MATCH
116
119
 
117
120
  def execute(self, runnable: Runnable) -> int:
121
+ if not runnable.needs_dependency_management:
122
+ logger.info(f"Runnable '{runnable.get_name()}' does not need dependency management. Executing directly.")
123
+ if self.dry_run:
124
+ return 0
125
+ return runnable.run()
126
+
118
127
  run_info_status = self.previous_run_info_matches(runnable)
119
128
  if run_info_status.should_run:
120
129
  logger.info(f"Runnable '{runnable.get_name()}' must run. {run_info_status.message}")
@@ -1,4 +1,5 @@
1
1
  import json
2
+ import os
2
3
  import re
3
4
  from concurrent.futures import ThreadPoolExecutor, as_completed
4
5
  from dataclasses import dataclass, field
@@ -85,9 +86,9 @@ class InstalledScoopApp(InstalledApp):
85
86
 
86
87
  class ScoopWrapper:
87
88
  def __init__(self) -> None:
88
- self.scoop_executable = self._find_scoop_executable()
89
- self.scoop_root_dir = self._find_scoop_root_dir(self.scoop_executable)
90
89
  self.logger = logger.bind()
90
+ self.scoop_script = self._find_scoop_script()
91
+ self.scoop_root_dir = self._find_scoop_root_dir(self.scoop_script)
91
92
 
92
93
  @property
93
94
  def apps_directory(self) -> Path:
@@ -101,12 +102,16 @@ class ScoopWrapper:
101
102
  """
102
103
  return self.do_install(ScoopInstallConfigFile.from_file(scoop_file), self.get_installed_apps())
103
104
 
104
- def _find_scoop_executable(self) -> Path:
105
+ def _find_scoop_script(self) -> Path:
105
106
  scoop_path = which("scoop")
106
107
  if not scoop_path:
107
- scoop_path = Path().home().joinpath("scoop", "shims", "scoop.cmd")
108
- if not scoop_path.is_file():
109
- raise UserNotificationException("Scoop not found in PATH or user home directory." " Please install Scoop and run the build script again.")
108
+ scoop_path = Path().home().joinpath("scoop", "shims", "scoop.ps1")
109
+ else:
110
+ # Use the powershell script to make sure the powershell profile is loaded (maybe there are proxy settings)
111
+ scoop_path = scoop_path.with_suffix(".ps1")
112
+ self.logger.info(f"Scoop executable: {scoop_path}")
113
+ if not scoop_path.is_file():
114
+ raise UserNotificationException("Scoop not found in PATH or user home directory. Please install Scoop and run the build script again.")
110
115
  return scoop_path
111
116
 
112
117
  def _find_scoop_root_dir(self, scoop_executable_path: Path) -> Path:
@@ -204,7 +209,11 @@ class ScoopWrapper:
204
209
  with TemporaryDirectory() as tmp_dir:
205
210
  tmp_scoop_file = Path(tmp_dir).joinpath("scoopfile.json")
206
211
  ScoopInstallConfigFile(scoop_install_config.buckets, apps_to_install).to_file(tmp_scoop_file)
207
- SubprocessExecutor([self.scoop_executable, "import", tmp_scoop_file]).execute()
212
+ # (!) Make sure powershell core module does not pollute the module path. Without this change scoop.ps1 fails because 'Get-FileHash' cannot be found.
213
+ # See more details here: https://github.com/PowerShell/PowerShell/issues/8635
214
+ env = os.environ.copy()
215
+ env["PSModulePath"] = f"{env.get('PSHOME', '')}/Modules"
216
+ SubprocessExecutor(["powershell.exe", self.scoop_script, "import", tmp_scoop_file], env=env).execute()
208
217
  return apps_to_install
209
218
 
210
219
  @staticmethod
@@ -1 +0,0 @@
1
- __version__ = "2.2.0"
File without changes
File without changes