Skip to content

Commit cdcd9cd

Browse files
committed
Add a migration guide for pth->start files
1 parent 1bc0ac4 commit cdcd9cd

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Doc/library/site.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,29 @@ See :pep:`829` for the full specification.
183183
file are ignored in favour of the entry points in the :file:`.start`
184184
file.
185185

186+
.. _site-migration-guide:
187+
188+
Migrating from ``import`` lines in ``.pth`` files to ``.start`` files
189+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
190+
191+
If your package currently ships a :file:`{name}.pth` file, you can keep all
192+
``sys.path`` extension lines unchanged. Only ``import`` lines need to be
193+
migrated.
194+
195+
To migrate, create a callable (taking zero arguments) within an importable
196+
module in your package. Reference it as a ``pkg.mod:callable`` entry point
197+
in a matching :file:`{name}.start` file.
198+
199+
If your package must straddle older Pythons that do not support :pep:`829`
200+
and newer Pythons that do, change the ``import`` lines in your
201+
:file:`{name}.pth` to use the following form::
202+
203+
import pkg.mod; pkg.mod.callable()
204+
205+
Older Pythons will execute these ``import`` lines, while newer Pythons will
206+
ignore them in favor of the :file:`{name}.start` file. After the straddling
207+
period, remove all ``import`` lines from your :file:`.pth` file.
208+
186209

187210
:mod:`!sitecustomize`
188211
---------------------

0 commit comments

Comments
 (0)