diff options
| author | Joseph Hunkeler <jhunkeler@gmail.com> | 2025-03-20 11:52:22 -0400 | 
|---|---|---|
| committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2025-03-20 11:52:22 -0400 | 
| commit | 5126b191b6d1a53d3a402478472fd1d357ace293 (patch) | |
| tree | 25c60be20c78b5d339e4421458799a021bdcb0c2 | |
| parent | 4307e297cb567d70a0369e66af2c0d7f42725574 (diff) | |
| download | stasis-5126b191b6d1a53d3a402478472fd1d357ace293.tar.gz | |
Remove extras usage where applicable
| -rw-r--r-- | src/lib/core/include/utils.h | 4 | ||||
| -rw-r--r-- | src/lib/core/str.c | 23 | ||||
| -rw-r--r-- | src/lib/delivery/delivery_build.c | 1 | ||||
| -rw-r--r-- | src/lib/delivery/delivery_install.c | 35 | 
4 files changed, 41 insertions, 22 deletions
| diff --git a/src/lib/core/include/utils.h b/src/lib/core/include/utils.h index 87f28cc..1906808 100644 --- a/src/lib/core/include/utils.h +++ b/src/lib/core/include/utils.h @@ -413,4 +413,8 @@ int env_manipulate_pathstr(const char *key, char *path, int mode);  */  int gen_file_extension_str(char *filename, const char *extension); +/** + * Remove [extra]s from a spec string + */ +char *remove_extras(char *s);  #endif //STASIS_UTILS_H diff --git a/src/lib/core/str.c b/src/lib/core/str.c index 6457afe..1d0b268 100644 --- a/src/lib/core/str.c +++ b/src/lib/core/str.c @@ -671,4 +671,25 @@ void unindent(char *s) {              pos++;          }      } -}
\ No newline at end of file +} + +char *remove_extras(char *s) { +    // an "extra" is a string encapsulated by square brackets "text[toremove]" +    char *extra_stop = NULL; +    char *extra_start = strchr(s, '['); +    size_t len = strlen(s); +    if (extra_start) { +        extra_stop = strchr(extra_start, ']'); +        if (extra_stop) { +            size_t last = strlen(s); +            if (last) { +                extra_stop++; +                last = strlen(extra_stop); +            } +            memmove(extra_start, extra_stop, last); +            s[len - (extra_stop - extra_start)] = 0; +        } +    } +    return s; +} + diff --git a/src/lib/delivery/delivery_build.c b/src/lib/delivery/delivery_build.c index 03f2d4c..2d891d2 100644 --- a/src/lib/delivery/delivery_build.c +++ b/src/lib/delivery/delivery_build.c @@ -141,6 +141,7 @@ struct StrList *delivery_build_wheels(struct Delivery *ctx) {          char name[100] = {0};          char *fullspec = strlist_item(ctx->conda.pip_packages_defer, p);          strncpy(name, fullspec, sizeof(name) - 1); +        remove_extras(name);          char *spec = find_version_spec(name);          if (spec) {              *spec = '\0'; diff --git a/src/lib/delivery/delivery_install.c b/src/lib/delivery/delivery_install.c index fec30ac..cf6ccaa 100644 --- a/src/lib/delivery/delivery_install.c +++ b/src/lib/delivery/delivery_install.c @@ -9,6 +9,7 @@ static struct Test *requirement_from_test(struct Delivery *ctx, const char *name              if (spec) {                  *spec = '\0';              } +            remove_extras(package_name);              if (ctx->tests[i].name && !strcmp(package_name, ctx->tests[i].name)) {                  result = &ctx->tests[i]; @@ -41,25 +42,6 @@ static char *have_spec_in_config(const struct Delivery *ctx, const char *name) {      return NULL;  } -static char *remove_extras(char *s) { -    char *extra_stop = NULL; -    char *extra_start = strchr(s, '['); -    size_t len = strlen(s); -    if (extra_start) { -        extra_stop = strchr(extra_start, ']'); -        if (extra_stop) { -            size_t last = strlen(s); -            if (last) { -                extra_stop++; -                last = strlen(extra_stop); -            } -            memmove(extra_start, extra_stop, last); -            s[len - (extra_stop - extra_start)] = 0; -        } -    } -    return s; -} -  int delivery_overlay_packages_from_env(struct Delivery *ctx, const char *env_name) {      char *current_env = conda_get_active_environment();      int need_restore = current_env && strcmp(env_name, current_env) != 0; @@ -99,7 +81,6 @@ int delivery_overlay_packages_from_env(struct Delivery *ctx, const char *env_nam          } else {              strncpy(spec_name, spec, sizeof(spec_name) - 1);          } -        remove_extras(spec_name);          struct Test *test_block = requirement_from_test(ctx, spec_name);          if (!test_block) { @@ -293,9 +274,21 @@ int delivery_install_packages(struct Delivery *ctx, char *conda_install_dir, cha                          }                          wheel_free(&whl);                      } + +                    char req[255] = {0}; +                    if (!strcmp(name, info->name)) { +                        strcpy(req, info->name); +                    } else { +                        strcpy(req, name); +                        char *spec = find_version_spec(req); +                        if (spec) { +                            *spec = 0; +                        } +                    } +                      snprintf(cmd + strlen(cmd),                               sizeof(cmd) - strlen(cmd) - strlen(info->name) - strlen(info->version) + 5, -                             " '%s==%s'", info->name, info->version); +                             " '%s==%s'", req, info->version);                  } else {                      fprintf(stderr, "Deferred package '%s' is not present in the tested package list!\n", name);                      return -1; | 
