3

I have a setup.py script for my package which I install using python ./setup.py install

What seems to happen is every time I increase the version, the old version is not removed in /usr/local/lib/python2.7/dist-packages so I see multiple versions.

Is there a way to set this up in a way that when a person updates, the old version gets removed?

There is a similar (but not quite) question on SO that asks how to uninstall a package in setup.py but I'm not really looking to uninstall as a separate option. I am looking for a clean 'update' process that removes old versions before installing new ones.

The other option is if I could just cleanly remove the version number from the installed package name, in which case I suppose it would overwrite, but I haven't been successful in doing that. If I remove version, it creates the package name with "0.0" which looks weird.

My setup script:

import io
import os
import sys

from setuptools import setup

#Package meta-data.
NAME = 'my_package'
DESCRIPTION = 'My description'
URL = 'https://github.com/myurl'
EMAIL = 'myemail@gmail.com'
AUTHOR = 'Me'
VERSION = '3.1.12'

setup(name = NAME,
      version=VERSION,
      py_modules = ['dir.mod1',
                    'dir.mod2',
                  ]
      )
Rene B.
  • 6,557
  • 7
  • 46
  • 72
user1361529
  • 2,667
  • 29
  • 61

1 Answers1

2

If you want to remove previous versions from your packages then you could use pip in the parent directory of your package. Lets assume your setup.py is in the directory my_package then you can use:

pip install my_package --upgrade
Rene B.
  • 6,557
  • 7
  • 46
  • 72