Skip to content

Commit

Permalink
PEP 582: Updates to internal directory structure (#2750)
Browse files Browse the repository at this point in the history
* Updates 582 with internal directory example

Now we have working example in both Cpython & in PyPy.

* Fixes Python version
  • Loading branch information
kushaldas authored Aug 6, 2022
1 parent be96146 commit 949dc03
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions pep-0582.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Type: Standards Track
Topic: Packaging
Content-Type: text/x-rst
Created: 16-May-2018
Python-Version: 3.8
Python-Version: 3.12


Abstract
Expand Down Expand Up @@ -89,14 +89,15 @@ the Python executable and any script will behave.

foo
__pypackages__
3.8
lib
bottle
lib
python3.10
site-packages
bottle
myscript.py

/> python foo/myscript.py
sys.path[0] == 'foo'
sys.path[1] == 'foo/__pypackages__/3.8/lib'
sys.path[1] == 'foo/__pypackages__/lib/python3.10/site-packages/'


cd foo
Expand All @@ -109,15 +110,17 @@ the Python executable and any script will behave.

foo> python
sys.path[0] == '.'
sys.path[1] == './__pypackages__/3.8/lib'
sys.path[1] == './__pypackages__/lib/python3.10/site-packages'

foo> python -m bottle

We have a project directory called ``foo`` and it has a ``__pypackages__``
inside of it. We have ``bottle`` installed in that
``__pypackages__/3.8/lib``, and have a ``myscript.py`` file inside of the
project directory. We have used whatever tool we generally use to install ``bottle``
in that location.
``__pypackages__/lib/python3.10/stie-packages/``, and have a ``myscript.py``
file inside of the project directory. We have used whatever tool we generally
use to install ``bottle`` in that location. This actual internal path will
depend on the Python implementation name, as mentioned in the
``sysconfig._INSTALL_SCHEMES['posix_prefix']`` dictionary.

For invoking a script, Python will try to find a ``__pypackages__`` inside of
the directory that the script resides[1]_, ``/usr/bin``. The same will happen
Expand Down Expand Up @@ -180,8 +183,8 @@ adding it the ``sys.path`` just before site packages, if it is present.
Reference Implementation
========================

`Here <https://github.com/kushaldas/cpython/tree/pypackages>`_ is a PoC
implementation (in the ``pypackages`` branch).
`Here <https://github.com/kushaldas/pep582>`_ is a small script which will
enable the implementation for ``Cpython`` & in ``PyPy``.


Rejected Ideas
Expand Down

0 comments on commit 949dc03

Please sign in to comment.