Skip to main content

Editable installations

Project description

A Python library for creating "editable wheels"

This library supports the building of wheels which, when installed, will expose packages in a local directory on sys.path in "editable mode". In other words, changes to the package source will be reflected in the package visible to Python, without needing a reinstall.

Usage

Suppose you want to build a wheel for your project foo. Your project is located in the directory /path/to/foo. Under that directory, you have a src directory containing your project, which is a package called foo and a Python module called bar.py. So your directory structure looks like this:

/path/to/foo
|
+-- src
|   +-- foo
|   |   +-- __init__.py
|   +-- bar.py
|
+-- setup.py
+-- other files

Build your wheel as follows:

from editables import EditableProject

my_project = EditableProject("foo", "/path/to/foo")
my_project.map("foo", "src/foo")
my_project.map("bar", "src/bar.py")

# Build a wheel however you prefer...
wheel = BuildAWheel()

# Add files to the wheel
for name, content in my_project.files():
    wheel.add_file(name, content)

# Add any runtime dependencies to the wheel
for dep in my_project.dependencies():
    wheel.metadata.dependencies.add(dep)

The resulting wheel will, when installed, put packages foo and bar on sys.path so that editing the original source will take effect without needing a reinstall (i.e., as "editable" packages).

Exposing individual packages like this requires an import hook, which is itself provided by the editables package. That's why you need to add a (runtime) dependency to the wheel metadata, so that the installer will install the hook code as well. The dependencies are provided via an API call so that if, at some future point, the hook code gets moved to its own project, callers will not need to change.

If you don't need to expose individual packages like this, but are happy to put the whole of the src directory onto sys.path, you can do this using my_project.add_to_path("src"). If you only use add_to_path, and not map, then no runtime dependency will be required (although you should not rely on this, you should still call dependencies to allow for future changes in implementation).

Using add_to_path is the only reliable way of supporting implicit namespace packages - the mechanism used in map does not handle them correctly.

Note that this project doesn't build wheels directly. That's the responsibility of the calling code.

Python Compatibility

This project supports the same versions of Python as pip does. Currently that is Python 3.6 and later, and PyPy3 (although we don't test against PyPy).

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

editables-0.2.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

editables-0.2-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file editables-0.2.tar.gz.

File metadata

  • Download URL: editables-0.2.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for editables-0.2.tar.gz
Algorithm Hash digest
SHA256 6918f16225258f24ef9800c2327e14eded42ddac344e77982380749464024f35
MD5 691357f5f0dec3df91790a2150fc367e
BLAKE2b-256 e4b84cbc098360011c019ded1b66bcf7ab777cfbce457d5f637b7880d13768ac

See more details on using hashes here.

File details

Details for the file editables-0.2-py3-none-any.whl.

File metadata

  • Download URL: editables-0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for editables-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fe9afdc51df78ac3b20a2c2dd763b36ac412a70c59ca39fc782d45797dcb619a
MD5 863227dadd3c0b67012174af0dad151a
BLAKE2b-256 025aafc6eed6d30a100c3350dde1d78529ee4432b954816783cfc5dede3f0f12

See more details on using hashes here.

Supported by

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