1

I need to delete a python package from a private python package index (a.k.a. repository) using the command line. This repo is on artifactory, but I am not able to use the artifactory portal UI to do this.

The package was originally uploaded using twine. However, it looks like there is no delete functionality in twine.

Twine was able to succeed at the upload despite being agnostic of it being an artifactory repo... so I assume there is some kind of standardized pypi-type api...?

(This question is similar but different to How to remove a package from Pypi , because it is asking specifically about a private repo and asking specifically about a CLI solution)

cowlinator
  • 7,195
  • 6
  • 41
  • 61
  • 2
    Warehouse (the backend behind the current PyPI.org) doesn't have any [API](https://warehouse.pypa.io/api-reference/index.html) to delete packages. Any compatible implementation probably doesn't have it either. – phd Feb 02 '22 at 21:32

2 Answers2

3

As you have mentioned that the package has been uploaded to the Artifactory's repository using "twine", I assume the package currently exists in a PyPI local repository of the Artifactory instance.

Since you are looking for an option to delete this artifact from the repository via the command line, please check if this REST API call to delete the artifact is an option for you.

I am sharing a sample command here for your reference.

curl -u <USERNAME>:<PASSWORD> -X DELETE "http://ARTIFACTORY_HOST:ARTIFACTORY_PORT/artifactory/admin-pypi-remote-cache/bd/"

admin-pypi-remote is my repository name and bd is the target folder/package of the deletion task.

Yuvarajan
  • 450
  • 2
  • 5
  • Unfortunately, artifactory's response is `405 method not allowed` – cowlinator Feb 04 '22 at 20:41
  • "HTTP 405" could have occurred either due to an incorrect repository path or if the method being used/expected is distinct. Can you please check it? – Yuvarajan Feb 05 '22 at 12:16
3

if you are using a local pypi server, to delete an uploaded artifact use the following command:

curl -u <USERNAME>:<PASSWORD> --form ":action=remove_pkg" --form "name=<PACKAGE_NAME>" --form "version=<VERSION>" <PYPI_SERVER_URL>
Franramb
  • 51
  • 6