From 0eda05963f3c70c3969ddd2aa72926b871ef4b07 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Tue, 20 Aug 2024 10:45:09 -0400 Subject: Pypi existence check (#30) * Add python_package_exists() function * Poll pypi.org or compatible index to see if a package exists * Returns non-zero on success * Implements python_package_exists() in delivery_defer_packages() * Implements python_package_exists() in delivery_defer_packages() * Bugfix: Avoid incorrect package selection * With large package lists that contain multiple packages starting with the same strstr() would pick the first match * This adds a temporary name variable that strcmp() can check against. * Message correction: * Change "release" to "testing" in testing environment failure message * Amend message to fit the flow of the output * Disable outdated conda notifications * The latest version isn't always the greatest. Don't give the end-user any ideas. Just use whatever the installer provides... quietly * Rename python_package_exists to pip_index_provides * Document the function prototype * Add missing comments in micromamba structure * Ensure the temporary output file does not linger --- src/delivery.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/delivery.c') diff --git a/src/delivery.c b/src/delivery.c index e69ce2f..524dd0a 100644 --- a/src/delivery.c +++ b/src/delivery.c @@ -1466,8 +1466,14 @@ void delivery_defer_packages(struct Delivery *ctx, int type) { struct Test *test = &ctx->tests[x]; version = NULL; + char nametmp[1024] = {0}; + if (spec_end != NULL && spec_begin != NULL) { + strncpy(nametmp, name, spec_begin - name); + } else { + strcpy(nametmp, name); + } // Is the [test:NAME] in the package name? - if (strstr(name, test->name)) { + if (!strcmp(nametmp, test->name)) { // Override test->version when a version is provided by the (pip|conda)_package list item guard_free(test->version); if (spec_begin && spec_end) { @@ -1498,7 +1504,12 @@ void delivery_defer_packages(struct Delivery *ctx, int type) { } } - ignore_pkg = 1; + if (DEFER_PIP == type && pip_index_provides(PYPI_INDEX_DEFAULT, name, version)) { + fprintf(stderr, "(%s present on index %s): ", version, PYPI_INDEX_DEFAULT); + ignore_pkg = 0; + } else { + ignore_pkg = 1; + } break; } } -- cgit