Metadata-Version: 2.4
Name: pload
Version: 1.2.0b1
Summary: A small, relocatable Python virtual environment manager
Author-email: Yunming Hu <hugonelsonm3@gmail.com>
License:                                  Apache License
                                   Version 2.0, January 2004
                                http://www.apache.org/licenses/
        
           TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
        
           1. Definitions.
        
              "License" shall mean the terms and conditions for use, reproduction,
              and distribution as defined by Sections 1 through 9 of this document.
        
              "Licensor" shall mean the copyright owner or entity authorized by
              the copyright owner that is granting the License.
        
              "Legal Entity" shall mean the union of the acting entity and all
              other entities that control, are controlled by, or are under common
              control with that entity. For the purposes of this definition,
              "control" means (i) the power, direct or indirect, to cause the
              direction or management of such entity, whether by contract or
              otherwise, or (ii) ownership of fifty percent (50%) or more of the
              outstanding shares, or (iii) beneficial ownership of such entity.
        
              "You" (or "Your") shall mean an individual or Legal Entity
              exercising permissions granted by this License.
        
              "Source" form shall mean the preferred form for making modifications,
              including but not limited to software source code, documentation
              source, and configuration files.
        
              "Object" form shall mean any form resulting from mechanical
              transformation or translation of a Source form, including but
              not limited to compiled object code, generated documentation,
              and conversions to other media types.
        
              "Work" shall mean the work of authorship, whether in Source or
              Object form, made available under the License, as indicated by a
              copyright notice that is included in or attached to the work
              (an example is provided in the Appendix below).
        
              "Derivative Works" shall mean any work, whether in Source or Object
              form, that is based on (or derived from) the Work and for which the
              editorial revisions, annotations, elaborations, or other modifications
              represent, as a whole, an original work of authorship. For the purposes
              of this License, Derivative Works shall not include works that remain
              separable from, or merely link (or bind by name) to the interfaces of,
              the Work and Derivative Works thereof.
        
              "Contribution" shall mean any work of authorship, including
              the original version of the Work and any modifications or additions
              to that Work or Derivative Works thereof, that is intentionally
              submitted to Licensor for inclusion in the Work by the copyright owner
              or by an individual or Legal Entity authorized to submit on behalf of
              the copyright owner. For the purposes of this definition, "submitted"
              means any form of electronic, verbal, or written communication sent
              to the Licensor or its representatives, including but not limited to
              communication on electronic mailing lists, source code control systems,
              and issue tracking systems that are managed by, or on behalf of, the
              Licensor for the purpose of discussing and improving the Work, but
              excluding communication that is conspicuously marked or otherwise
              designated in writing by the copyright owner as "Not a Contribution."
        
              "Contributor" shall mean Licensor and any individual or Legal Entity
              on behalf of whom a Contribution has been received by Licensor and
              subsequently incorporated within the Work.
        
           2. Grant of Copyright License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              copyright license to reproduce, prepare Derivative Works of,
              publicly display, publicly perform, sublicense, and distribute the
              Work and such Derivative Works in Source or Object form.
        
           3. Grant of Patent License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              (except as stated in this section) patent license to make, have made,
              use, offer to sell, sell, import, and otherwise transfer the Work,
              where such license applies only to those patent claims licensable
              by such Contributor that are necessarily infringed by their
              Contribution(s) alone or by combination of their Contribution(s)
              with the Work to which such Contribution(s) was submitted. If You
              institute patent litigation against any entity (including a
              cross-claim or counterclaim in a lawsuit) alleging that the Work
              or a Contribution incorporated within the Work constitutes direct
              or contributory patent infringement, then any patent licenses
              granted to You under this License for that Work shall terminate
              as of the date such litigation is filed.
        
           4. Redistribution. You may reproduce and distribute copies of the
              Work or Derivative Works thereof in any medium, with or without
              modifications, and in Source or Object form, provided that You
              meet the following conditions:
        
              (a) You must give any other recipients of the Work or
                  Derivative Works a copy of this License; and
        
              (b) You must cause any modified files to carry prominent notices
                  stating that You changed the files; and
        
              (c) You must retain, in the Source form of any Derivative Works
                  that You distribute, all copyright, patent, trademark, and
                  attribution notices from the Source form of the Work,
                  excluding those notices that do not pertain to any part of
                  the Derivative Works; and
        
              (d) If the Work includes a "NOTICE" text file as part of its
                  distribution, then any Derivative Works that You distribute must
                  include a readable copy of the attribution notices contained
                  within such NOTICE file, excluding those notices that do not
                  pertain to any part of the Derivative Works, in at least one
                  of the following places: within a NOTICE text file distributed
                  as part of the Derivative Works; within the Source form or
                  documentation, if provided along with the Derivative Works; or,
                  within a display generated by the Derivative Works, if and
                  wherever such third-party notices normally appear. The contents
                  of the NOTICE file are for informational purposes only and
                  do not modify the License. You may add Your own attribution
                  notices within Derivative Works that You distribute, alongside
                  or as an addendum to the NOTICE text from the Work, provided
                  that such additional attribution notices cannot be construed
                  as modifying the License.
        
              You may add Your own copyright statement to Your modifications and
              may provide additional or different license terms and conditions
              for use, reproduction, or distribution of Your modifications, or
              for any such Derivative Works as a whole, provided Your use,
              reproduction, and distribution of the Work otherwise complies with
              the conditions stated in this License.
        
           5. Submission of Contributions. Unless You explicitly state otherwise,
              any Contribution intentionally submitted for inclusion in the Work
              by You to the Licensor shall be under the terms and conditions of
              this License, without any additional terms or conditions.
              Notwithstanding the above, nothing herein shall supersede or modify
              the terms of any separate license agreement you may have executed
              with Licensor regarding such Contributions.
        
           6. Trademarks. This License does not grant permission to use the trade
              names, trademarks, service marks, or product names of the Licensor,
              except as required for reasonable and customary use in describing the
              origin of the Work and reproducing the content of the NOTICE file.
        
           7. Disclaimer of Warranty. Unless required by applicable law or
              agreed to in writing, Licensor provides the Work (and each
              Contributor provides its Contributions) on an "AS IS" BASIS,
              WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
              implied, including, without limitation, any warranties or conditions
              of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
              PARTICULAR PURPOSE. You are solely responsible for determining the
              appropriateness of using or redistributing the Work and assume any
              risks associated with Your exercise of permissions under this License.
        
           8. Limitation of Liability. In no event and under no legal theory,
              whether in tort (including negligence), contract, or otherwise,
              unless required by applicable law (such as deliberate and grossly
              negligent acts) or agreed to in writing, shall any Contributor be
              liable to You for damages, including any direct, indirect, special,
              incidental, or consequential damages of any character arising as a
              result of this License or out of the use or inability to use the
              Work (including but not limited to damages for loss of goodwill,
              work stoppage, computer failure or malfunction, or any and all
              other commercial damages or losses), even if such Contributor
              has been advised of the possibility of such damages.
        
           9. Accepting Warranty or Additional Liability. While redistributing
              the Work or Derivative Works thereof, You may choose to offer,
              and charge a fee for, acceptance of support, warranty, indemnity,
              or other liability obligations and/or rights consistent with this
              License. However, in accepting such obligations, You may act only
              on Your own behalf and on Your sole responsibility, not on behalf
              of any other Contributor, and only if You agree to indemnify,
              defend, and hold each Contributor harmless for any liability
              incurred by, or claims asserted against, such Contributor by reason
              of your accepting any such warranty or additional liability.
        
           END OF TERMS AND CONDITIONS
        
           APPENDIX: How to apply the Apache License to your work.
        
              To apply the Apache License to your work, attach the following
              boilerplate notice, with the fields enclosed by brackets "[]"
              replaced with your own identifying information. (Don't include
              the brackets!)  The text should be enclosed in the appropriate
              comment syntax for the file format. We also recommend that a
              file or class name and description of purpose be included on the
              same "printed page" as the copyright notice for easier
              identification within third-party archives.
        
           Copyright [yyyy] [name of copyright owner]
        
           Licensed under the Apache License, Version 2.0 (the "License");
           you may not use this file except in compliance with the License.
           You may obtain a copy of the License at
        
               http://www.apache.org/licenses/LICENSE-2.0
        
           Unless required by applicable law or agreed to in writing, software
           distributed under the License is distributed on an "AS IS" BASIS,
           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
           See the License for the specific language governing permissions and
           limitations under the License.
        
