[Distutils] Local version identifiers from PEP 440 in practice

Maurits van Rees m.van.rees at zestsoftware.nl
Wed Dec 17 13:07:06 CET 2014


Maurits van Rees schreef op 17-12-14 01:46:
> Maurits van Rees schreef op 17-12-14 00:53:
>> I have created a very basic python project called 'myproject'.  It
>> does nothing.  I have released a few versions here:
>> http://pypi.zestsoftware.nl/public/packagingtest/
>
> I have now also distributed myproject version 1.1.  (This has a
> base.jinja2 file and requires Jinja2[i18n], which I need for checking
> a corner case; I may report that later).

I will report that now.


I ran into some problems earlier with an internal release of Babel.

Problem is that I use Jinja2 and this has a requirement on
'Babel>=0.8'.  This gives extra problems in some cases, maybe more
because entry points are used.  In some cases installing works fine,
but actually using the package gives an error.

For clarity: I don't think the notes below indicate a bug in
setuptools or pip or buildout.  It just shows some possibly unexpected
behaviour.

Latest official Babel release is 1.3.  I have created a few
development releases and added them to
http://pypi.zestsoftware.nl/public/

Some versions there are PEP 440 compliant, others not.  Some may make
sense, other not.  In order of creation:

- setup.py version 2.0a0.zest.20141021: Babel-2.0a0.zest.20141021.zip

- setup.py version 2.0a1.zest.20141021: Babel-2.0a1.zest.20141021.zip

- setup.py version 2.0a1+zest.20141216: Babel-2.0a1-zest.20141216.zip

- setup.py version 2.0a1+zest.201412162: Babel-2.0a1+zest.201412162.zip

Let's try them out.


Babel and buildout
------------------

With the earlier given buildout, I added an extra directory to the 
find-links:

find-links = http://pypi.zestsoftware.nl/public/packagingtest/
     http://pypi.zestsoftware.nl/public/

Then I updated the Babel version in the [versions] section.

- Babel = 2.0a1.zest.20141021
   * Works in setuptools 7.
   * Does not work setuptools 8:
     Error: Bad constraint 2.0a1.zest.20141021 Babel>=0.8

- Babel = 2.0a1-zest.20141216
   * Works in setuptools 7.
   * Does not work setuptools 8:
     Error: Bad constraint 2.0a1.zest.20141021 Babel>=0.8

- Babel = 2.0a1+zest.201412162
   * Does not work in setuptools 8:
     ValueError: ("Expected ',' or end-of-list in", 
'Babel[]==2.0a1+zest.201412162', 'at', '+zest.201412162')
   * Works in setuptools 8


Babel and pip
-------------

- Babel==2.0a1.zest.20141021
   * pip 1.5.6 works fine
   * pip dev fails when using it:
     $ ../venv-newest/bin/python setup.py extract_messages 
--mapping-file=extract.ini --output-file=foo.pot
     running extract_messages
     extracting messages from myproject/__init__.py
     extracting messages from myproject/base.jinja2
     Traceback (most recent call last):
       File "setup.py", line 11, in <module>
         'Jinja2[i18n]',
       File 
"/Users/mauritsvanrees/buildout/python2.7/parts/opt/lib/python2.7/distutils/core.py", 
line 151, in setup
         dist.run_commands()
       File 
"/Users/mauritsvanrees/buildout/python2.7/parts/opt/lib/python2.7/distutils/dist.py", 
line 953, in run_commands
         self.run_command(cmd)
       File 
"/Users/mauritsvanrees/buildout/python2.7/parts/opt/lib/python2.7/distutils/dist.py", 
line 972, in run_command
         cmd_obj.run()
       File 
"/Users/mauritsvanrees/tmp/venv-newest/lib/python2.7/site-packages/babel/messages/frontend.py", 
line 305, in run
         for filename, lineno, message, comments, context in extracted:
       File 
"/Users/mauritsvanrees/tmp/venv-newest/lib/python2.7/site-packages/babel/messages/extract.py", 
line 163, in extract_from_dir
         strip_comment_tags):
       File 
"/Users/mauritsvanrees/tmp/venv-newest/lib/python2.7/site-packages/babel/messages/extract.py", 
line 190, in extract_from_file
         strip_comment_tags))
       File 
"/Users/mauritsvanrees/tmp/venv-newest/lib/python2.7/site-packages/babel/messages/extract.py", 
line 249, in extract
         func = entry_point.load(require=True)
       File 
"/Users/mauritsvanrees/tmp/venv-newest/lib/python2.7/site-packages/pkg_resources.py", 
line 2242, in load
         self.require(env, installer)
       File 
"/Users/mauritsvanrees/tmp/venv-newest/lib/python2.7/site-packages/pkg_resources.py", 
line 2256, in require
         items = working_set.resolve(reqs, env, installer)
       File 
"/Users/mauritsvanrees/tmp/venv-newest/lib/python2.7/site-packages/pkg_resources.py", 
line 751, in resolve
         raise VersionConflict(tmpl % args)
     pkg_resources.VersionConflict: Babel 2.0a1.zest.20141021 is 
installed but Babel>=0.8 is required by []
   * DANGER: a version that previously worked fine and still installs
     fine, is broken when using it.  This may be troublesome.  Mostly
     you should just be aware of it.  Basically, this wrongly named
     internal version number of my Babel distribution does not work
     nicely with setuptools 8 when you also use jinja2.
   * I only wonder if something needs fixing in Babel's usage of the
     entry point.

- Babel==2.0a1-zest.20141216
   * pip 1.5.6 works fine
   * pip dev works fine (with version warning while installing)
   * Note that it works because the setup.py version is a valid 440
     version: 2.0a1+zest.20141216

- Babel==2.0a1+zest.20141216
   * pip 1.5.6 fails to install: plus is not accepted.
   * pip dev fails to install.  Error message is: "No distributions
     matching the version for Babel==2.0a1+zest.20141216".  This is
     logical, because this distribution was created with setuptools 7
     or earlier, which results in a file name that does not exactly
     match the version.

- Babel==2.0a1+zest.201412162
   * pip 1.5.6 fails to install: plus is not accepted.
   * pip dev fails to install.
   * pip dev with pull request #2205 (Expand our regex to support the
     new PEP 440 version characters) works fine.

- pip install 
http://pypi.zestsoftware.nl/public/Babel-2.0a1+zest.201412162.zip
   * pip 1.5.6 works fine
   * pip dev works fine



-- 
Maurits van Rees: http://maurits.vanrees.org/
Zest Software: http://zestsoftware.nl



More information about the Distutils-SIG mailing list