#3 Please provide version information

closed
nobody
5
2014-08-08
2012-05-11
No

pip thinks installed version is 0.0.0 and so always reinstalls the package even if it's up-to-date.

$ pip install --upgrade irc
Downloading/unpacking irc from http://pypi.python.org/packages/source/i/irc/irc-1.1.zip#md5=34b2b2e32358b18058289b54f8ac0cc4
Running setup.py egg_info for package irc
Installing collected packages: irc
Found existing installation: irc 0.0.0
Uninstalling irc:
Successfully uninstalled irc
Running setup.py install for irc
Successfully installed irc
Cleaning up...
$

Please provide proper version information inside package.

Discussion

  • That's interesting. I'm not able to reproduce on Windows:

    PS C:> virtualenv env
    New python executable in env\Scripts\python.exe
    Installing distribute...............................................................................................................................................................................................done.
    Installing pip.................done.
    PS C:> env/scripts/pip install irc
    Downloading/unpacking irc
    Downloading irc-1.1.zip (105Kb): 105Kb downloaded
    Running setup.py egg_info for package irc
    Checking .pth file support in .
    C:\env\Scripts\pythonw.exe -E -c pass
    Searching for hgtools
    Reading http://pypi.python.org/simple/hgtools/
    Reading http://bitbucket.org/jaraco/hgtools/
    Reading http://bitbucket.org/jaraco/hgtools/downloads/
    Best match: hgtools 2.0
    Downloading http://pypi.python.org/packages/source/h/hgtools/hgtools-2.0.zip#md5=cafbbcb7828e1d155eb2dd11474bea04
    Processing hgtools-2.0.zip
    Running hgtools-2.0\setup.py -q bdist_egg --dist-dir c:\users\jaraco\appdata\local\temp\easy_install-yjuquk\hgtools-2.0\egg-dist-tmp-bvohea
    installing library code to build\bdist.win-amd64\egg
    zip_safe flag not set; analyzing archive contents...
    removing 'build\bdist.win-amd64\egg' (and everything under it)
    Extracting hgtools-2.0-py2.7.egg to c:\env\build\irc

    Installed c:\env\build\irc\hgtools-2.0-py2.7.egg
    

    Installing collected packages: irc
    Running setup.py install for irc
    Successfully installed irc
    Cleaning up...
    PS C:> dir .\env\Lib\site-packages\irc*

    Directory: C:\env\Lib\site-packages
    

    Mode LastWriteTime Length Name
    ---- ------------- ------ ----
    d---- 12-May-2012 5:43 PM irc
    d---- 12-May-2012 5:43 PM irc-1.1-py2.7.egg-info

    PS C:> env/scripts/python -c "import irc.client; print irc.client.VERSION"
    (1, 1)

    nor Linux:

    jaraco@hideaki:~$ virtualenv --distribute envs/irc
    New python executable in envs/irc/bin/python2.7
    Also creating executable in envs/irc/bin/python
    Installing distribute.............................................................................................................................................................................................done.
    Installing pip...............done.
    jaraco@hideaki:~$ envs/irc/bin/pip install irc
    Downloading/unpacking irc
    Downloading irc-1.1.zip (105Kb): 105Kb downloaded
    Running setup.py egg_info for package irc
    Checking .pth file support in .
    /home/jaraco/envs/irc/bin/python2.7 -E -c pass
    Searching for hgtools
    Reading http://pypi.python.org/simple/hgtools/
    Reading http://bitbucket.org/jaraco/hgtools/
    Reading http://bitbucket.org/jaraco/hgtools/downloads/
    Best match: hgtools 2.0
    Downloading http://pypi.python.org/packages/source/h/hgtools/hgtools-2.0.zip#md5=cafbbcb7828e1d155eb2dd11474bea04
    Processing hgtools-2.0.zip
    Running hgtools-2.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-MMSy5x/hgtools-2.0/egg-dist-tmp-FdBbRY
    installing library code to build/bdist.linux-x86_64/egg
    zip_safe flag not set; analyzing archive contents...
    removing 'build/bdist.linux-x86_64/egg' (and everything under it)
    Extracting hgtools-2.0-py2.7.egg to /home/jaraco/envs/irc/build/irc

    Installed /home/jaraco/envs/irc/build/irc/hgtools-2.0-py2.7.egg
    

    Installing collected packages: irc
    Running setup.py install for irc
    Successfully installed irc
    Cleaning up...
    jaraco@hideaki:~$ envs/irc/bin/python -c "import irc.client; print irc.client.VERSION"
    (1, 1)
    jaraco@hideaki:~$ ls -d envs/irc/lib/python2.7/site-packages/irc*
    envs/irc/lib/python2.7/site-packages/irc
    envs/irc/lib/python2.7/site-packages/irc-1.1-py2.7.egg-info

    I suspect the problem is with the version of setuptools/distribute/pip being used. Can you try upgrading your packaging toolset and report back if you're still able to reproduce the issue and what versions you're using?

     
  • You won't be seeing this on a new install, only on second and subsequent installs. I'm on Linux and using python 2.6 and 2.7. All relevant packages (pip, setuptools, distribute, etc.) are the newest versions. The irc package is the only package on my system that behaves this way.

     
  • I'm sorry to hear you're still having trouble. I've re-run the install (several times) without it attempting to reinstall. It always says:

    jaraco@hideaki:~$ envs/irc/bin/pip install --upgrade irc
    Requirement already up-to-date: irc in ./envs/irc/lib/python2.7/site-packages
    Cleaning up...

    I also uninstalled and reinstalled with no problems.

    I'll try again on a clean ubuntu system for comparison. It's quite possible the installer is making some assumptions about the environment. If you have any other suggestions on how I can reproduce the issue, please do advise.

     
  • The ‘problem’ persists even when I uninstall irc first then install it, and then reinstall (upgrade) it. Pip always thinks the installed version is irc 0.0.0. I don't know where pip gets this number from. The egg info says 1.1. Perhaps a “version = '1.1'” in init.py will help? I don't know…

     
  • PS: irc gets installed in a directory called irc-0.0.0-py2.7.egg-info, that's probably where pip gets the version information from on upgrade. Doesn't this suggest that the mismatch happens at install time?

     
  • This is frustrating. I'm still unable to reproduce the issue. I took a near-pristine Ubuntu Oneiric server, instaledl python-setuptools (using aptitude) and the latest virtualenv (using easy_install), then created the env, installed irc, upgraded irc, and confirmed that the version is being reported as expected (transcript below).

    You're right that the version is being incorrectly detected at run time, but this should not happen because pip is running 'setup.py', and setup.py uses setup_requires, which causes hgtools to be loaded. hgtools then grabs the version from the setup.cfg (where it was saved when I built the sdist).

    I would really like to keep the use of 'hgtools' for tag/version management, as it means the version gets indicated in one place, so there's nothing to keep in sync manually (just tag a revision and that's it - that's the version number).

    If there are bugs using this technique, then I'd like to know what they are and get them resolved, and only if they can't be resolved, consider removing hgtools. However, I use hgtools for literally dozens of other packages with great success, so I imagine there's a way to make this work.

    Are you by chance installing in an environment where you don't have access to pypi? That would cause hgtools not to be found, which might cause this issue. Would you consider trying to install 'jaraco.util' and see if it has the same issue? It doesn't have any dependencies, so should be straightforward to uninstall afterward. It also uses hgtools for version management.

    I appreciate your patience on this issue.

    jaraco@ichiro:~$ sudo aptitude install python-setuptools
    The following NEW packages will be installed:
    python-setuptools
    0 packages upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
    Need to get 0 B/212 kB of archives. After unpacking 1,065 kB will be used.
    Selecting previously deselected package python-setuptools.
    (Reading database ... 45871 files and directories currently installed.)
    Unpacking python-setuptools (from .../python-setuptools_0.6.16-1ubuntu0.1_all.deb) ...
    Setting up python-setuptools (0.6.16-1ubuntu0.1) ...

    jaraco@ichiro:~$ /usr/bin/easy_install --user virtualenv
    Searching for virtualenv
    Reading http://pypi.python.org/simple/virtualenv/
    Reading http://www.virtualenv.org
    Reading http://virtualenv.openplans.org
    Best match: virtualenv 1.7.1.2
    Downloading http://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.7.1.2.tar.gz#md5=3be8a014c27340f48b56465f9109d9fa
    Processing virtualenv-1.7.1.2.tar.gz
    Running virtualenv-1.7.1.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-0nf1va/virtualenv-1.7.1.2/egg-dist-tmp-50Bugb
    warning: no previously-included files matching '.' found under directory 'docs/_templates'
    Adding virtualenv 1.7.1.2 to easy-install.pth file
    Installing virtualenv script to /home/jaraco/.local/bin

    Installed /home/jaraco/.local/lib/python2.7/site-packages/virtualenv-1.7.1.2-py2.7.egg
    Processing dependencies for virtualenv
    Finished processing dependencies for virtualenv
    jaraco@ichiro:~$ virtualenv irc
    New python executable in irc/bin/python
    Installing setuptools............done.
    Installing pip...............done.
    jaraco@ichiro:~$ irc/bin/pip install irc
    Downloading/unpacking irc
    Downloading irc-1.1.zip (105Kb): 105Kb downloaded
    Running setup.py egg_info for package irc
    Searching for hgtools
    Reading http://pypi.python.org/simple/hgtools/
    Reading http://bitbucket.org/jaraco/hgtools/
    Reading http://bitbucket.org/jaraco/hgtools/downloads/
    Best match: hgtools 2.0
    Downloading http://pypi.python.org/packages/source/h/hgtools/hgtools-2.0.zip#md5=cafbbcb7828e1d155eb2dd11474bea04
    Processing hgtools-2.0.zip
    Running hgtools-2.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-G7t884/hgtools-2.0/egg-dist-tmp-JqeYlM
    /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'use_2to3'
    warnings.warn(msg)
    installing library code to build/bdist.linux-x86_64/egg
    zip_safe flag not set; analyzing archive contents...
    removing 'build/bdist.linux-x86_64/egg' (and everything under it)
    Moving hgtools-2.0-py2.7.egg to /home/jaraco/irc/build/irc

    Installed /home/jaraco/irc/build/irc/hgtools-2.0-py2.7.egg
    

    Installing collected packages: irc
    Running setup.py install for irc
    Successfully installed irc
    Cleaning up...
    jaraco@ichiro:~$ irc/bin/pip install --upgrade irc
    Requirement already up-to-date: irc in ./irc/lib/python2.7/site-packages
    Cleaning up...
    araco@ichiro:~$ ls irc/lib/python2.7/site-packages/
    easy-install.pth irc-1.1-py2.7.egg-info setuptools-0.6c11-py2.7.egg
    irc pip-1.1-py2.7.egg setuptools.pth

     
  • This is certainly frustrating…

    First: I have root access to the linux box in question. The hgtools package v2.0 is installed and visible by both python 2.6 and 2.7. The distribute, setuptools and pip packages are all the newest versions.

    The jaraco.utils package exhibits the same behaviour on second and subsequent installs, so I think you're on to something (not quite sure what, though).

    Oh, and I have patience for this for as long as you have. It's not a big problem, just surprising. :)

     
  • FYI, you should not need hgtools installed to install irclib. Setuptools pulls it down automatically during the install process.

    But since you have hgtools installed, can you do this for me? I want to see if hgtools is able to calculate the version properly from the irclib package you have. Run these commands:

    jaraco@ichiro:~$ alias unzip-stream='python -c "import zipfile, sys, io; zipfile.ZipFile(io.BytesIO(sys.stdin.read())).extractall()"'
    jaraco@ichiro:~$ wget http://pypi.python.org/packages/source/i/irc/irc-1.1.zip -O - 2> /dev/null | unzip-stream
    jaraco@ichiro:~$ ls
    irc-1.1
    jaraco@ichiro:~$ cd irc-1.1
    jaraco@ichiro:~/irc-1.1$ python -c "import hgtools.plugins; print(hgtools.plugins.calculate_version())"
    1.1

    You can see the results I get from it when I run the commands on my local system. It pulls down the zip file and extracts it to the local disk. It then changes to that directory and runs the version calculation locally on the extracted sdist. That's very similar to what setuptools does when it installs the package.

    I expect it to print '1.1', just as it did on my machine.

    I look forward to your findings.

     
  • $ python -c "import hgtools.plugins; print(hgtools.plugins.calculate_version())"
    None
    $

    Hm…, what now?

     
  • Perhaps the following brings us one step closer. Instead of letting hgtools call the config parser, I do it manually (current working dir is irc-1.1 from the unpacked irclib zip file):

    import configparser
    parser=configparser.ConfigParser()
    parser.read('setup.cfg')
    []
    parser.read(u'setup.cfg')
    [u'setup.cfg']

    So configparser fails on reading the setup.cfg file in current directory because the filename is given as a string, not a unicode.

    This happens because configparser makes a stupid assumption in the .read() method:

    »if isinstance(filenames, unicode): filenames = [filenames]«

    and later

    »for filename in filenames:«

    This is provable. If I from the shell link setupd.cfg to the "file" s (ln -s setup.cfg s) we get the following:

    import configparser
    parser=configparser.ConfigParser()
    parser.read('setup.cfg')
    ['s']

    and from the shell:

    $ python -c "import hgtools.plugins; print(hgtools.plugins.calculate_version())"
    1.1
    $

    Voilà! :)

     
  • I tried with my debian squeeze and it worked just fine. You probably have an issue on your side.

     
  • Right, the issue is that I have let pip upgrade configparser to pypi's https://pypi.python.org/pypi/configparser/3.2.0r3 which is a backport of python 3.2's configparser.

    Now the unicode issue makes sense…

     
  • I uninstalled configparser (i.e., the backport of 3.2's configparser), and now pip says:

    $ pip-2.7 install --upgrade irc
    Requirement already up-to-date: irc in /usr/local/lib/python2.7/dist-packages
    Cleaning up...

     
  • Nice work! So now the question is - can this behavior be fixed so that it doesn't fail on Python 3 or Python 2 with the configparser backport? Would it fix the issue altogether if hgtools simply converted the filename to unicode before passing it to configparser? That will be a little tricky because the module has to run as Python 2 and Python 3 natively. I guess alternatively, I could give preference to the Python 2 ConfigParser module, and only fall back (or, more appropriately, forward) to configparser when running under Python 3.

     


Anonymous


Cancel   Add attachments