@@ -36,15 +36,15 @@ system will not try to upgrade said library.
3636
3737With the recent changes in Python packaging this is now possible.
3838
39- As an example let's look at the example of the` fictious ` library.
39+ As an example let's look at the example of the` fictitious ` library.
4040
41- - ` fictious ` 1.1, 1.2, 1.3, 1.4 are compatible Python 2.7 and 3.3+
42- - ` fictious ` 2.0 has been released and is python 3.4+ only.
41+ - ` fictitious ` 1.1, 1.2, 1.3, 1.4 are compatible Python 2.7 and 3.3+
42+ - ` fictitious ` 2.0 has been released and is python 3.4+ only.
4343
4444As a Python 2.7 user, if I don't pay attention, or if the library is not
4545correctly tagged, if I issue the following:
4646
47- $ python -c 'importfictious ; print(fictious .__version__)'
47+ $ python -c 'importfictitious ; print(fictitious .__version__)'
48481.3.2
4949$ pip install fiction --upgrade
5050
@@ -96,10 +96,8 @@ If you are on a system for which no wheel is available, pip will try to
9696install a source distribution (aka` sdist ` ).
9797
9898Installing an` sdist ` will require setuptools make sure you have setuptools
99- ` >=24.2.0 ` (mnemonic: 2-42,[ why
100- 42] ( https://en.wikipedia.org/wiki/The_answer_to_life_the_universe_and_everything )
101- ?) or building Python 3 only libraries is likely to fail. In particular if
102- library authors have taken time to mark their library as Python 3 only, the
99+ ` >=24.2.0 ` or building Python 3 only libraries is likely to fail. In particular
100+ if library authors have taken time to mark their library as Python 3 only, the
103101` python_requires ` argument to` setup() ` may not be recognized and installation
104102will fail.
105103
@@ -131,9 +129,6 @@ deployed yet but should hopefully be deployed soon.
131129PyPI] ( https://github.com/pypa/legacy-pypi ) have received various patches to
132130insure they support this new functionality.
133131
134- You can publish a package with the` requires_python ` metadata** now** , it will
135- be correctly exposed once pypi is deployed.
136-
137132#Preparing your library
138133
139134
@@ -163,16 +158,16 @@ setup(
163158)
164159```
165160
166- Changes ` >=3.3 ` accordingly depending on what version your library decides to
161+ Change ` >=3.3 ` accordingly depending on what version your library decides to
167162support. In particular you can use` >=2.6 ` or` >=3.5 ` ! Note that this also
168- support the_ compable with_ syntax:` ~=2.5 ` (meaning,` >=2.5 ` and` <3 ` .
163+ support the_ compable with_ syntax:` ~=2.5 ` (meaning,` >=2.5 ` and` <3 ` ) .
169164
170165This will make[ PyPI aware] ( https://github.com/pypa/warehouse/pull/1448 ) that
171166your package is Python 3.3+ only, and[ allow
172167pip] ( https://github.com/pypa/pip/pull/3877 ) to be[ made aware of
173168this] ( https://github.com/pypa/pypi-legacy/pull/506 ) .
174169
175- Thus as long as your user havea recent enoughversion of pip, and setuptools
170+ Thus as long as your user have recent enoughversions of pip and setuptools
176171they will get the right version of your library.
177172
178173#Unit Testing and documentation
@@ -212,7 +207,7 @@ the LTS branch).
212207
213208Add an error early at import at runtime with a clear error message, leave the
214209early import compatible Python 2 for users to not be welcomed with a useless
215- ` SyntaxError ` .You are _ allowed _ to use multi-line strings in error messages.
210+ ` SyntaxError ` .Don't hesitate to use multi-line strings in error messages.
216211
217212Error at import time_ will_ happen on system with old version of pip and
218213setuptools. Keep in mind that saying the package is Python 3 only is not a lot
@@ -229,7 +224,7 @@ if sys.version_info < (3,):
229224
230225Unfortunately Frobulator 6.0 and above are not compatible with Python 2
231226anymore, and you still ended up with this version installed on your system.
232- That's a bummer. Sorry about that. It should not havehappen . Make sure you
227+ That's a bummer. Sorry about that. It should not havehappened . Make sure you
233228have pip >= 9.0 to avoid this kind of issues, as well as setuptools >= 24.2:
234229
235230 $ pip install pip setuptools --upgrade
@@ -267,25 +262,14 @@ The regular expression to check for validity of pep440 can be find below:
267262
268263` ^([1-9]\\d*!)?(0|[1-9]\\d*)(\\.(0|[1-9]\\d*))*((a|b|rc)(0|[1-9]\\d*))?(\\.post(0|[1-9]\\d*))?(\\.dev(0|[1-9]\\d*))? `
269264
270- ##Depend on setuptools
271-
272- You can mark your library as dependent on setuptools greater than 24.3 starting
273- now, this will insure that during the next upgrade (when the packages drop
274- python 2 support) will have the right version of setuptools.
275-
276- Of course regardless of all the care you will take for your library to no break
277- and to install only on python 2, you will likely have cases where it still end
278- up being installed on incompatible versions of Python. Simply because users
279- upgrades rarely and only an old version of pip or setuptools is enough to make
280- the all update process broken.
281265
282266##fail early in setup.py
283267
284268Leave` setup.py ` python 2 compatible and fail early. If you detect Python 2
285269raise a clear error message and ask user to make sure they have pip >9.0 (or
286270migrate to Python 3). You can (try to) conditionally import pip and check for
287271its version but this might not be the same pip. Failing early is important to
288- make sure the Python installation does not installand incompatible version.
272+ make sure the Python installation does not installan incompatible version.
289273Otherwise user code can fail at runtime arbitrary later in the future, which can
290274be a difficult to debug and fix. Get inspiration from the message of failure at
291275runtime, and adapt for installation time.
@@ -295,7 +279,7 @@ runtime, and adapt for installation time.
295279If you control dependant packages, Make sure to include conditional dependencies
296280depending on the version of Python.
297281
298- #Incorrect mitigations
282+ #Non recommended mitigations
299283
300284This is a collection of "mitigation" or "solutions" you will find on the web
301285and that you will hear about. This is an attempt to acknowledge them, and
@@ -313,6 +297,22 @@ this approach is _doable_ this can make imports confusing.
313297Moreover, upgrading your package may need the user to explicitly tell pip to
314298upgrade dependencies as` pip install -U frob ` will only upgrade the meta-package.
315299
300+ ##Depend on setuptools
301+
302+ You can mark your library as dependent on setuptools greater than 24.3 this
303+ will insure that during the next upgrade (when the packages drop python 2
304+ support) will have the right version of setuptools.
305+
306+ Of course regardless of all the care you will take for your library to no break
307+ and to install only on python 2, you will likely have cases where it still end
308+ up being installed on incompatible versions of Python. Simply because users
309+ upgrades rarely and only an old version of pip or setuptools is enough to make
310+ the all update process broken.
311+
312+ Plus setuptools is rarely an actual dependency of your project but a
313+ requirement to build wheels.
314+
315+
316316###Multiple Sdist.
317317
318318Pip (used to) support a "feature" where a sdist ending in` -pyX.Y.tar.gz ` would
@@ -341,11 +341,11 @@ can also apply to libraries that are only stopping support for 2.6, or even are
341341already Python 3 only, but are starting to stop support for earlier versions of
342342Python. For example a library releasing a Python 3.4+ only version.
343343
344- Python 3.3 was release end of 2012, and was the first version to support
345- (again)` u ` as a prefix for Unicode string. It was one of the first minor
346- version of Python 3 that saw a majority of single-source project working both
347- on Python 2 and Python 3. These are the Project that will likely be affected by
348- this issue.
344+ Python 3.3 was releaseat the end ofend of 2012, and was the first version to
345+ support (again)` u ` as a prefix for Unicode string. It was one of the first
346+ minor version of Python 3 that saw a majority of single-source project working
347+ both on Python 2 and Python 3. These are the Project that will likely be
348+ affected by this issue.
349349
350350The introduction of Python 3 was chaotic, there are still strong argument both
351351in Python 2 and Python 3 camps. In the one suffering the most from this are