Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.0.3 - Fix 'download' command #88

Merged
merged 1 commit into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:

- run: |
mk python-release owner=vkottler \
repo=yambs version=3.0.2
repo=yambs version=3.0.3
if: |
matrix.python-version == '3.11'
&& matrix.system == 'ubuntu-latest'
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
=====================================
generator=datazen
version=3.1.4
hash=72271a00d30bf23159c35289b5ff7a00
hash=934a1cb8be74864c521e3c3d3875e01d
=====================================
-->

# yambs ([3.0.2](https://pypi.org/project/yambs/))
# yambs ([3.0.3](https://pypi.org/project/yambs/))

[![python](https://img.shields.io/pypi/pyversions/yambs.svg)](https://pypi.org/project/yambs/)
![Build Status](https://github.com/vkottler/yambs/workflows/Python%20Package/badge.svg)
Expand Down Expand Up @@ -216,7 +216,7 @@ options:
repository owner (default: 'vkottler')
-r REPO, --repo REPO repository name (default: 'toolchains')
-O OUTPUT, --output OUTPUT
output directory (default: 'toolchains')
output directory (default: '.')
-p PATTERN, --pattern PATTERN
a pattern to use to select project specifications
filtered by name
Expand Down
2 changes: 1 addition & 1 deletion local/variables/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
major: 3
minor: 0
patch: 2
patch: 3
entry: mbs
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta:__legacy__"

[project]
name = "yambs"
version = "3.0.2"
version = "3.0.3"
description = "Yet another meta build-system."
readme = "README.md"
requires-python = ">=3.11"
Expand Down
15 changes: 14 additions & 1 deletion tests/commands/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

# built-in
import platform
from tempfile import TemporaryDirectory

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

with TemporaryDirectory() as tmpdir:
assert yambs_main([PKG_NAME, "-C", str(tmpdir), "download"]) == 0
assert (
yambs_main(
[
PKG_NAME,
"-C",
str(tmpdir),
"download",
"-p",
platform.machine(),
]
)
== 0
)
4 changes: 2 additions & 2 deletions yambs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# =====================================
# generator=datazen
# version=3.1.4
# hash=d1fc72b413b5923198b146f188381f34
# hash=1229207e5be7a4167912254256ebd6a2
# =====================================

"""
Expand All @@ -10,4 +10,4 @@

DESCRIPTION = "Yet another meta build-system."
PKG_NAME = "yambs"
VERSION = "3.0.2"
VERSION = "3.0.3"
10 changes: 7 additions & 3 deletions yambs/commands/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,19 @@
# internal
from yambs.dependency.github import GithubDependency, default_filt

DEFAULT_PATTERN = ".*"


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

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

# Download and extract things.
args.output.mkdir(parents=True, exist_ok=True)
dep.download_release_assets(
default_filt(args.output, pattern=args.pattern)
default_filt(args.output.joinpath(args.repo), pattern=args.pattern),
strict=args.pattern == DEFAULT_PATTERN,
)

return 0
Expand All @@ -46,13 +50,13 @@ def add_download_cmd(parser: _ArgumentParser) -> _CommandFunction:
"-O",
"--output",
type=Path,
default=Path("toolchains"),
default=Path(),
help="output directory (default: '%(default)s')",
)
parser.add_argument(
"-p",
"--pattern",
default=".*",
default=DEFAULT_PATTERN,
help=(
"a pattern to use to select project "
"specifications filtered by name"
Expand Down
12 changes: 8 additions & 4 deletions yambs/dependency/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ def filt(asset: dict[str, Any]) -> Optional[Path]:
return filt


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

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

assert dest.is_dir(), dest
assert not strict or dest.is_dir(), dest


class GithubDependency(LoggerMixin):
Expand Down Expand Up @@ -111,7 +113,7 @@ def __init__(
}

def download_release_assets(
self, filt: AssetFilter, extract: bool = True
self, filt: AssetFilter, extract: bool = True, strict: bool = True
) -> None:
"""Ensure release assets are downloaded."""

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

if extract:
ensure_extracted(dest.parent, logger=self.logger)
ensure_extracted(
dest.parent, strict=strict, logger=self.logger
)
Loading