Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to formally deprecate a pip package

This might seem a little strange, but I can't really find an acceptable way of doing this after having googled around for quite some time.

Basically I have a pip package that I maintain. It's mostly a wrapper for an external API, and the external API just changed. I sent out a new version of the wrapper, but presumably not everyone keeps their pip packages completely up to date. I made an effort to keep most legacy functionality around, but there were a few features I was unable to preserve.

Is there any way to formally let people know that every package before a certain version has been formally deprecated? Ideally this would tell people to actively upgrade, but I'm not sure how feasible that is.

It seems like pip must have some functionality or best practices for this, but I can't really find any relevant documentation.

like image 663
Slater Victoroff Avatar asked Jun 06 '14 15:06

Slater Victoroff


People also ask

How do I uninstall a package with pip?

To use pip to uninstall a package locally in a virtual environment: Open a command or terminal window (depending on the operating system) cd into the project directory. pip uninstall <packagename>

Does pip uninstall remove dependencies?

For example, on my system this script eventually failed because the target package had dependencies in common with pip, so pip uninstalled its own dependencies before the script could finish, and then failed. Beware this removes only the next level down dependencies, but not the dependencies of those dependencies.

Does uninstalling Python remove all packages?

@patelshahrukh uninstalling python DOES NOT remove pip packages. please AVOID doing that, since it both most likely WON'T WORK the way you think it will, and, depending on how you install python again, can leave your machine in an unstable state that's more work to fix.

How do I install old pip packages?

To install a specific version of a Python package you can use pip: pip install YourPackage==YourVersion . For example, if you want to install an older version of Pandas you can do as follows: pip install pandas==1.1. 3 .


1 Answers

Add the following code to __init__.py of the module if you want it to give the warnings when you import it in other places.

import warnings
warnings.warn("deprecated", DeprecationWarning)

From: https://docs.python.org/2/library/warnings.html#temporarily-suppressing-warnings

like image 60
benedikt Avatar answered Sep 28 '22 10:09

benedikt