diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-07-30 14:10:59 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-07-30 14:10:59 -0400 |
commit | be5245c4410ee0940b4f6ad38c661cc2f78f7265 (patch) | |
tree | 2a4532c672e96bc992337f773dac4a7d6a87e912 | |
parent | 27dcf9b9aab6afb8049901b4aedf0c100ca1a28a (diff) | |
download | stasis-be5245c4410ee0940b4f6ad38c661cc2f78f7265.tar.gz |
Now that *_packages lists define the package version through detection, because the end-result version cannot be guaranteed to be identical to the tag.
* Find the just-compiled package matching the name and version in the package list.
* If compiling master/main this can also match against post-commits (x.y.z.devN+hash)
* Versions are extracted from the package name in the list, only if a matching test block exists. Otherwise the string is passed through to pip directly.
-rw-r--r-- | src/delivery.c | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/src/delivery.c b/src/delivery.c index 6bf11db..973570a 100644 --- a/src/delivery.c +++ b/src/delivery.c @@ -1237,9 +1237,39 @@ int delivery_install_packages(struct Delivery *ctx, char *conda_install_dir, cha continue; } if (INSTALL_PKG_PIP_DEFERRED & type) { - const struct Test *info = requirement_from_test(ctx, name); + struct Test *info = (struct Test *) requirement_from_test(ctx, name); if (info) { - sprintf(cmd + strlen(cmd), " '%s==%s'", info->name, info->version); + if (!strcmp(info->version, "HEAD")) { + struct StrList *tag_data = strlist_init(); + if (!tag_data) { + SYSERROR("%s", "Unable to allocate memory for tag data\n"); + return -1; + } + strlist_append_tokenize(tag_data, info->repository_info_tag, "-"); + + struct Wheel *whl = NULL; + char *post_commit = NULL; + char *hash = NULL; + if (strlist_count(tag_data) > 1) { + post_commit = strlist_item(tag_data, 1); + hash = strlist_item(tag_data, 2); + } + + // We can't match on version here (index 0). The wheel's version is not guaranteed to be + // equal to the tag; setuptools_scm auto-increments the value, the user can change it manually, + // etc. + whl = get_wheel_file(ctx->storage.wheel_artifact_dir, info->name, + (char *[]) {ctx->meta.python_compact, ctx->system.arch, + "none", "any", + post_commit, hash, + NULL}, WHEEL_MATCH_ANY); + + guard_strlist_free(&tag_data); + info->version = whl->version; + sprintf(cmd + strlen(cmd), " '%s==%s'", info->name, whl->version); + } else { + sprintf(cmd + strlen(cmd), " '%s==%s'", info->name, info->version); + } } else { fprintf(stderr, "Deferred package '%s' is not present in the tested package list!\n", name); return -1; @@ -1507,10 +1537,26 @@ void delivery_defer_packages(struct Delivery *ctx, int type) { // Compile a list of packages that are *also* to be tested. char *version; + char *spec_begin = strpbrk(name, "~=<>!"); + char *spec_end = spec_begin; + if (spec_end) { + // A version is present in the package name. Jump past operator(s). + while (*spec_end != '\0' && !isalnum(*spec_end)) { + spec_end++; + } + } + + // When spec is present in name, set ctx->tests[x].version to the version detected in the name for (size_t x = 0; x < sizeof(ctx->tests) / sizeof(ctx->tests[0]); x++) { version = NULL; if (ctx->tests[x].name) { if (strstr(name, ctx->tests[x].name)) { + guard_free(ctx->tests[x].version); + if (spec_end) { + ctx->tests[x].version = strdup(spec_end); + } else { + ctx->tests[x].version = strdup("HEAD"); + } version = ctx->tests[x].version; ignore_pkg = 1; break; |