Project-URL: Homepage, https://github.com/HugoPhi/pload
Project-URL: Issues, https://github.com/HugoPhi/pload/issues
Keywords: python,venv,virtual-environment,pyenv
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: packaging<27,>=23.2
Requires-Dist: questionary<3,>=2.0.1
Requires-Dist: rich<15,>=13.7
Requires-Dist: resolvelib<1.2,>=1.1
Requires-Dist: tomli>=2; python_version < "3.11"
Provides-Extra: test
Requires-Dist: pytest>=7; extra == "test"
Requires-Dist: ruff>=0.9; extra == "test"
Dynamic: license-file

# pload

![pload welcome screen on macOS](docs/images/pload-welcome-macos.png)

`pload` is a relocatable Python runtime and virtual-environment manager for
Bash, Zsh, Fish, and PowerShell. Its private runtime, downloaded Python
versions, virtual environments, registry, and caches can all live under
directories you choose. pyenv is supported for discovery, but is not required.

Running `pload` without arguments opens a small welcome screen. Use `-h` for a
complete parameter reference and `-h -d` for practical examples and effects.

## Contents

- [Install](#install)
- [Reproduce and share environments](#reproduce-and-share-environments)
- [Upgrade](#upgrade)
- [First run](#first-run)
- [Configure later](#configure-later)
- [Shell activation](#shell-activation)
- [Discover and install Python](#discover-and-install-python)
- [Create and activate environments](#create-and-activate-environments)
- [Help and aliases](#help-and-aliases)
- [Terminal experience](#terminal-experience)
- [Isolation and directory layout](#isolation-and-directory-layout)
- [Command reference](#command-reference)
- [Development](#development)
- [License](#license)

## Install

Install the small bootstrap package, then start the guided installer:

```console
python -m pip install --user --upgrade pload
python -m pload.installer
```

If your distribution enforces PEP 668, use pipx or a dedicated bootstrap
virtual environment:

```console
python3 -m venv ~/.pload-bootstrap
~/.pload-bootstrap/bin/python -m pip install --upgrade pload
~/.pload-bootstrap/bin/python -m pload.installer
```

On Windows, replace `python` with `py` when appropriate. If pipx is already
available:

```console
pipx install pload
pload-install
```

The installer uses consistent cursor-key choices for the pload data directory,
launcher directory, virtual-environment directory, Python directory, runtime
source, pip index, and optional shell integration. Use `↑`/`↓` to move and
Enter to accept the highlighted value. Without a terminal UI, the same prompts
fall back to numbered choices.

After installation it prints an ASCII welcome screen with copyable next steps.
The same screen is shown whenever you run bare `pload` (see the screenshot at
the top of this page).

For a non-interactive setup:

```console
python -m pload.installer --yes \
  --home /mnt/tools/pload \
  --bin-dir ~/.local/bin \
  --venvs-dir /mnt/venvs \
  --python-dir /mnt/python \
  --source ustc \
  --pip-source tsinghua
```

`--yes` accepts explicit values and saved defaults. It only changes a shell
profile when `--shell` is supplied or already configured.

## Reproduce and share environments

The `1.2` preview uses one clean, user-authored `pload.toml` as portable intent.
pload manages `.pload_lock.toml` (exact versions and artifacts) and
`.pload_plan.toml` (the selected acquisition route for every package):

```console
pload describe v2 -o pload.toml
pload plan pload.toml
pload apply pload.toml
pload apply --local         # reproduce into .venv beside pload.toml
```

`plan` fetches only index pages and independent package metadata—never wheel
bodies—and inventories pload/pip/uv caches, compatible existing environments,
local/SSH stores and indexes. Its interactive chooser shows only dependencies
written by the user; transitive dependencies are routed automatically. It
supports previous/next, undo, reset, save and save-and-apply through a
compact shortcut row (`p/n/u/r/s/a/q`); the selection list itself contains only
real package sources. `apply` executes exactly the saved plan:
it never re-resolves, changes route, falls back, or uploads packages. Set
`[plan].mode = "auto"` in `pload.toml` to save recommended routes without the
chooser; strict per-package exceptions live under `[plan.packages.NAME]`.
`apply` prints the saved plan first, then compact Docker-style progress rows.
Each package is prefixed by its route, such as `[cache]`, `[index-exact]`, or
`[repository]`, followed only by its byte progress. Verbose grey source/status
suffixes are intentionally omitted because the saved plan above already names
the selected resource. The bar
uses Rich's standard adaptive-width bar with explicit start and end boundaries,
so it grows naturally on wider terminals without another progress dependency.
Index and repository transfers report real received bytes at up to 30 updates
per second. SSH repository downloads stream the remote object directly;
cache routes report bytes while verifying SHA-256 instead of turning green
before visible work. Environment-copy routes validate the source `RECORD`, then
immediately stage each byte from the compatible environment and finish green
before pload advances to the next package. The staged files are installed after
the target environment exists.
Redirected logs remain coalesced instead of flooding CI.

Use `pload apply --local` (or `-l`) for a project-local environment. It creates
`.venv` beside the selected `pload.toml`, matching the layout produced by
`pload init` while executing the saved declarative plan exactly.

Back up a special or slow wheel only when you explicitly request it:

```console
pload remote add torch --from v10 --remote lab
```

See the [declarative environment guide](docs/declarative-environments.md) for the
[complete TOML field reference](docs/declarative-environments.md#complete-ploadtoml-field-reference),
exact versus compatible policies, resource-selection algorithm, CUDA wheel
caching, idempotency and current platform boundaries.

## Upgrade

Check the installed version first:

```console
pload --version
```

For an installation managed by `pload-install`, upgrade the private runtime
in place. Your configured directories, registry, downloaded Python runtimes,
and virtual environments are kept:

```console
pload-install --yes --package-spec "pload==1.0.0"
```

To opt into the declarative-environment pre-release for testing:

```console
pload-install --yes --package-spec "pload==1.2.0b1"
```

To always follow the newest published release instead of pinning a version,
omit the version constraint:

```console
pload-install --yes --package-spec pload
```

If your selected mirror has not synchronized the release yet, choose the
official index for this run (or replace it with another configured index):

```console
pload-install --yes --package-spec "pload==1.0.0" --pip-index https://pypi.org/simple
```

For pipx installations use pipx's own upgrade command:

```console
pipx upgrade pload
```

For a dedicated bootstrap virtual environment, run pip through that same
interpreter:

```console
~/.pload-bootstrap/bin/python -m pip install --upgrade pload
```

Verify the result and refresh shell integration if the current shell still
has an older function loaded:

```console
pload --version
pload cfg
eval "$(pload shell-init zsh)"   # use bash/fish/powershell as appropriate
```

On systems enforcing PEP 668, do not force-install into the system Python;
use pipx or the dedicated bootstrap environment shown above.

## First run

```console
pload
```

The no-argument screen gives the shortest useful tour:

```console
pload cfg                         # show effective paths and sources
pload python list                 # discover usable Python interpreters
pload new -n data -v 3.12         # create an environment
pload list                        # list IDs, descriptions, and paths
pload v1                          # activate an environment by ID
```

Run `pload new` without options to start the guided creator. It lists detected
Python runtimes, then asks for the interpreter, environment name, description,
and optional packages. When packages are present, choose **Automatic** to let
pload prefer a compatible local wheel cache and otherwise use the configured
index, or **Custom** to choose the source of each top-level package yourself.
Press Enter to accept the suggested value at each step.

## Configure later

Inspect the effective configuration:

```console
pload cfg
pload config show
```

Change one value without reinstalling pload or uv:

```console
pload cfg set source ustc
pload cfg set pip-source tsinghua
pload cfg set venvs-dir ~/venvs
pload cfg set python-dir ~/.pload/pythons
pload cfg set shell zsh
```

Reopen the complete setup wizard at any time:

```console
pload cfg -t
```

The wizard reuses current values as defaults and updates configuration plus the
selected shell profile. It does not reinstall pload, uv, or existing
environments. Configuration is stored in `PLOAD_HOME/config.json`.

## Shell activation

The installer can update a shell profile. To configure it manually:

```bash
# Bash
eval "$(pload shell-init bash)"

# Zsh
eval "$(pload shell-init zsh)"

# Fish
pload shell-init fish | source
```

PowerShell:

```powershell
Invoke-Expression (& pload shell-init powershell | Out-String)
```

Then `pload v1`, `pload data`, and `pload .` can activate environments in the
current shell.

## Discover and install Python

`pload python list` scans usable interpreters from the operating system, PATH,
uv, pyenv, Conda, mise, asdf, Homebrew, and the Windows Python Launcher.
Duplicate executable paths are collapsed:

```console
pload python list
pload python list --filter uv,conda
pload python list --filter uv conda
pload python path 3.12
```

Each distinct executable receives a stable Python ID and readable alias:

```text
ID   ALIAS          VERSION  TYPE    PATH
py1  uv-v3.12.8     3.12.8   uv      ~/.pload/pythons/.../python3.12
py2  conda-v3.11.9  3.11.9   conda   ~/miniforge3/envs/data/bin/python
```

The ID and alias are separate columns in the real output:

![Python runtime discovery on macOS](docs/images/pload-python-list-macos.png)

Use any of these forms when selecting an interpreter:

```console
pload new -n data --version py1
pload new -n data --version uv-v3.12.8
pload new -n data --version py1:uv-v3.12.8
pload python path py1
```

Types include `sys`, `pyenv`, `uv`, `conda`, `mise`, `asdf`, `homebrew`, and
`other`. Compatibility names `system` and `managed` map to `sys` and `uv`.

Install a managed Python without pyenv:

```console
pload python install 3.12
pload python install 3.13.3
```

Managed runtimes are stored under the configured Python directory and do not
replace `/usr/bin/python`, Homebrew, pyenv, or Conda installations.

Runtime downloads and Python package downloads are configured separately:

- runtime source: `official`, `ustc`, or `custom`;
- pip source: `official`, `tsinghua`, `ustc`, `aliyun`, or `custom`.

The runtime source controls uv's `python-build-standalone` archives. A normal
PyPI mirror does not host those archives.

## Create and activate environments

Create a named environment with a description:

```console
pload new                     # guided creation
pload new -n data -v 3.12 -m "Data analysis"
pload new -n web -v 3.12 -r fastapi uvicorn -m "Web API"
pload new -n lab -r numpy torch -s custom  # choose each top-level package source
pload new -v 3.12 --message "Temporary data tools"  # auto-named safely
pload list
pload v1
```

Create a project-local environment:

```console
pload init -m "Current project"
pload .
pload init -r pytest requests
```

Use an explicit interpreter or destination when needed:

```console
pload new -p /mnt/venvs/build -v /opt/python/bin/python
pload init -P /mnt/projects/app -e /mnt/venvs/app
```

Every managed environment receives an ID such as `v1`, `v2`, or `v3`, plus a
description and creation timestamp. Deleted IDs are reused from the first
available number. `pload list` displays environments newest-first:

![Environment list on macOS](docs/images/pload-list-macos.png)

The table includes ID, name, Python version, description, and full path. A
spinner is shown in interactive terminals; redirected and CI output uses stable
ordinary log lines.

Package requests are installed one at a time. A misspelled, unavailable, or
invalid request is reported and skipped, while later requests still run and
successful installations remain in the environment. The command returns a
failure status at the end when any requested package failed, with one summary
listing those packages. Source selection applies only to packages explicitly
entered by the user; pip continues to resolve their transitive dependencies.

## Help and aliases

Brief help is a complete reference. It starts with an emphasized `USAGE` panel,
then lists every positional argument, long option, short alias, and description:

```console
pload config -h
pload cfg -h
pload new -h
pload py install -h
pload py ls -h
pload-install -h
```

The root help keeps global storage options together, while command-specific
help shows only that command's arguments:

![Root help on macOS](docs/images/pload-help-macos.png)

Detailed help adds examples, expected output, disk effects, and failure behavior:

```console
pload -h -d
pload new -h -d
pload cfg -h -d
pload py ls -h -d
pload-install -h -d
```

Command aliases:

| Command | Alias |
| --- | --- |
| `new` | none; already short and explicit |
| `init` | `i` |
| `list` | `ls` |
| `rm` | `remove`, `del`, `delete` |
| `python` | `py` |
| `path` | `p` |
| `config` | `cfg` |
| `shell-init` | `shell` |

Python subcommands use `ls` and `p`; the explicit `install` command has no alias:

```console
pload py ls --filter uv,conda
pload python install 3.12
pload py p 3.12
```

## Terminal experience

All interactive screens share the same keyboard and visual language. Use
`↑`/`↓` and Enter in guided creation, setup, and package-route selection;
recommended values start highlighted. Status, success, warning, and error
messages use the same symbols and colors everywhere, while compact border-light
tables keep lists readable.

`NO_COLOR=1` disables color. `PLOAD_NO_PROGRESS=1` replaces animated progress
with plain status lines. Every guided workflow also has an explicit flag-based
form for scripts. See the [terminal experience specification](docs/terminal-experience.md)
for the complete interaction and output contract.

## Isolation and directory layout

Put all pload-managed data under one root:

```console
export PLOAD_HOME=/mnt/workspace/.pload
pload new -n tools
```

The default layout is:

```text
PLOAD_HOME/
├── config.json       saved choices
├── runtime/          pload and uv private runtime
├── pythons/          downloaded Python runtimes
├── python-bin/       managed Python executable links
├── cache/python/     Python download cache
├── state/            environment IDs and Python runtime IDs
└── venvs/            managed virtual environments
```

Override individual roots with `PLOAD_VENVS_DIR`, `PLOAD_STATE_DIR`, or the
global `--home`, `--venvs-dir`, and `--state-dir` options. Project-local
environments can live elsewhere with `init --project-dir` and `--venv-dir`.

## Command reference

```console
pload new -h -d
pload init -h -d
pload list -h -d
pload rm -h -d
pload path -h -d
pload python -h -d
pload python install -h -d
pload python list -h -d
pload config -h -d
pload-install -h -d
```

Other useful commands:

```console
pload path v1
pload rm v1 --yes
pload rm --expression '^test-' --yes
pload cfg set source ustc
pload cfg -t
```

## Development

```console
python -m pip install -e '.[test]'
pytest
ruff check src tests
```

## License

Apache License 2.0. Copyright 2025 Yunming Hu.
