Metadata-Version: 2.4
Name: deport
Version: 0.1.0
Summary: The opposite of import
Project-URL: Homepage, https://github.com/broyojo/deport
Project-URL: Repository, https://github.com/broyojo/deport
Author: broyojo
License-Expression: MIT
License-File: LICENSE
Keywords: deport,import,module,unload
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.12
Description-Content-Type: text/markdown

# deport

The opposite of `import`.

```
pip install deport
```

## Usage

```python
import os
import json

deport os, json
# os and json are now completely unloaded from sys.modules and deleted from scope

import os  # re-importing works — loads the module fresh
```

That's it. No special imports, no decorators, no configuration. Just `pip install deport` and the `deport` statement is available in all your Python files.

## What it does

`deport` completely reverses an import:

1. Removes the module (and all submodules) from `sys.modules`
2. Deletes the name from the current scope

This means re-importing after a `deport` will reload the module from scratch, rather than returning the cached version.

## How it works

When you `pip install deport`, a `.pth` file is installed into `site-packages` that activates the `deport` machinery at Python startup. It uses three mechanisms:

- **Import hook**: transparently preprocesses imported `.py` files, rewriting `deport X` into valid Python before compilation
- **Excepthook**: catches `SyntaxError` in the main script, preprocesses the source, and re-executes it
- **Custom codec**: files with `# coding: deport` are preprocessed at decode time

## Syntax

```python
deport os           # single module
deport os, json     # multiple modules
deport os.path      # submodule (also removes os from scope)
```

## Why

Why not?
