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

Change command line option name from cache to work #351

Merged
merged 1 commit into from
Mar 6, 2023
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
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ jobs:
ci/${RELEASE} \
ci/repository.yml \
--workspace ${{ runner.temp }}/kmd-ws \
--cache ${{ runner.temp }}/kmd-cache \
--prefix ${{ runner.temp }}/pfx \
--release ci \
--locations-config $(realpath ci/locations.yml) \
Expand Down
2 changes: 1 addition & 1 deletion docs/basic-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ A full software distribution can then be built and deployed to a specified
path, e.g. `./builds/stable-0.0.1`, with the following command:

```bash
kmd stable.yml repository.yml --prefix builds --release stable-0.0.1 --locations-config locations.yml --cache pip-cache
kmd stable.yml repository.yml --prefix builds --release stable-0.0.1 --locations-config locations.yml
kwinkunks marked this conversation as resolved.
Show resolved Hide resolved
```

To use this environment, type `source builds/stable-0.0.1/enable`.
32 changes: 20 additions & 12 deletions komodo/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def _main(args):
data = Data(extra_data_dirs=args.extra_data_dirs)

if args.download or (not args.build and not args.install):
git_hashes = fetch(args.pkgs, args.repo, outdir=args.cache, pip=args.pip)
git_hashes = fetch(args.pkgs, args.repo, outdir=args.downloads, pip=args.pip)

if args.download and not args.build:
sys.exit(0)
Expand All @@ -70,7 +70,7 @@ def _main(args):
args.repo,
data,
prefix=str(tmp_prefix),
dlprefix=args.cache,
dlprefix=args.downloads,
builddir=args.tmp,
jobs=args.jobs,
cmk=args.cmake,
Expand Down Expand Up @@ -137,8 +137,9 @@ def _main(args):
shell(f"rm -rf {args.prefix}/{args.release}.delete", sudo=args.sudo)

if args.tmp:
# Allows e.g. pip to use this folder as tmpfolder, instead of in some
# cases falling back to /tmp, which is undesired when building on nfs.
# Allows e.g. pip to use this folder as a destination for "pip
# download", instead of in some cases falling back to /tmp, which is
# undesired when building on nfs.
os.environ["TMPDIR"] = args.tmp

release_path = Path(args.prefix) / Path(args.release)
Expand All @@ -159,8 +160,9 @@ def _main(args):
"--no-index",
"--no-deps",
"--ignore-installed",
f"--cache-dir {args.cache}",
f"--find-links {args.cache}",
# assuming fetch.py has done "pip download" to this directory:
f"--cache-dir {args.downloads}",
f"--find-links {args.downloads}",
]
shell_input.append(current.get("makeopts"))

Expand Down Expand Up @@ -265,11 +267,15 @@ def parse_args(args: List[str]) -> argparse.Namespace:
"current working directory.",
)
optional_args.add_argument(
"--cache",
"-c",
"--downloads",
"--cache", # deprecated
"-c", # deprecated
type=str,
default="pip-cache",
help="The temporary directory used for downloads, e.g. by pip.",
default="downloads",
help="A destination directory relative to the workspace, used for downloads, "
"used by pip download, cp, rsync and git clone. This directory "
"must be empty if it already exists, otherwise it will be created, "
"unless you are running with the --build option.",
)
optional_args.add_argument(
"--jobs",
Expand All @@ -282,13 +288,15 @@ def parse_args(args: List[str]) -> argparse.Namespace:
"--download",
"-d",
action="store_true",
help="Flag to choose whether to download the packages.",
help="If set, packages will be downloaded but nothing will be built, unless "
"--build is also included.",
)
optional_args.add_argument(
"--build",
"-b",
action="store_true",
help="Flag to choose whether to build the packages.",
help="Flag to only build. If set and --download is not, "
"the downloads directory must already be populated.",
)
optional_args.add_argument(
"--install",
Expand Down
13 changes: 9 additions & 4 deletions komodo/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,12 @@ def fetch(pkgs, repo, outdir, pip="pip") -> dict:

if not outdir:
raise ValueError(
"The value of `outdir`, the cache location for pip and other "
"tools, cannot be None or the empty string."
"The value of `outdir`, the download destination location "
"cannot be None or the empty string."
)
if os.path.exists(outdir) and os.listdir(outdir):
raise RuntimeError(
f"Downloading to non-empty directory {outdir} is not supported."
)
if not os.path.exists(outdir):
os.mkdir(outdir)
Expand Down Expand Up @@ -171,13 +175,14 @@ def fetch(pkgs, repo, outdir, pip="pip") -> dict:
"-o",
type=str,
required=True,
help="The cache location for pip and other tools; will be created.",
help="The download destination for pip, cp, rsync and git. "
"Must be non-existing or empty.",
)
parser.add_argument(
"--pip",
type=str,
default="pip",
help="The command to use for downloading.",
help="The command to use for downloading pip packages.",
)
args = parser.parse_args()
fetch(args.pkgfile, args.repofile, outdir=args.output, pip=args.pip)
2 changes: 1 addition & 1 deletion tests/data/cli/nominal_repository.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ setuptools:

hackres:
0.0.5289:
source: ../hackres # we assume here hackres is copied into cache/..
source: ../hackres # we assume here hackres is copied into _work/..
fetch: fs-cp
make: sh
makefile: test_build_script.sh
Expand Down