About Python pip install and versioning

Backgroup

If you want to release python project on PyPI, you must need to know about PyPI usage characteristics, then I did some test about pip install command.

For example: I have a Python project called demo-pip. and beta release would like 1.1.0.xxxx, offical release version is 1.1.0 to see if could success upgrade when using pip command.

Base on the below test results, I summarized as follows:

  1. Install a specific version of demo-pip from PyPI, with --upgrade option or not, they’ll all both success.
  2. Install the latest package version of demo-pip from PyPI that version is large than the locally installed package version, with --upgrade option installs successfully. without --upgrade option install failed.
  3. Install the latest package version of demo-pip from PyPI that version is less than the locally installed package version, with --upgrade option or not, install failed.
  4. 1.1.0.xxxx version naming is OK, but when the beta version is larger than 1.1.0, for example, the beta version is 1.1.0.1000, pip install with --upgrade not work when our official release version is 1.1.0.
    a. One option is the official release version start from 1.1.0.1000, beta version starts from 1.1.0.0001, 1.1.0.0002… Or the beta version should be less than 1.1.0, maybe 1.0.0.xxxx
    b. Another option is follow up python official versioning that is the best practice, then the beta release version will be 1.1.b1, 1.1.b2, 1.1.bN… (it passed No.5 test below)

My Test Case

<No.> <Test Case Steps> <Test Output> <Test Results>
1 1.build and install demo-pip-1.0.5
2.install from PyPI. on PyPI, the latest version is 1.0.4
C:\workspace\demo-pip>pip install dist\demo-pip-1.0.5-py3-none-any.whl
Processing c:\workspace\demo-pip\dist\demo-pip-1.0.5-py3-none-any.whl
Installing collected packages: demo-pip
Attempting uninstall: demo-pip
Found existing installation: demo-pip 1.0.4
Uninstalling demo-pip-1.0.4:
Successfully uninstalled demo-pip-1.0.4
Successfully installed demo-pip-1.0.5

C:\workspace\demo-pip>pip install -i https://test.pypi.org/simple/ –upgrade demo-pip
Looking in indexes: https://test.pypi.org/simple/
Requirement already up-to-date: demo-pip in c:\program files\python38\lib\site-packages (1.0.5)
install with --upgrade option failed when the installed version number is less than the current version number
2 1.rebuild and install demo-pip-1.0.3
2.install from PyPI again with --upgrade option
C:\workspace\demo-pip>pip install dist\demo-pip-1.0.3-py3-none-any.whl
Processing c:\workspace\demo-pip\dist\demo-pip-1.0.3-py3-none-any.whl
Installing collected packages: demo-pip
Attempting uninstall: demo-pip
Found existing installation: demo-pip 1.0.5
Uninstalling demo-pip-1.0.5:
Successfully uninstalled demo-pip-1.0.5
Successfully installed demo-pip-1.0.3

C:\workspace\demo-pip>pip install -i https://test.pypi.org/simple/ –upgrade demo-pip
Looking in indexes: https://test.pypi.org/simple/
Collecting demo-pip
Downloading https://test-files.pythonhosted.org/packages/41/c5/fe16fdc482927b2831c36f96d6e5a1c5b7a2a676ddc4c00c67a9ccf644e9/demo-pip-1.0.4-py3-none-any.whl (51 kB)
|████████████████████████████████| 51 kB 362 kB/s
Installing collected packages: demo-pip
Attempting uninstall: demo-pip
Found existing installation: demo-pip 1.0.3
Uninstalling demo-pip-1.0.3:
Successfully uninstalled demo-pip-1.0.3
Successfully installed demo-pip-1.0.4
install with --upgrade option success from PyPI when install version number is larger than the current version number
3 1. create a new build demo-pip-1.0.3.1000
2. install demo-pip-1.0.3.1000 with --upgrade option
3. install demo-pip-1.0.3.1000, without --upgrade option
C:\workspace\demo-pip>pip install -i https://test.pypi.org/simple/ –upgrade demo-pip
Looking in indexes: https://test.pypi.org/simple/
Collecting demo-pip
Downloading https://test-files.pythonhosted.org/packages/41/c5/fe16fdc482927b2831c36f96d6e5a1c5b7a2a676ddc4c00c67a9ccf644e9/demo-pip-1.0.4-py3-none-any.whl (51 kB)
|████████████████████████████████| 51 kB 83 kB/s
Installing collected packages: demo-pip
Attempting uninstall: demo-pip
Found existing installation: demo-pip 1.0.3.1000
Uninstalling demo-pip-1.0.3.1000:
Successfully uninstalled demo-pip-1.0.3.1000
Successfully installed demo-pip-1.0.4

