Search code examples
python-3.xversioningsetuptoolssetup.pypython-packaging

setup.py how NOT to keep multiple version of packages


I need some suggestion on my python setuptools deployment flows. Here is my current workflow.

  1. The python name packages are stored in the remote git server with a setup.py (setuptools based) and it has a version number that gets update each time the code is changed.
  2. The users would clone the git repos and run ./setup.py install to install the python package to system path (/usr/local/lib/python3.6/dist-package/)
  3. If there are any bugfix, updated code + version increment inside setup.py are done and changes are pushed to the git server.
  4. The users do a git pull and run ./setup.py install again.

After step 4, usually import python module would point to the newest package, but I realize the older version of the same package still exists in dist-package/ I wonder how do we only keep the latest version of my package installed via setup.py?


Solution

  • pip uninstalls previous version when upgrading a package. Instead of running ./setup.py directly, ask users to use

    pip install --upgrade .