From 095b02b983e2dcfb46421e1aa8426b620f6e0c84 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Sun, 14 May 2023 02:15:53 +0200 Subject: [PATCH] More docs --- .python-version | 1 + README.md | 139 ++-------------------------------------- docs/guide/config.md | 2 +- docs/guide/deps.md | 57 ++++++++++++++++ docs/guide/pyproject.md | 2 +- docs/guide/sync.md | 78 ++++++++++++++++++++++ mkdocs.yml | 4 +- 7 files changed, 147 insertions(+), 136 deletions(-) create mode 100644 .python-version create mode 100644 docs/guide/deps.md create mode 100644 docs/guide/sync.md diff --git a/.python-version b/.python-version new file mode 100644 index 0000000000..371cfe355d --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.11.1 diff --git a/README.md b/README.md index cf0115c3bb..0bb20f0b39 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,12 @@ an exploration, and it's far from perfect. Thus also the question:

Click on the thumbnail to watch a 9 minute introduction video

+Learn more: + +* [Documentation](https://mitsuhiko.github.io/rye) +* [Issue Tracker](https://github.com/mitsuhiko/issues) +* [Discussions](https://github.com/mitsuhiko/discussions) + ## Installation Rye is built in Rust. There is no binary distribution yet, it only works on Linux @@ -56,11 +62,6 @@ pick up the right Python without manually activating the virtualenv, you can add of a rye managed project, the regular Python is picked up automatically. For the global tool installation you need to add the shims to the path. -## Deinstallation - -If you no longer want anything to do with rye, all you need to delete is the `~/.rye` -folder. Everything that it has downloaded / created is placed in there. - ## Some of the things it does It automatically installs and manages Python: @@ -123,91 +124,6 @@ To understand why things are the way they are: shims to your shell and you can run `python` and it will automatically always operate in the right project. -## What Could Be? - -There are a few shortcomings in the Python packaging world, largely as a result of -lack of standardization. Here is what this project ran into over the years: - -- **No Python Binary Distributions:** CPython builds from python.org are completely - inadequate. On some platforms you only get an .msi installer, on some you - literally only get tarballs. The various Python distributions that became popular - over the years are diverging greatly and cause all kinds of nonsense downstream. - This is why this Project uses the indygreg standalone builds. I hope that with - time someone will start distributing well maintained and reliable Python builds - to replace the mess we are dealing with today. - -- **No Dev Dependencies:** Rye currently needs a custom section in the `pyproject.toml` - to represent dev dependencies. There is no standard in the ecosystem for this. It - really should be added. - -- **No Local Dependency Overlays:** There is no standard for how to represent local - dependencies. Rust for this purpose has something like `{ path = "../foo" }` - which allows both remote and local references to co-exist and it rewrites them - on publish. - -- **No Exposed Pip:** pip is intentionally not exposed. If you were to install something - into the virtualenv, it disappears next time you sync. If you symlink `rye` to - `~/.rye/shims/pip` you can get access to pip without installing it into the - virtualenv. There be dragons. - -- **No Workspace Spec:** for monorepos and things of that nature, the Python ecosystem - would need a definition of workspaces. Today that does not exist which forces every - tool to come up with it's own solutions to this problem. - -- **No Basic Script Section:** There should be a standard in `pyproject.toml` to - represent scripts like `rye` does in `rye.tools.scripts`. - -## Adding Dependencies - -To add a new dependency run `rye add` with the name of the package that you want to -install. Additionally a proprietary extension to `pyproject.toml` exists to add -development only packages. For those add `--dev`. - -```shell -$ rye add "flask>=2.0" -$ rye add --dev black -``` - -Adding dependencies will not directly install them. To install them run `rye sync` again. - -## Workspaces - -To have multiple projects share the same virtualenv, it's possible to declare workspaces -in the `pyproject.toml`: - -```toml -[tool.rye.workspace] -members = ["foo-*"] -``` - -When `rye sync` is run in a workspace, then all packages are installed at all times. This -also means that they can inter-depend as they will all be installed editable by default. - -## Lockfiles - -Rye does not try to re-invent the world (yet!). This means it uses `pip-tools` behind -the scenes automatically. As neither `pip` nor `pip-tools` provide lockfiles today -Rye uses generated `requirements.txt` files as replacement. Whenever you run -`rye sync` it updates the `requirements.lock` and `requirements-dev.lock` files -automatically. - -## Scripts - -`rye run` can be used to invoke a binary from the virtualenv or a configured script. -Rye allows you to define basic scripts in the `pyproject.toml` in the `tool.rye.scripts` -section: - -```toml -[tool.rye.scripts] -serve = "python -m http.server 8000" -``` - -They are only available via `rye run `. Each script can either be a string or an -array where each item is an argument to the script. The scripts will be run with the -virtualenv activated. - -To see what's available, run `rye run` without arguments and it will list all scripts. - ## Python Distributions Rye does not use system python installations. Instead it uses Gregory Szorc's standalone @@ -216,23 +132,6 @@ This is done to create a unified experience of Python installations and to avoid incompatibilities created by different Python distributions. Most importantly this also means you never need to compile a Python any more, it just downloads prepared binaries. -## Managing Python Toolchains - -You can register custom Python toolchains with `rye toolchain register`: - -``` -$ rye toolchain register ~/Downloads/pypy3.9-v7.3.11-macos_arm64/bin/python -Registered /Users/mitsuhiko/Downloads/pypy3.9-v7.3.11-macos_arm64/bin/python as pypy@3.9.16 -``` - -Afterwards you can pin it, in this case with `rye pin pypy@3.9.16`. The auto detection of -the name might not be great, in which case you can provide an explicit name with `--name`. -To remove downloaded or linked toolchains, you can use the `rye toolchain remove` command. -To list what's available, use `rye toolchain list`. - -Additionally, you can view the list of downloadable Python toolchains with the command -`rye toolchain list --include-downloadable`. - ## Global Tools If you want tools to be installed into isolated virtualenvs (like pipsi and pipx), you @@ -254,30 +153,4 @@ $ pycowsay Wow To uninstall run `rye uninstall pycowsay` again. -## Using The Virtualenv - -There are two ways to use the virtual environment. One is to just activate it like you -would do normally: - -```shell -$ . .venv/bin/activate -``` - -The other is to use `rye run