primitive 0.1.76__py3-none-any.whl → 0.1.78__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.
primitive/__about__.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # SPDX-FileCopyrightText: 2024-present Dylan Stein <dylan@primitive.tech>
2
2
  #
3
3
  # SPDX-License-Identifier: MIT
4
- __version__ = "0.1.76"
4
+ __version__ = "0.1.78"
@@ -1,7 +1,11 @@
1
+ from typing import List
2
+ from pathlib import Path
1
3
  from subprocess import Popen, PIPE
2
4
  import shlex
5
+ import glob
3
6
  import selectors
4
7
  from loguru import logger
8
+ from abc import abstractmethod
5
9
 
6
10
 
7
11
  class Process:
@@ -11,7 +15,9 @@ class Process:
11
15
  env,
12
16
  workdir: str = ".",
13
17
  ):
14
- self.cmd = shlex.split(cmd)
18
+ self.cmd = Process.expand_glob_in_cmd(
19
+ cmd_parts=shlex.split(cmd), workdir=workdir
20
+ )
15
21
  self.env = env
16
22
  self.workdir = workdir
17
23
  self.process = None
@@ -90,6 +96,24 @@ class Process:
90
96
  if self.process:
91
97
  self.process.kill()
92
98
 
99
+ @abstractmethod
100
+ def expand_glob_in_cmd(cmd_parts: List[str], workdir: Path):
101
+ # Characters that indicate a glob pattern
102
+ glob_chars = {"*", "?", "[", "]", "{", "}"}
103
+ expanded_cmd = []
104
+ for part in cmd_parts:
105
+ if any(c in part for c in glob_chars):
106
+ matches = glob.glob(str(workdir / part))
107
+ if matches:
108
+ expanded_cmd.extend(
109
+ [str(Path(match).relative_to(workdir)) for match in matches]
110
+ )
111
+ else:
112
+ expanded_cmd.append(part)
113
+ else:
114
+ expanded_cmd.append(part)
115
+ return expanded_cmd
116
+
93
117
  @property
94
118
  def errors(self) -> int:
95
119
  return self._errors
primitive/agent/runner.py CHANGED
@@ -48,7 +48,6 @@ class AgentRunner:
48
48
  job_slug: str,
49
49
  max_log_size: int = 10 * 1024 * 1024,
50
50
  log_to_file: bool = True,
51
- job: Optional[JobDescription] = None,
52
51
  ) -> None:
53
52
  self.primitive = primitive
54
53
  self.source_dir = source_dir
@@ -69,37 +68,33 @@ class AgentRunner:
69
68
  format=AgentRunner.log_serializer(),
70
69
  )
71
70
 
72
- # Attempt to load job from file
73
- if not job:
74
- logger.info(f"Scanning directory for job file {self.job_slug}")
75
- yaml_file = Path(self.source_dir / ".primitive" / f"{self.job_slug}.yaml")
76
- yml_file = Path(self.source_dir / ".primitive" / f"{self.job_slug}.yml")
71
+ logger.info(f"Scanning directory for job file {self.job_slug}")
72
+ yaml_file = Path(self.source_dir / ".primitive" / f"{self.job_slug}.yaml")
73
+ yml_file = Path(self.source_dir / ".primitive" / f"{self.job_slug}.yml")
77
74
 
78
- if yaml_file.exists() and yml_file.exists():
79
- logger.error(
80
- f"Found two job descriptions with the same slug: {self.job_slug}"
81
- )
82
- self.primitive.jobs.job_run_update(
83
- self.job_id, status="request_completed", conclusion="failure"
84
- )
85
- raise FileExistsError
86
-
87
- if yaml_file.exists():
88
- self.job = yaml.load(open(yaml_file, "r"), Loader=Loader)
89
- elif yml_file.exists():
90
- self.job = yaml.load(open(yml_file, "r"), Loader=Loader)
91
- else:
92
- logger.error(
93
- f"No job description with matching slug '{self.job_slug}' found"
94
- )
95
- self.primitive.jobs.job_run_update(
96
- self.job_id, status="request_completed", conclusion="failure"
97
- )
98
- raise FileNotFoundError
75
+ if yaml_file.exists() and yml_file.exists():
76
+ logger.error(
77
+ f"Found two job descriptions with the same slug: {self.job_slug}"
78
+ )
79
+ self.primitive.jobs.job_run_update(
80
+ self.job_id, status="request_completed", conclusion="failure"
81
+ )
82
+ raise FileExistsError
99
83
 
100
- logger.info(f"Found job description for {self.job_slug}")
84
+ if yaml_file.exists():
85
+ self.job = yaml.load(open(yaml_file, "r"), Loader=Loader)
86
+ elif yml_file.exists():
87
+ self.job = yaml.load(open(yml_file, "r"), Loader=Loader)
101
88
  else:
102
- self.job = job
89
+ logger.error(
90
+ f"No job description with matching slug '{self.job_slug}' found"
91
+ )
92
+ self.primitive.jobs.job_run_update(
93
+ self.job_id, status="request_completed", conclusion="failure"
94
+ )
95
+ raise FileNotFoundError
96
+
97
+ logger.info(f"Found job description for {self.job_slug}")
103
98
 
104
99
  @staticmethod
105
100
  def log_serializer() -> Callable:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: primitive
3
- Version: 0.1.76
3
+ Version: 0.1.78
4
4
  Project-URL: Documentation, https://github.com//primitivecorp/primitive-cli#readme
