Skip to content

Commit 2b60ced

Browse files
committed
Merge branch 'main' into bits
2 parents 5abc3f2 + a04ab75 commit 2b60ced

File tree

16 files changed

+404
-45
lines changed

16 files changed

+404
-45
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ dependencies = [
3333

3434
[project.optional-dependencies]
3535
test = ["pytest", "pytest-cov", "django", "streamlit", "copier", "jinja2-time", "flask",
36-
"maturin", "uv"]
36+
"maturin", "uv", "briefcase"]
3737
qt = ["pyqt>5,<6", "pyqtwebengin>5,<6"]
3838

3939
[project.scripts]

src/projspec/artifact/base.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import logging
2-
import subprocess
32
from typing import Literal
43

54
import fsspec.implementations.local
65

76
from projspec.config import get_conf
87
from projspec.proj import Project
9-
from projspec.utils import camel_to_snake, is_installed
8+
from projspec.utils import camel_to_snake, is_installed, run_subprocess
109

1110
logger = logging.getLogger("projspec")
1211
registry = {}
@@ -57,7 +56,7 @@ def make(self, *args, **kwargs):
5756

5857
def _make(self, *args, **kwargs):
5958
logger.info("running %s", self.cmd)
60-
subprocess.check_call(self.cmd, cwd=self.proj.url, **kwargs)
59+
run_subprocess(self.cmd, cwd=self.proj.url, output=False, **kwargs)
6160

6261
def remake(self):
6362
"""Recreate the artifact and any runtime it depends on"""

src/projspec/artifact/container.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import subprocess
2-
31
from projspec.proj.base import Project, ProjectExtra
42
from projspec.artifact import BaseArtifact
3+
from projspec.utils import run_subprocess
54

65

76
class DockerImage(BaseArtifact):
@@ -28,16 +27,19 @@ def _make(self, *args, **kwargs) -> None:
2827
:param args: added to the docker run command
2928
:param kwargs: affect the docker run subprocess call
3029
"""
31-
out = subprocess.check_output(self.cmd, cwd=self.proj.url, **kwargs)
30+
out = run_subprocess(self.cmd, cwd=self.proj.url, **kwargs).stdout
3231
if self.tag:
33-
subprocess.check_call(["docker", "run", self.tag])
32+
run_subprocess(["docker", "run", self.tag], cwd=self.proj.url, output=False)
3433
else:
3534
lines = [
3635
l for l in out.splitlines() if l.startswith(b"Successfully built ")
3736
]
3837
img = lines[-1].split()[-1]
39-
subprocess.check_call(
40-
["docker", "run", img.decode()] + list(args), **kwargs
38+
run_subprocess(
39+
["docker", "run", img.decode()] + list(args),
40+
cwd=self.proj.url,
41+
output=False,
42+
**kwargs,
4143
)
4244

4345

src/projspec/artifact/installable.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
from enum import auto
22
import logging
33
import os.path
4-
import subprocess
54
from platform import architecture
65

76
from projspec.artifact import FileArtifact
8-
from projspec.utils import Enum
7+
from projspec.utils import Enum, run_subprocess
98

109
logger = logging.getLogger("projspec")
1110

@@ -54,7 +53,7 @@ def _make(self, *args, **kwargs):
5453
import re
5554

5655
logger.debug(" ".join(self.cmd))
57-
out = subprocess.check_output(self.cmd).decode("utf-8")
56+
out = run_subprocess(self.cmd, cwd=self.proj.url).stdout.decode("utf-8")
5857
if fn := re.match(r"'(.*?\.conda)'\n", out):
5958
if os.path.exists(fn.group(1)):
6059
self.fn = fn.group(1)

src/projspec/artifact/process.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
from projspec.artifact import BaseArtifact
1313
from projspec.config import get_conf
14+
from projspec.utils import run_subprocess
1415

1516

1617
logger = logging.getLogger("projspec")
@@ -51,9 +52,10 @@ def _make(self, enqueue=True, **kwargs):
5152
kwargs["stdout"] = subprocess.PIPE
5253
kwargs["stderr"] = subprocess.STDOUT
5354
kwargs["close_fds"] = ON_POSIX
54-
proc = subprocess.Popen(
55+
proc = run_subprocess(
5556
self.cmd,
5657
cwd=self.proj.url,
58+
popen=True,
5759
**kwargs,
5860
)
5961
if enq:

src/projspec/artifact/python_env.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
"""
77

