code.gitea.io/gitea@v1.22.3/docs/content/usage/packages/pypi.en-us.md (about)

     1  ---
     2  date: "2021-07-20T00:00:00+00:00"
     3  title: "PyPI Package Registry"
     4  slug: "pypi"
     5  sidebar_position: 100
     6  draft: false
     7  toc: false
     8  menu:
     9    sidebar:
    10      parent: "packages"
    11      name: "PyPI"
    12      sidebar_position: 100
    13      identifier: "pypi"
    14  ---
    15  
    16  # PyPI Package Registry
    17  
    18  Publish [PyPI](https://pypi.org/) packages for your user or organization.
    19  
    20  ## Requirements
    21  
    22  To work with the PyPI package registry, you need to use the tools [pip](https://pypi.org/project/pip/) to consume and [twine](https://pypi.org/project/twine/) to publish packages.
    23  
    24  ## Configuring the package registry
    25  
    26  To register the package registry you need to edit your local `~/.pypirc` file. Add
    27  
    28  ```ini
    29  [distutils]
    30  index-servers = gitea
    31  
    32  [gitea]
    33  repository = https://gitea.example.com/api/packages/{owner}/pypi
    34  username = {username}
    35  password = {password}
    36  ```
    37  
    38  | Placeholder  | Description |
    39  | ------------ | ----------- |
    40  | `owner`      | The owner of the package. |
    41  | `username`   | Your Gitea username. |
    42  | `password`   | Your Gitea password. If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password. |
    43  
    44  ## Publish a package
    45  
    46  Publish a package by running the following command:
    47  
    48  ```shell
    49  python3 -m twine upload --repository gitea /path/to/files/*
    50  ```
    51  
    52  The package files have the extensions `.tar.gz` and `.whl`.
    53  
    54  You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first.
    55  
    56  ## Install a package
    57  
    58  To install a PyPI package from the package registry, execute the following command:
    59  
    60  ```shell
    61  pip install --index-url https://{username}:{password}@gitea.example.com/api/packages/{owner}/pypi/simple --no-deps {package_name}
    62  ```
    63  
    64  | Parameter         | Description |
    65  | ----------------- | ----------- |
    66  | `username`        | Your Gitea username. |
    67  | `password`        | Your Gitea password or a personal access token. |
    68  | `owner`           | The owner of the package. |
    69  | `package_name`    | The package name. |
    70  
    71  For example:
    72  
    73  ```shell
    74  pip install --index-url https://testuser:password123@gitea.example.com/api/packages/testuser/pypi/simple --no-deps test_package
    75  ```
    76  
    77  You can use `--extra-index-url` instead of `--index-url` but that makes you vulnerable to dependency confusion attacks because `pip` checks the official PyPi repository for the package before it checks the specified custom repository. Read the `pip` docs for more information.
    78  
    79  ## Supported commands
    80  
    81  ```
    82  pip install
    83  twine upload
    84  ```