Skip to content

Commit 8342b95

Browse files
committed
Remove useless heading, decrease heading levels
Update MyST meta tags
1 parent e2ec34a commit 8342b95

File tree

1 file changed

+44
-47
lines changed

1 file changed

+44
-47
lines changed

docs/backend/upgrading/version-specific-migration/upgrade-to-python3.md

Lines changed: 44 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,42 @@
11
---
22
myst:
33
html_meta:
4-
"description": "Upgrading to Python 3"
5-
"property=og:description": "Upgrading to Python 3"
6-
"property=og:title": "Upgrading to Python 3"
7-
"keywords": "Upgrading, Python 3"
4+
"description": "Upgrading to Python 3 in Plone 5.2"
5+
"property=og:description": "Upgrading to Python 3 in Plone 5.2"
6+
"property=og:title": "Upgrading to Python 3 in Plone 5.2"
7+
"keywords": "Upgrading, Python 3, Plone 5.2"
88
---
99

1010

1111
(migrating-52-to-python3-label)=
1212

1313
# Migrating Plone 5.2 to Python 3
1414

15-
```{admonition} Description
16-
Instructions and tips for porting Plone projects to Python 3
17-
```
15+
This chapter provides instructions and tips for porting Plone projects to Python 3.
1816

19-
```{note}
20-
If you want to upgrade add-ons to Python 3, the list of all Plone packages that still need to be ported can be found on the GitHub project board [Python 3 porting state for Plone add-ons](https://github.com/orgs/collective/projects/1).
17+
```{seealso}
18+
If you want to upgrade add-ons to Python 3, the list of all Plone packages that still need to be ported can be found on the GitHub project board [Python 3 porting state for Plone add-ons](https://github.com/orgs/collective/projects/1).
2119
```
2220

23-
## Make Custom Packages Python 3 Ready
21+
## Principles
2422

25-
### Principles
23+
- You should support Python 2 and 3 with the same codebase to allow it to be used in existing versions of Plone.
24+
- Plone 5.2 supports Python 2.7, Python 3.6, Python 3.7, and Python 3.8.
25+
- We use [six](https://six.readthedocs.io) and [modernize](https://pypi.org/project/modernize) for the first steps toward Python 3.
2626

27-
- You should support Python 2 and 3 with the same codebase to allow it to be used in existing versions of Plone.
28-
- Plone 5.2 supports Python 2.7, Python 3.6, and Python 3.7.
29-
- We use [six](https://six.readthedocs.io) and [modernize](https://pypi.org/project/modernize) to do the first steps towards Python 3.
27+
In general, you should follow these steps to port add-ons:
3028

31-
In general you should follow these steps to port add-ons:
29+
1. Prepare `buildout` for the add-on to be ported.
30+
2. Update code with [python-modernize](https://python-modernize.readthedocs.io/en/latest/).
31+
3. Use [plone.recipe.precompiler](https://github.com/plone/plone.recipe.precompiler) (also called `precompiler` for brevity) to find syntax errors.
32+
4. Start the instance and find more errors.
33+
5. Test functionality manually.
34+
6. Run and fix all tests.
35+
7. Update package information.
36+
8. Update package buildout and test setup.
3237

33-
1. Prepare `buildout` for the add-on to be ported.
34-
2. Update code with [python-modernize](https://python-modernize.readthedocs.io/en/latest/).
35-
3. Use [plone.recipe.precompiler](https://github.com/plone/plone.recipe.precompiler) (also called `precompiler` for brevity) to find syntax errors.
36-
4. Start the instance and find more errors.
37-
5. Test functionality manually.
38-
6. Run and fix all tests.
39-
7. Update package information.
40-
8. Update package buildout and test-setup
4138

42-
### 1 Preparation
39+
## 1. Preparation
4340

4441
In the GitHub repository of the add-on:
4542

@@ -51,13 +48,13 @@ The following section is valid until the final release of Plone 5.2.
5148
Upon the final release of Plone 5.2, something else will take its place.
5249
```
5350

54-
#### Using Released Plone 5.2
51+
### Using Released Plone 5.2
5552

5653
Usually it is fine to use the latest Plone 5.2 release.
5754
The version pins for the latest release can be found for pip at [https://dist.plone.org/release/5.2-latest/requirements.txt] and for buildout at [https://dist.plone.org/release/5.2-latest/versions.cfg].
5855
Install Plone with Python 3.6 or 3.7 and then add your addons as source using mr.developer\`.
5956

60-
#### Using Core Development Buildout
57+
### Using Core Development Buildout
6158

6259
With [buildout.coredev](https://github.com/plone/buildout.coredev) the latest development version of Plone can be used.
6360
It contains everything for porting an add-on to Python 3.
@@ -141,7 +138,7 @@ For small packages or packages that have few dependencies, it is a good idea to
141138

142139
If it does not start up, you should continue with the next steps instead of trying to fix each issue as it appears.
143140

144-
### 2 Automated Fixing With Modernize
141+
## 2. Automated Fixing With Modernize
145142

146143
`python-modernize` is a utility that automatically prepares Python 2 code for porting to Python 3.
147144
After running `python-modernize`, there is manual work ahead.
@@ -159,7 +156,7 @@ Check the [Python style guide for Plone](https://docs.plone.org/develop/stylegui
159156

160157
If `six` is used in the code, make sure that `six` is added to the `install_requires` list in the `setup.py` of the package.
161158

162-
#### Installation
159+
### Installation
163160

164161
Install `modernize` into your Python 3 environment with `pip`.
165162

@@ -173,7 +170,7 @@ Install `isort` into your Python 3 environment with `pip`.
173170
./bin/pip install isort
174171
```
175172

176-
#### Usage
173+
### Usage
177174

178175
The following command is a dry-run. I shows all changes that `modernize` would make.
179176

@@ -201,7 +198,7 @@ You can use `isort` to fix the order of imports:
201198

202199
After you run the commands above, you need to review all changes and fix what `modernizer` did not get right.
203200

204-
### 3 Use `precompiler`
201+
## 3. Use `precompiler`
205202

206203
You can make use of `plone.recipe.precompiler` to identify syntax errors quickly.
207204
This recipe compiles all Python code already at buildout-time, not at run-time.
@@ -221,20 +218,20 @@ If you want to avoid running the complete buildout every time, you can use the `
221218
./bin/buildout -c local.cfg install precompiler
222219
```
223220

224-
### 4 Start The Instance
221+
## 4. Start The Instance
225222

226223
As a next step we recommend that you try to start the instance with your add-on.
227224
This will fail on all import errors (e.g., relative imports that are not allowed in Python 3).
228225
If it works then you can try to install the add-on.
229226

230227
You need to fix all issues that appear before you can do manual testing to check for big, obvious issues.
231228

232-
#### Common Issues during startup
229+
### Common Issues during startup
233230

234231
The following issues will abort your startup.
235232
You need to fix them before you are able to test the functionality by hand or run tests.
236233

237-
##### A - Class Advice
234+
#### A - Class Advice
238235

239236
This kind of error message:
240237

@@ -265,17 +262,17 @@ class Group(form.BaseForm):
265262
The same is the case for `provides(IFoo)` and some other Class advices.
266263
These need to be replaced with their respective decorators like `@provider`.
267264

268-
##### B - Relative Imports
265+
#### B - Relative Imports
269266

270267
Relative imports like `import permissions` are no longer permitted.
271268
Instead use fully qualified import paths such as `from collective.package import permissions`.
272269

273-
##### C - Syntax Error On Importing Async
270+
#### C - Syntax Error On Importing Async
274271

275272
In Python 3.7 you can no longer have a module called `async` (see <https://github.com/celery/celery/issues/4849>).
276273
You need to rename all such files, folders or packages (like `zc.async` and `plone.app.async`).
277274

278-
### 5 Test functionality manually
275+
## 5. Test functionality manually
279276

280277
Now that the instance is running you should do the following and fix all errors as they appear.
281278

@@ -285,7 +282,7 @@ Now that the instance is running you should do the following and fix all errors
285282

286283
For this step it is recommended that you have installed `Products.PDBDebugMode` to help debug and fix issues.
287284

288-
### 6 Run Tests
285+
## 6. Run Tests
289286

290287
```shell
291288
$ ./bin/test --all -s collective.package
@@ -308,7 +305,7 @@ Search for examples of `Py23DocChecker` in Plone's packages to find a pattern wh
308305
- Fill the fields {guilabel}`ADDON_URL` and {guilabel}`ADDON_BRANCH` with your repository's URL and the branch name ("python3" if you followed these instructions).
309306
- Start the build with the {guilabel}`Build` button.
310307

311-
### 7 Update Add On Information
308+
## 7. Update Add On Information
312309

313310
Add the following three entries of the classifiers list in setup.py:
314311

@@ -321,7 +318,7 @@ Add the following three entries of the classifiers list in setup.py:
321318

322319
Make an entry in the `CHANGES.rst` file.
323320

324-
### 8 Create A Test Setup That Tests In Python 2 And Python 3
321+
## 8. Create A Test Setup That Tests In Python 2 And Python 3
325322

326323
You need to update the buildout of the add-on you are migrating to also support Plone 5.2 and Python 3.
327324
Since the buildout of most add-ons are different we cannot offer advice that works for all add-ons.
@@ -337,9 +334,9 @@ Always use the newest version of {py:mod}`bobtemplates.plone`!
337334

338335
Add-ons created like this contain a setup that allows testing in Python 2 and Python 3 and various Plone versions locally and on travis-ci using {py:mod}`tox`. Look at the files `tox.ini` and `travis.yml`.
339336

340-
### 9 Frequent Issues
337+
## 9. Frequent Issues
341338

342-
#### Text and Bytes
339+
### Text and Bytes
343340

344341
This is by far the biggest issue when porting to Python 3.
345342
Read the [Conservative Python 3 Porting Guide, Strings](https://portingguide.readthedocs.io/en/latest/strings.html) to be prepared.
@@ -377,10 +374,10 @@ from six import BytesIO
377374
```{seealso}
378375
Here is a list of helpful references on the topic of porting Python 2 to Python 3.
379376
380-
- <https://portingguide.readthedocs.io/en/latest/index.html>
381-
- <https://eev.ee/blog/2016/07/31/python-faq-how-do-i-port-to-python-3/>
382-
- <http://getpython3.com/diveintopython3/>
383-
- <https://docs.djangoproject.com/en/1.11/topics/python3/>
384-
- <https://docs.ansible.com/ansible/latest/dev_guide/developing_python_3.html>
385-
- <https://docs.python.org/2/library/doctest.html#debugging>
377+
- https://portingguide.readthedocs.io/en/latest/index.html
378+
- https://eev.ee/blog/2016/07/31/python-faq-how-do-i-port-to-python-3/
379+
- http://getpython3.com/diveintopython3/
380+
- https://docs.djangoproject.com/en/1.11/topics/python3/
381+
- https://docs.ansible.com/ansible/latest/dev_guide/developing_python_3.html
382+
- https://docs.python.org/2/library/doctest.html#debugging
386383
```

0 commit comments

Comments
 (0)