Skip to main content

A library for installing distributions in editable mode.

Project description

This is a PoC of an editable library which operates on the frontend as discussed on the Python packaging Discourse. It supports installing prospective editable distributions using three different methods (symlink, redirector and .pth files) and two strategies (lax and strict). The strict strategy reproduces the distribution structure faithfully whereas the lax strategy exposes the contents of packages as they appear on disk. The input must be a mapping of would-be wheel file paths and absolute paths on disk; folder paths are invalid. This library does not manipulate data files or scripts because I consider that to be an unnecessary complication in the context of editable installation.

Installation

$ python -m pip install frontend-editables

Basic usage

import sysconfig

import frontend_editables

path_mapping = ...  # Will have been returned by the backend.
installed_files = frontend_editables.install(
    "name",
    sysconfig.get_path("purelib"),
    path_mapping,
    frontend_editables.EditableStrategy.lax,
)
# Then append the ``installed_files`` to the distribution's ``RECORD``,
# optionally by passing ``append_to_record=<path to RECORD>`` to ``install``.

CLI

frontend_editables includes an extremely hacky CLI which serves a stopgap until editable installation is standardised. You can use this in place of python -m pip install -e .... The CLI supports all of the same layouts and installation methods supported by the library. Some examples:

  • To install a project with a single module foo.py, symlinking it: python -m frontend_editables.transitional_cli --strategy strict foo.py foo.py.

  • To install a project with a package foo, located in <project-root>/src/foo, with the aid of a pth file: python -m frontend_editables.transitional_cli --method pth_file src/foo foo.

  • To install a project with multiple packages at different locations: python -m frontend_editables.transitional_cli {src/,}foo {lib/,}bar

Editable distributions can be uninstalled with pip as normal.

usage: python -m frontend_editables.transitional_cli [-h]
                                                     [--method {symlink,redirect,pth_file}]
                                                     [--strategy {lax,strict}]
                                                     [--spec SPEC]
                                                     path_pairs
                                                     [path_pairs ...]

Wacky transitional editable project installer.

positional arguments:
  path_pairs            pairs of path on disk and corresponding path in
                        the virtual wheel (posix)

optional arguments:
  -h, --help            show this help message and exit
  --method {symlink,redirect,pth_file}
                        editable installation method to use (default:
                        None)
  --strategy {lax,strict}
                        editable strategy to follow (default: lax)
  --spec SPEC           requirement specifier (default: .)

Contributing

You can use frontend-editables to install frontend-editables for development:

$ PYTHONPATH=src python -m frontend_editables.transitional_cli \
    --spec .[test] {src/,}frontend_editables

Before opening a merge request, install nox and run nox. The type checking step has an external dependency on npm.

Happy hacking!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

frontend-editables-0.1.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

frontend_editables-0.1.0-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file frontend-editables-0.1.0.tar.gz.

File metadata

  • Download URL: frontend-editables-0.1.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.4

File hashes

Hashes for frontend-editables-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ed71d6cdca3cf73886670e53d50f85eb7a6c4d5ad0c4065959155b7c093d5505
MD5 cb8864a1ff0b00a720af3aaaaa9cce2c
BLAKE2b-256 7c79b230f5f08c20802c1e3b31dbefe3a136b3832ee8793ef148a3760a6d260e

See more details on using hashes here.

File details

Details for the file frontend_editables-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: frontend_editables-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.4

File hashes

Hashes for frontend_editables-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 888530a70dd96e89da765a82e8c3d14320f5e871746ea7daedd67df4b448cdae
MD5 a67ed1c05b050ecf9d4cee10a8fc9c2a
BLAKE2b-256 db9e59b35435891098e8cc45e84ac0ba85f7613f1dce0695300c08eec844ceb2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page