C:\workspace\demo-pip>pip install -i https://test.pypi.org/simple/ demo-pip
Looking in indexes: https://test.pypi.org/simple/
Requirement already satisfied: demo-pip in c:\program files\python38\lib\site-packages (1.0.3.1000)
1. install with --upgrade option success
2. install without --upgrade option failed
4 1. create a new build demo-pip-1.0.4.1000
2. install demo-pip-1.0.4.1000 with --upgrade option.
3. install specific version of demo-pip
C:\workspace\demo-pip>pip install dist\demo-pip-1.0.4.1000-py3-none-any.whl
Processing c:\workspace\demo-pip\dist\demo-pip-1.0.4.1000-py3-none-any.whl
Installing collected packages: demo-pip
Attempting uninstall: demo-pip
Found existing installation: demo-pip 1.0.4
Uninstalling demo-pip-1.0.4:
Successfully uninstalled demo-pip-1.0.4
Successfully installed demo-pip-1.0.4.1000

C:\workspace\demo-pip>pip install -i https://test.pypi.org/simple/ –upgrade demo-pip
Looking in indexes: https://test.pypi.org/simple/
Requirement already up-to-date: demo-pip in c:\program files\python38\lib\site-packages (1.0.4.1000)

C:\workspace\demo-pip>pip install -i https://test.pypi.org/simple/ demo-pip==1.0.4
Looking in indexes: https://test.pypi.org/simple/
Collecting demo-pip==1.0.4
Downloading https://test-files.pythonhosted.org/packages/41/c5/fe16fdc482927b2831c36f96d6e5a1c5b7a2a676ddc4c00c67a9ccf644e9/demo-pip-1.0.4-py3-none-any.whl (51 kB)
|████████████████████████████████| 51 kB 362 kB/s
Installing collected packages: demo-pip
Attempting uninstall: demo-pip
Found existing installation: demo-pip 1.0.4.1000
Uninstalling demo-pip-1.0.4.1000:
Successfully uninstalled demo-pip-1.0.4.1000
Successfully installed demo-pip-1.0
Install failed when the install version number is less than the currently installed version number

if install a specific version of demo-pip with --upgrade option or not. will both works.
5 1. Follow up python official version naming for beta-version, create a new build demo-pip-1.0.b1
2. install from PyPi without --upgrade option
3. install from PyPi with --upgrade option
C:\workspace\demo-pip>pip install -i https://test.pypi.org/simple/ demo-pip
Looking in indexes: https://test.pypi.org/simple/
Requirement already satisfied: demo-pip in c:\program files\python38\lib\site-packages (1.0b1)

C:\workspace\demo-pip>pip install -i https://test.pypi.org/simple/ –upgrade demo-pip
Looking in indexes: https://test.pypi.org/simple/
Collecting demo-pip
Downloading https://test-files.pythonhosted.org/packages/41/c5/fe16fdc482927b2831c36f96d6e5a1c5b7a2a676ddc4c00c67a9ccf644e9/demo-pip-1.0.4-py3-none-any.whl (51 kB)
|████████████████████████████████| 51 kB 362 kB/s
Installing collected packages: demo-pip
Attempting uninstall: demo-pip
Found existing installation: demo-pip 1.0b1
Uninstalling demo-pip-1.0b1:
Successfully uninstalled demo-pip-1.0b1
Successfully installed demo-pip-1.0.4
install successful with --upgrade option
so it means 1.0.b1 version number is less than 1.0.4 version