[Distutils] Varying dependencies by python minor version (2.7.9)

Daniel Holth dholth at gmail.com
Fri Dec 12 21:52:54 CET 2014


It is possible and supported but not very elegant since the marker
syntax can only compare versions as strings (you wouldn't want to use
< and have the wrong dependencies under Python 2.7.10). One solution
would be to check that you are not running on any of the older
releases of Python 2.7, like so:

In setup.py:

      extras_require={
          ':python_version == "2.7" and (python_full_version!="2.7.8"
and python_full_version!="2.7.7" and ...)':
['backports.ssl_match_hostname'],
      }

This means the extra named '' a.k.a. the default dependencies includes
your package, but only if the expression after the colon : evaluates
to True. bdist_wheel preserves the expression in .whl binary packages.


On Fri, Dec 12, 2014 at 11:09 AM, Ben Darnell <ben at bendarnell.com> wrote:
> Hi distutils-sig,
>
> Tornado depends on backports.ssl_match_hostname on python 2, but this is no
> longer needed with (cpython) 2.7.9. We have a PR to make this dependency
> conditional on the minor version of python
> (https://github.com/tornadoweb/tornado/pull/1276/files). We could also make
> the test something like `hasattr(ssl, 'SSLContext')`, which would be more
> compatible with pypy and other implementations, but the fundamental issues
> remain. Is it a good idea to distribute packages that will install different
> dependencies on different minor versions of python? Is it even possible with
> binary distributions? I'm thinking it's probably best to just live with the
> unused extra dependency (until we can completely drop support for python
> versions without modern ssl libraries), but I wanted to check and see if
> there is a clean way to deal with this.
>
> Thanks,
> -Ben
>
> _______________________________________________
> Distutils-SIG maillist  -  Distutils-SIG at python.org
> https://mail.python.org/mailman/listinfo/distutils-sig
>


More information about the Distutils-SIG mailing list