Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--script and --lib flags #738

Merged
merged 5 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ that were not yet released.

_Unreleased_

- `init` now supports `--script` and `--lib` to generate a script or library project. #738

- Fixed `rye config --show-path` abort with an error. #706

- Bumped `uv` to 0.1.7. #719, #740
Expand Down
35 changes: 35 additions & 0 deletions docs/guide/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,38 @@ virtualenv is located and more.
```
rye show
```

## Executable projects

To generate a project that is aimed to provide an executable
script, use `rye init --script`:

```shell
rye init --script my-project
cd my-project
```

The following structure will be created:

```
.
├── .git
├── .gitignore
├── .python-version
├── README.md
├── pyproject.toml
└── src
└── my_project
└── __init__.py
└── __main__.py
```

The [`pyproject.toml`](pyproject.md) will be generated with a
[`[project.scripts]`](pyproject.md#projectscripts) section named `hello`
that points to the `main()` function of `__init__.py`. After you
synchronized your changes, you can run the script with `rye run my-project`.

```shell
rye sync
rye run hello
```