cowlinator
cowlinator

Reputation: 8813

How to delete python package from pypi-type repository using command line?

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)

Upvotes: 1

Views: 3716

Answers (2)

Franramb
Franramb

Reputation: 61

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>

Upvotes: 4

Yuvarajan
Yuvarajan

Reputation: 470

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.

Upvotes: 3

Related Questions