88
import json
9-
import subprocess
109
from functools import cache
1110

1211
from projspec.artifact import FileArtifact
12+
from projspec.utils import run_subprocess
1313

1414

1515
class CondaEnv(FileArtifact):
@@ -27,7 +27,7 @@ class CondaEnv(FileArtifact):
2727
def envs() -> list[str]:
2828
"""Global conda env root paths"""
2929
# pixi also has global envs
30-
out = subprocess.check_output(["conda", "env", "list", "--json"])
30+
out = run_subprocess(["conda", "env", "list", "--json"]).stdout
3131
return json.loads(out.decode())["envs"]
3232

3333

src/projspec/proj/briefcase.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import os
2+
13
from projspec.proj import ProjectSpec
2-
from projspec.utils import AttrDict
4+
from projspec.utils import AttrDict, run_subprocess, make_and_copy
35

46

57
def supported(apps: dict, app: str, *config) -> bool:
@@ -162,3 +164,9 @@ def parse(self) -> None:
162164
"zip",
163165
],
164166
)
167+
168+
@staticmethod
169+
def _create(path: str) -> None:
170+
# TODO: this version will overwrite any pyproject.toml
171+
with make_and_copy(path, sub="helloworld", mkdir=True) as tmp:
172+
run_subprocess(["briefcase", "new", "--no-input"], cwd=tmp, output=False)

src/projspec/proj/git.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import subprocess
2-
31
from projspec.proj.base import ProjectSpec
4-
from projspec.utils import AttrDict
2+
from projspec.utils import AttrDict, run_subprocess
53

64

75
class GitRepo(ProjectSpec):
@@ -17,7 +15,7 @@ def match(self) -> bool:
1715

1816
@staticmethod
1917
def _create(path: str) -> None:
20-
subprocess.check_call(["git", "init", path])
18+
run_subprocess(["git", "init"], cwd=path, output=False)
2119

2220
def parse(self) -> None:
2321
# It's faster to read the /.git/config file for branches, remotes and URLs;

src/projspec/proj/node.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from projspec.proj.base import ProjectSpec, ParseFailed
44
from projspec.content.package import NodePackage
55
from projspec.artifact.process import Process
6+
from projspec.utils import run_subprocess
67
from projspec.content.executable import Command
78
from projspec.utils import AttrDict
89

@@ -195,8 +196,6 @@ def parse(self):
195196
# create() with https://github.com/jupyterlab/extension-template
196197
@staticmethod
197198
def _create(path: str, name: str | None = None) -> None:
198-
import subprocess
199-
200199
# this is a highly opinionated template
201200
cmd = [
202201
"copier",
@@ -212,4 +211,4 @@ def _create(path: str, name: str | None = None) -> None:
212211
"https://github.com/jupyterlab/extension-template",
213212
path,
214213
]
215-
subprocess.check_call(cmd, cwd=path)
214+
run_subprocess(cmd, cwd=path, output=False)

src/projspec/proj/rust.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import subprocess
2-
31
import toml
42
from projspec.proj import ProjectSpec, PythonLibrary
5-
from projspec.utils import AttrDict
3+
from projspec.utils import AttrDict, run_subprocess
64

75

86
class Rust(ProjectSpec):
@@ -39,7 +37,7 @@ def parse(self):
3937

4038
@staticmethod
4139
def _create(path: str) -> None:
42-
subprocess.check_call(["cargo", "init"], cwd=path)
40+
run_subprocess(["cargo", "init"], cwd=path, output=False)
4341

4442

4543
class RustPython(Rust, PythonLibrary):
@@ -69,4 +67,6 @@ def parse(self):
6967
def _create(path: str) -> None:
7068
# will fail for existing python libraries, since it doesn't want to edit
7169
# the pyproject.toml build backend.
72-
subprocess.check_call(["maturin", "init", "-b", "pyo3", "--mixed"], cwd=path)
70+
run_subprocess(
71+
["maturin", "init", "-b", "pyo3", "--mixed"], cwd=path, output=False
72+
)

0 commit comments

Comments
 (0)