|
1 | | -# codespaces artifacts helper keyring |
| 1 | +# codespaces_artifacts_helper_keyring |
2 | 2 |
|
3 | | -wow what a long package name. i'm open to suggestions for renaming it. |
| 3 | +The `codespaces_artifacts_helper_keyring` package provides [keyring](https://pypi.org/project/keyring) authentication for consuming Python packages from Azure Artifacts feeds using the [Codespaces Artifacts Helper](https://github.com/microsoft/codespace-features/tree/main/src/artifacts-helper) and its underlying authentication tool, [ado-codespaces-auth](https://github.com/microsoft/ado-codespaces-auth). |
4 | 4 |
|
5 | | -## what is this? |
| 5 | +This package is an extension to [keyring](https://pypi.org/project/keyring), which will automatically find and use it once installed. Both [pip](https://pypi.org/project/pip) and [twine](https://pypi.org/project/twine) will use keyring to find credentials. |
6 | 6 |
|
7 | | -The codespaces artifacts helper keyring is a package that provides a keyring implementation for the codespaces artifacts helper at https://github.com/microsoft/ado-codespaces-auth. When the keyring package and this keyring are both installed, pip will automatically use this keyring to store and retrieve credentials when accessing ADO package feeds. |
| 7 | +## Installation |
8 | 8 |
|
9 | | -## build instructins |
| 9 | +### From Source |
10 | 10 |
|
11 | | -This package uses `pyproject.toml`, and `pdm` for building. To build the package, run the following commands: |
| 11 | +To install this package from source: |
12 | 12 |
|
13 | 13 | ```sh |
14 | | -cd src/artifacts-helper/codespaces_artifacts_helper_keyring |
| 14 | +$ cd src/artifacts-helper/codespaces_artifacts_helper_keyring |
15 | 15 |
|
16 | 16 | # PDM is used to manage the project |
17 | 17 | $ pip install 'pdm>=2.14' |
18 | 18 |
|
19 | 19 | # Install dependencies and build the package |
20 | 20 | $ pdm build |
21 | 21 |
|
22 | | -# Install package + deps with pip |
| 22 | +# Install package and dependencies with pip |
23 | 23 | $ pip install dist/codespaces_artifacts_helper_keyring-*.whl |
24 | 24 | ``` |
25 | 25 |
|
26 | | -## contributing |
| 26 | +### From GitHub Releases |
| 27 | + |
| 28 | +TODO: Write instructions |
| 29 | + |
| 30 | +## Usage |
| 31 | + |
| 32 | +### Requirements |
| 33 | + |
| 34 | +To use `codespaces_artifacts_helper_keyring` to set up authentication between `pip` and Azure Artifacts, the following requirements must be met: |
| 35 | + |
| 36 | +- pip version **19.2** or higher |
| 37 | +- python version **3.8** or higher |
| 38 | +- running inside a Codespace with [Codespaces Artifacts Helper](https://github.com/microsoft/codespace-features/tree/main/src/artifacts-helper) and the `param` option set to `true`. This will automatically install the `codespaces_artifacts_helper_keyring` package for you. |
| 39 | + ```json |
| 40 | + { |
| 41 | + "features": { |
| 42 | + "ghcr.io/microsoft/codespace-features/artifacts-helper:1": { |
| 43 | + // TODO: Add parameter for installing package |
| 44 | + "TODO": true |
| 45 | + } |
| 46 | + } |
| 47 | + } |
| 48 | + ``` |
| 49 | + |
| 50 | +### Inner Workings |
| 51 | + |
| 52 | +The `codespaces_artifacts_helper_keyring` will detect if the package index has a domain that matches Azure Artifacts, e.g. `pkgs.dev.azure.com`. If it does, it will use the `ado-codespaces-auth` tool at `~/ado-auth-helper` to fetch an access token. This token will be used to authenticate with the Azure Artifacts feed. |
| 53 | + |
| 54 | +### Installing Packages from an Azure Artifacts Feed |
| 55 | + |
| 56 | +Once the codespace is ready, to consume a package, use the following `pip` command, replacing **<org_name>** and **<feed_name>** with your own, and **<package_name>** with the package you want to install: |
| 57 | + |
| 58 | +``` |
| 59 | +pip install <package_name> --index-url https://pkgs.dev.azure.com/<org_name>/_packaging/<feed_name>/pypi/simple |
| 60 | +``` |
| 61 | + |
| 62 | +## Contributing |
| 63 | + |
| 64 | +We use [PDM](https://pdm-project.org/) to manage the project and its dependencies. To get started, install PDM: |
27 | 65 |
|
28 | 66 | ```sh |
29 | | -# Lint |
30 | | -$ pdm run check |
| 67 | +$ pip install 'pdm>=2.14' |
| 68 | +``` |
31 | 69 |
|
32 | | -# Format |
33 | | -$ pdm run fmt |
| 70 | +Then, install the project dependencies: |
| 71 | + |
| 72 | +```sh |
| 73 | +$ pdm install |
| 74 | +``` |
| 75 | + |
| 76 | +### Scripts |
| 77 | + |
| 78 | +A set of scripts are in `pyproject.toml` to help with common tasks. These can be run using `pdm <script name> <extra args>`. For example: |
| 79 | + |
| 80 | +```sh |
| 81 | +# Lint and exit with non-zero status if there are issues |
| 82 | +$ pdm lint |
| 83 | + |
| 84 | +# Lint and attempt to fix issues |
| 85 | +$ pdm run lint-fix |
| 86 | + |
| 87 | +# Format and fix issues |
| 88 | +$ pdm run format [target files or directories] |
34 | 89 |
|
35 | 90 | # Type check |
36 | | -$ pdm nox -s mypy |
| 91 | +$ pdm mypy |
37 | 92 |
|
38 | | -# Test on current python version |
39 | | -$ pdm run test |
| 93 | +# Run tests |
| 94 | +$ pdm tests |
40 | 95 |
|
41 | | -# Test on all supported python versions |
| 96 | +# Test on all supported Python versions |
42 | 97 | $ pdm run nox |
43 | 98 | ``` |
| 99 | + |
| 100 | +The scripts are wrappers around [nox](https://github.com/wntrblm/nox) sessions. You can directly run them from nox and use more specific filters. For example, to list the sessions that would run tests on Python 3.11: |
| 101 | + |
| 102 | +```sh |
| 103 | +$ pdm run nox -l -s tests --python '3.11' |
| 104 | + |
| 105 | +* tests(python='3.11', keyring='20') -> Run the test suite. |
| 106 | +* tests(python='3.11', keyring='25.1') -> Run the test suite. |
| 107 | +``` |
| 108 | + |
| 109 | +The underlying [nox](https://github.com/wntrblm/nox) configuration is defined in `noxfile.py`. You can modify this file to add new test environments or change the behavior of existing ones. Any tests with the `"ci"` tag will be run in the CI pipeline. |
0 commit comments