Skip to content

Commit 77469fa

Browse files
authored
Merge pull request #88 from vkottler/dev/3.0.3
3.0.3 - Fix 'download' command
2 parents 7c801e0 + 7c68bef commit 77469fa

File tree

8 files changed

+37
-16
lines changed

8 files changed

+37
-16
lines changed

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ jobs:
9090
9191
- run: |
9292
mk python-release owner=vkottler \
93-
repo=yambs version=3.0.2
93+
repo=yambs version=3.0.3
9494
if: |
9595
matrix.python-version == '3.11'
9696
&& matrix.system == 'ubuntu-latest'

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
=====================================
33
generator=datazen
44
version=3.1.4
5-
hash=72271a00d30bf23159c35289b5ff7a00
5+
hash=934a1cb8be74864c521e3c3d3875e01d
66
=====================================
77
-->
88

9-
# yambs ([3.0.2](https://pypi.org/project/yambs/))
9+
# yambs ([3.0.3](https://pypi.org/project/yambs/))
1010

1111
[![python](https://img.shields.io/pypi/pyversions/yambs.svg)](https://pypi.org/project/yambs/)
1212
![Build Status](https://github.com/vkottler/yambs/workflows/Python%20Package/badge.svg)
@@ -216,7 +216,7 @@ options:
216216
repository owner (default: 'vkottler')
217217
-r REPO, --repo REPO repository name (default: 'toolchains')
218218
-O OUTPUT, --output OUTPUT
219-
output directory (default: 'toolchains')
219+
output directory (default: '.')
220220
-p PATTERN, --pattern PATTERN
221221
a pattern to use to select project specifications
222222
filtered by name

local/variables/package.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
22
major: 3
33
minor: 0
4-
patch: 2
4+
patch: 3
55
entry: mbs

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta:__legacy__"
44

55
[project]
66
name = "yambs"
7-
version = "3.0.2"
7+
version = "3.0.3"
88
description = "Yet another meta build-system."
99
readme = "README.md"
1010
requires-python = ">=3.11"

tests/commands/test_download.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
# built-in
6+
import platform
67
from tempfile import TemporaryDirectory
78

89
# module under test
@@ -14,4 +15,16 @@ def test_download_basic():
1415
"""Test the 'download' command."""
1516

1617
with TemporaryDirectory() as tmpdir:
17-
assert yambs_main([PKG_NAME, "-C", str(tmpdir), "download"]) == 0
18+
assert (
19+
yambs_main(
20+
[
21+
PKG_NAME,
22+
"-C",
23+
str(tmpdir),
24+
"download",
25+
"-p",
26+
platform.machine(),
27+
]
28+
)
29+
== 0
30+
)

yambs/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# =====================================
22
# generator=datazen
33
# version=3.1.4
4-
# hash=d1fc72b413b5923198b146f188381f34
4+
# hash=1229207e5be7a4167912254256ebd6a2
55
# =====================================
66

77
"""
@@ -10,4 +10,4 @@
1010

1111
DESCRIPTION = "Yet another meta build-system."
1212
PKG_NAME = "yambs"
13-
VERSION = "3.0.2"
13+
VERSION = "3.0.3"

yambs/commands/download.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,19 @@
1313
# internal
1414
from yambs.dependency.github import GithubDependency, default_filt
1515

16+
DEFAULT_PATTERN = ".*"
17+
1618

1719
def download_cmd(args: _Namespace) -> int:
1820
"""Execute the download command."""
1921

2022
dep = GithubDependency(args.owner, args.repo)
2123

2224
# Download and extract things.
25+
args.output.mkdir(parents=True, exist_ok=True)
2326
dep.download_release_assets(
24-
default_filt(args.output, pattern=args.pattern)
27+
default_filt(args.output.joinpath(args.repo), pattern=args.pattern),
28+
strict=args.pattern == DEFAULT_PATTERN,
2529
)
2630

2731
return 0
@@ -46,13 +50,13 @@ def add_download_cmd(parser: _ArgumentParser) -> _CommandFunction:
4650
"-O",
4751
"--output",
4852
type=Path,
49-
default=Path("toolchains"),
53+
default=Path(),
5054
help="output directory (default: '%(default)s')",
5155
)
5256
parser.add_argument(
5357
"-p",
5458
"--pattern",
55-
default=".*",
59+
default=DEFAULT_PATTERN,
5660
help=(
5761
"a pattern to use to select project "
5862
"specifications filtered by name"

yambs/dependency/github.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ def filt(asset: dict[str, Any]) -> Optional[Path]:
5454
return filt
5555

5656

57-
def ensure_extracted(path: Path, logger: LoggerType = None) -> None:
57+
def ensure_extracted(
58+
path: Path, strict: bool = True, logger: LoggerType = None
59+
) -> None:
5860
"""Ensure that all archive files in a directory are extracted."""
5961

6062
for item in path.iterdir():
@@ -75,7 +77,7 @@ def ensure_extracted(path: Path, logger: LoggerType = None) -> None:
7577
nano_str(result[1], is_time=True),
7678
)
7779

78-
assert dest.is_dir(), dest
80+
assert not strict or dest.is_dir(), dest
7981

8082

8183
class GithubDependency(LoggerMixin):
@@ -111,7 +113,7 @@ def __init__(
111113
}
112114

113115
def download_release_assets(
114-
self, filt: AssetFilter, extract: bool = True
116+
self, filt: AssetFilter, extract: bool = True, strict: bool = True
115117
) -> None:
116118
"""Ensure release assets are downloaded."""
117119

@@ -121,4 +123,6 @@ def download_release_assets(
121123
download_file_if_missing(asset["browser_download_url"], dest)
122124

123125
if extract:
124-
ensure_extracted(dest.parent, logger=self.logger)
126+
ensure_extracted(
127+
dest.parent, strict=strict, logger=self.logger
128+
)

0 commit comments

Comments
 (0)