Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b542e01

Browse files
committed
Take into account most of Thomas comments.
1 parent 7cf319e commit b542e01

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

_practicalities/intro.md

+34-34
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ system will not try to upgrade said library.
3636

3737
With 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

4444
As a Python 2.7 user, if I don't pay attention, or if the library is not
4545
correctly tagged, if I issue the following:
4646

47-
$ python -c 'import fictious; print(fictious.__version__)'
47+
$ python -c 'import fictitious; print(fictitious.__version__)'
4848
1.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
9696
install a source distribution (aka `sdist`).
9797

9898
Installing 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
104102
will fail.
105103

@@ -131,9 +129,6 @@ deployed yet but should hopefully be deployed soon.
131129
PyPI](https://github.com/pypa/legacy-pypi) have received various patches to
132130
insure 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
167162
support. 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

170165
This will make [PyPI aware](https://github.com/pypa/warehouse/pull/1448) that
171166
your package is Python 3.3+ only, and [allow
172167
pip](https://github.com/pypa/pip/pull/3877) to be [made aware of
173168
this](https://github.com/pypa/pypi-legacy/pull/506).
174169

175-
Thus as long as your user have a recent enough version of pip, and setuptools
170+
Thus as long as your user have recent enough versions of pip and setuptools
176171
they will get the right version of your library.
177172

178173
# Unit Testing and documentation
@@ -212,7 +207,7 @@ the LTS branch).
212207

213208
Add an error early at import at runtime with a clear error message, leave the
214209
early 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

217212
Error at import time _will_ happen on system with old version of pip and
218213
setuptools. 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
230225
Unfortunately Frobulator 6.0 and above are not compatible with Python 2
231226
anymore, and you still ended up with this version installed on your system.
232-
That's a bummer. Sorry about that. It should not have happen. Make sure you
227+
That's a bummer. Sorry about that. It should not have happened. Make sure you
233228
have 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

284268
Leave `setup.py` python 2 compatible and fail early. If you detect Python 2
285269
raise a clear error message and ask user to make sure they have pip >9.0 (or
286270
migrate to Python 3). You can (try to) conditionally import pip and check for
287271
its version but this might not be the same pip. Failing early is important to
288-
make sure the Python installation does not install and incompatible version.
272+
make sure the Python installation does not install an incompatible version.
289273
Otherwise user code can fail at runtime arbitrary later in the future, which can
290274
be a difficult to debug and fix. Get inspiration from the message of failure at
291275
runtime, and adapt for installation time.
@@ -295,7 +279,7 @@ runtime, and adapt for installation time.
295279
If you control dependant packages, Make sure to include conditional dependencies
296280
depending on the version of Python.
297281

298-
# Incorrect mitigations
282+
# Non recommended mitigations
299283

300284
This is a collection of "mitigation" or "solutions" you will find on the web
301285
and 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.
313297
Moreover, upgrading your package may need the user to explicitly tell pip to
314298
upgrade 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

318318
Pip (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
341341
already Python 3 only, but are starting to stop support for earlier versions of
342342
Python. 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 release at the end of end 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

350350
The introduction of Python 3 was chaotic, there are still strong argument both
351351
in Python 2 and Python 3 camps. In the one suffering the most from this are

0 commit comments

Comments
 (0)