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

add pypi package #495

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/reference/registry-config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ packages:
- [github_release](github-release-package.md): The package is downloaded from GitHub Releases
- [go_install](go-install-package.md): The package is installed by `go install` command. `aqua >= v1.10.0`
- [http](http-package.md): The package is downloaded from the specified URL
- [pypi](pypi-package.md): The package is installed [pip install](https://pip.pypa.io/en/stable/cli/pip_install/) command

## Common attributes

Expand Down
118 changes: 118 additions & 0 deletions docs/reference/registry-config/pypi-package.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
---
sidebar_position: 1320
---

# `pypi` Package

[#2128](https://github.com/aquaproj/aqua/issues/2128) [#2142](https://github.com/aquaproj/aqua/issues/2142) `aqua >= v2.11.0`

The package is installed by [pip install](https://pip.pypa.io/en/stable/cli/pip_install/) command.

## Requirements

Please install these tools in advance.

- Python https://www.python.org/
- pip: https://pip.pypa.io/en/stable/installation/

This feature depends on versions of Python and pip.
We verified this feature with the following versions.

- Python 3.10.5
- pip 22.2

```console
$ python --version
$ python -m pip --version
```

## Get Started

Let's install [pre-commit](https://pre-commit.com/) by aqua.

```sh
aqua init
```

```sh
aqua g -i pypi.org/pre-commit
```

You can also select the version by `-s` option.

```sh
aqua g -i -s pypi.org/pre-commit
```

```sh
aqua i -l
aqua which pre-commit
pre-commit --version
```

## aqua-renovate-config

From 1.8.0, [aqua-renovate-config](/docs/products/aqua-renovate-config) supports `pypi` packages.

:::caution
Package names must be `pypi.org/<pypi package name>`.

e.g. `pypi.org/pre-commit`.
:::


## How to add new pypi packages to Standard Registry

Please send a pull request to https://github.com/aquaproj/aqua-registry .
Package names must be `pypi.org/<pypi package name>`.

e.g. `pypi.org/pre-commit`.

## How does it work?

:::caution
This includes details of the internal implementation, which may be changed without notice.
Please skip this section if you're not interested in the detail. You can use pypi packages even if you don't know this.
:::

`pypi` packages are installed in `<AQUA_ROOT_DIR>/pkgs/pip/pypi.org/<pypi package name>/<version>`,
and executable files are installed in `<AQUA_ROOT_DIR>/pkgs/pip/pypi.org/<pypi package name>/<version>/bin/<command>`.

aqua internally runs `python -m pip install` commands.

```sh
python -m pip install --target "<AQUA_ROOT_DIR>/pkgs/pip/pypi.org/<pypi package name>/<version>" "<pypi package>==<version>"
```

aqua adds `<AQUA_ROOT_DIR>/pkgs/pip/pypi.org/<pypi package name>/<version>` to the environment variable [PYTHONPATH](https://docs.python.org/3/using/cmdline.html#envvar-PYTHONPATH) when pypi packages are executed.

`aqua g -s` gets the list of pypi package versions from the endpoint `https://pypi.org/pypi/<pypi package name>/json`.

## Registry

e.g.

```yaml
packages:
- type: pypi
pypi_name: pre-commit
```

`type` must be `pypi`. `pypi_name` is required. Other fields are optional.
The above setting is equivalent to the following setting.

```yaml
packages:
- name: pypi.org/pre-commit
type: pypi
pypi_name: pre-commit
files:
- name: pre-commit
```

`pypi` packages don't support the following fields.

- format, format_overrides
- checksum
- slsa_provenance
- cosign
2 changes: 1 addition & 1 deletion docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const config = {
announcementBar: {
id: 'cargo_package',
content:
'<a href="/docs/reference/registry-config/cargo-package">aqua v2.8.0 supports installing packages by cargo install (2023-05-21)</a>',
'<a href="/docs/reference/registry-config/pypi-package">aqua v2.11.0 supports installing packages by pip install (2023-07-30)</a>',
backgroundColor: '#7FFF00',
textColor: '#091E42',
isCloseable: true,
Expand Down