5
5
  Project-URL: Issues, https://github.com//primitivecorp/primitive-cli/issues
6
6
  Project-URL: Source, https://github.com//primitivecorp/primitive-cli
@@ -98,19 +98,10 @@ git config --global user.name “<firstName lastName>”
98
98
  brew install make
99
99
  fish_add_path /opt/homebrew/opt/make/libexec/gnubin
100
100
 
101
- # install pyenv (python version manager)
102
- brew install pyenv
103
- set -Ux PYENV_ROOT $HOME/.pyenv
104
- fish_add_path $PYENV_ROOT/bin
105
- echo 'pyenv init - | source' >> ~/.config/fish/config.fish
106
-
107
- # install the latest version of python
108
- pyenv install 3.12.2
109
- pyenv global 3.12.2
110
- pip install --upgrade pip
111
-
112
101
  # install uv
113
- pip install uv
102
+ curl -LsSf https://astral.sh/uv/install.sh | sh
103
+ uv python install
104
+ fish_add_path "$(uv python dir)/bin"
114
105
  ```
115
106
 
116
107
  ### Repository Setup
@@ -1,13 +1,13 @@
1
- primitive/__about__.py,sha256=EYbYfJTot30aqVJWBENADheY8VcBhNRZTzkewjATzNc,130
1
+ primitive/__about__.py,sha256=8gbR_hS2TXmTT8fMyHO_YgVOC1s2J-DqRmh7UU5Z5dU,130
2
2
  primitive/__init__.py,sha256=bwKdgggKNVssJFVPfKSxqFMz4IxSr54WWbmiZqTMPNI,106
3
3
  primitive/cli.py,sha256=CiI60bG3UZyNFuLTpchr0KeJRG5SALj455Ob11CegGE,2412
4
4
  primitive/client.py,sha256=PPyIQRvKKSqCF9RRF5mJJ4Vqqolpzy1YXqffNLKIvAA,2390
5
5
  primitive/agent/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  primitive/agent/actions.py,sha256=Hosy2o2FntfBtcNqqHuMFq9dm99EVfySy0v2JGeufvc,6474
7
7
  primitive/agent/commands.py,sha256=-dVDilELfkGfbZB7qfEPs77Dm1oT62qJj4tsIk4KoxI,254
8
- primitive/agent/process.py,sha256=7o8axjJ1OauKaFBL0jbZL9tGlZdZbDCXAdT5F-S_XQ8,2541
8
+ primitive/agent/process.py,sha256=4dpuO4cZg_SYi0kCoZJrm-ugB_mAnxYWaNbIyUHkoII,3395
9
9
  primitive/agent/provision.py,sha256=rmwnro1K5F8mwtd45XAq7RVQmpDWnbBCQ8X_qgWhm3M,1546
10
- primitive/agent/runner.py,sha256=b2Rdm44-w_1_uMwODjrfMvb75n8vVmCTDsvaiiU7-d8,8442
10
+ primitive/agent/runner.py,sha256=rJq-UE1ONc2uMdymxAes72q9kiSQPESvOOfgpSxXEIg,8199
11
11
  primitive/agent/uploader.py,sha256=OkgwXhWKoECOJnW_ZmpzmUS_cpb-orC_uebNcmf5byw,2948
12
12
  primitive/auth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  primitive/auth/actions.py,sha256=MPsG9LcKcOPwA7gZ9Ewk0PZJhTQvIrGfODdz4GxSzgA,999
@@ -90,8 +90,8 @@ primitive/utils/memory_size.py,sha256=4xfha21kW82nFvOTtDFx9Jk2ZQoEhkfXii-PGNTpIU
90
90
  primitive/utils/printer.py,sha256=f1XUpqi5dkTL3GWvYRUGlSwtj2IxU1q745T4Fxo7Tn4,370
91
91
  primitive/utils/shell.py,sha256=j7E1YwgNWw57dFHVfEbqRNVcPHX0xDefX2vFSNgeI_8,1648
92
92
  primitive/utils/verible.py,sha256=Zb5NUISvcaIgEvgCDBWr-GCoceMa79Tcwvr5Wl9lfnA,2252
93
- primitive-0.1.76.dist-info/METADATA,sha256=zXs0TSPKi3K2exL-kdRFHNEWv1YVWd8MLg-xNLC4wxY,3843
94
- primitive-0.1.76.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
95
- primitive-0.1.76.dist-info/entry_points.txt,sha256=p1K8DMCWka5FqLlqP1sPek5Uovy9jq8u51gUsP-z334,48
96
- primitive-0.1.76.dist-info/licenses/LICENSE.txt,sha256=B8kmQMJ2sxYygjCLBk770uacaMci4mPSoJJ8WoDBY_c,1098
97
- primitive-0.1.76.dist-info/RECORD,,
93
+ primitive-0.1.78.dist-info/METADATA,sha256=Lg0DHnkK_9k1gZyRk-BfxOf_Vu6EfgLkBarZTAyiGww,3642
94
+ primitive-0.1.78.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
95
+ primitive-0.1.78.dist-info/entry_points.txt,sha256=p1K8DMCWka5FqLlqP1sPek5Uovy9jq8u51gUsP-z334,48
96
+ primitive-0.1.78.dist-info/licenses/LICENSE.txt,sha256=B8kmQMJ2sxYygjCLBk770uacaMci4mPSoJJ8WoDBY_c,1098
97
+ primitive-0.1.78.dist-info/RECORD,,