Re: [Distutils] Limit package installation to a specific Python version

2017-01-20 Thread Matthias Bussonnier
Hi all,

On Fri, Jan 20, 2017 at 2:56 PM, Nathaniel Smith  wrote:
> On Fri, Jan 20, 2017 at 1:56 PM, Lele Gaifax  wrote:
>> Hi all,
>>
>> do installers like pip and conda consult trove classifiers, or more generally
>> is there a way to "mark" a package published on PyPI as installable only in a
>> Python 3 environment?
>>

>  For sdists, historically there was no way to do this, but as of a
> few months ago this was fixed and pip now *does* honor
> python_requires, and PyPI has been updated to expose this information
> so pip can see it before downloading the sdists:
>
> https://github.com/pypa/pip/pull/3846
> https://github.com/python/peps/pull/56
> https://github.com/pypa/pip/pull/3877
>
> Since this is a pretty recent change, you probably want to put a
> runtime check inside your setup.py for old Python versions, so if
> someone uses an old version of pip then they will at least get a nice
> explanation.
>
> IPython's an example of a python-3-only project that uses this
> belt-and-suspenders approach:
>
> https://github.com/ipython/ipython/blob/f060158665189fd456e54a5a864080efe28b4fdf/setup.py#L29
> https://github.com/ipython/ipython/blob/f060158665189fd456e54a5a864080efe28b4fdf/setup.py#L248
>

I'm also in the (slow) process of writing the various step you can
take when python_requires is not honored by older systems and how to
mitigate that:

https://github.com/python3statement/python3statement.github.io/pull/55

Feedback (and help) would be welcome.

In particular only system where pip 9.0+ is installed will understand
the metadata now exposed by PyPI,
so when/if you fail in your setup.py, a useful tip is to ask user to
upgrade pip.

There should be some snipets of code you copy and past in your
setup.py in this PR as well.

Thanks.
-- 
M
___
Distutils-SIG maillist  -  Distutils-SIG@python.org
https://mail.python.org/mailman/listinfo/distutils-sig


Re: [Distutils] Limit package installation to a specific Python version

2017-01-20 Thread Lele Gaifax
Great, thank you Nathaniel!
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
l...@metapensiero.it  | -- Fortunato Depero, 1929.

___
Distutils-SIG maillist  -  Distutils-SIG@python.org
https://mail.python.org/mailman/listinfo/distutils-sig


Re: [Distutils] Limit package installation to a specific Python version

2017-01-20 Thread Nathaniel Smith
On Fri, Jan 20, 2017 at 1:56 PM, Lele Gaifax  wrote:
> Hi all,
>
> do installers like pip and conda consult trove classifiers, or more generally
> is there a way to "mark" a package published on PyPI as installable only in a
> Python 3 environment?
>
> An user proposed[1] to change the classifiers of a package to get that result,
> so I tried looking at pip and setuptools sources, but didn't find evidence of
> that. I see both use python_requires[2] in their setup that seem closer to the
> goal, but again, is that actually honored by pip and/or other installers?
>
> Thanks for any hint,
> ciao, lele.
>
> [1] https://github.com/python-rapidjson/python-rapidjson/pull/47
> [2] https://www.python.org/dev/peps/pep-0345/#requires-python

Neither pip nor conda do anything automatically with trove
classifiers. Conda uses its own metadata added when the conda package
is built; whoever runs your conda-build can probably figure something
out. Wheels have always had this metadata and pip has always honored
it. For sdists, historically there was no way to do this, but as of a
few months ago this was fixed and pip now *does* honor
python_requires, and PyPI has been updated to expose this information
so pip can see it before downloading the sdists:

https://github.com/pypa/pip/pull/3846
https://github.com/python/peps/pull/56
https://github.com/pypa/pip/pull/3877

Since this is a pretty recent change, you probably want to put a
runtime check inside your setup.py for old Python versions, so if
someone uses an old version of pip then they will at least get a nice
explanation.

IPython's an example of a python-3-only project that uses this
belt-and-suspenders approach:

https://github.com/ipython/ipython/blob/f060158665189fd456e54a5a864080efe28b4fdf/setup.py#L29
https://github.com/ipython/ipython/blob/f060158665189fd456e54a5a864080efe28b4fdf/setup.py#L248

-n

-- 
Nathaniel J. Smith -- https://vorpus.org
___
Distutils-SIG maillist  -  Distutils-SIG@python.org
https://mail.python.org/mailman/listinfo/distutils-sig