Skip to content

Commit

Permalink
Switch to hatch package manager (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
tr11 authored Feb 19, 2024
1 parent 7a5e329 commit 2a226d5
Show file tree
Hide file tree
Showing 20 changed files with 188 additions and 114 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Publish to PyPI

on:
release:
types:
- published

permissions:
contents: read

env:
PYTHON_VERSION: 3.11

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install hatch
run: |
python -m pip install hatch
- name: Build package
run: hatch build

- name: Publish
run: hatch build
env:
HATCH_INDEX_USER: ${{ vars.HATCH_INDEX_USER }}
HATCH_INDEX_AUTH: ${{ secrets.HATCH_INDEX_AUTH }}
37 changes: 7 additions & 30 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
POETRY_VERSION: 1.7.1

jobs:
testing:
runs-on: ubuntu-latest
Expand All @@ -28,35 +25,15 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Load cached Poetry installation
id: poetry
uses: actions/cache@v3
with:
path: ~/.local
key: poetry-install-${{env.POETRY_VERSION}}-${{ runner.os }}-${{ matrix.python-version }}

- name: Install and configure Poetry
uses: snok/install-poetry@v1
if: steps.poetry.outputs.cache-hit != 'true'
with:
version: ${{env.POETRY_VERSION}}
virtualenvs-create: true
virtualenvs-in-project: false

- name: Cache Poetry cache
uses: actions/cache@v3
id: cache
with:
path: ~/.cache/pypoetry
key: poetry-cache-${{env.POETRY_VERSION}}-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }}

- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: poetry install -v --all-extras

- name: Install hatch
run: |
python -m pip install hatch
- name: Run pytest
run: poetry run pytest --cov=./ --cov-report=xml
run: |
hatch build --hooks-only
hatch run +py=${{ matrix.python-version }} testing:test --cov=./ --cov-report=xml
- name: Coverage report
uses: codecov/codecov-action@v1
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ cover
.mypy_cache
.idea
.vscode
poetry.lock
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

- Use the standard lib for `toml` in Python >= 3.11
- Switched to `hatch` instead of `poetry`

## [0.9.1] - 2023-08-06

Expand Down
21 changes: 15 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing to python-configuration

:+1::tada: First off, thanks for taking the time to contribute! :tada::+1:
First off, thanks for taking the time to contribute!

## Setting up a dev environment

Expand All @@ -12,14 +12,23 @@
cd python-configuration
```

1. Use [`poetry`](https://python-poetry.org/docs/) to install the dependencies:
1. Use [`hatch`](https://hatch.pypa.io/) to generate a version file and install the dependencies

```shell
poetry install
```
```shell
hatch build --hooks-only # generate a version file from the git commit
# or
hatch build
```

### Running the tests

To run the tests (which include linting and type checks), run:
```shell
hatch run test:test
```

Before opening a PR, make sure to run
```shell
poetry run pytest
hatch run testing:test
```
which executes the previous test command on all Python versions supported by the library.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019 Tiago Requeijo
Copyright (c) 2024 Tiago Requeijo

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
30 changes: 16 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# python-configuration
> A library to load configuration parameters hierarchically from multiple sources and formats
[![Hatch project](https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg)](https://github.com/pypa/hatch)
[![version](https://img.shields.io/pypi/v/python-configuration)](https://pypi.org/project/python-configuration/)
![python](https://img.shields.io/pypi/pyversions/python-configuration)
![wheel](https://img.shields.io/pypi/wheel/python-configuration)
Expand All @@ -15,20 +16,20 @@ This library is intended as a helper mechanism to load configuration files hiera

The `python-configuration` library supports the following configuration formats and sources:

- Python files: ...
- Dictionaries: ...
- Environment variables: ...
- Filesystem paths: ...
- JSON files: ...
- INI files: ...
- dotenv type files: ...
- Python files
- Dictionaries
- Environment variables
- Filesystem paths
- JSON files
- INI files
- dotenv type files
- Optional support for:
- YAML files: requires `yaml`
- TOML files: requires `toml`
- Azure Key Vault credentials: ...
- AWS Secrets Manager credentials: ...
- GCP Secret Manager credentials: ...
- Hashicorp Vault credentials: ...
- TOML files: requires `tomli` for Python < 3.11
- Azure Key Vault credentials: requires `azure-keyvault`
- AWS Secrets Manager credentials: requires `boto3`
- GCP Secret Manager credentials: requires `google-cloud-secret-manager`
- Hashicorp Vault credentials: requires `hvac`


## Installing
Expand All @@ -45,8 +46,9 @@ To include the optional TOML and/or YAML loaders, install the optional dependenc
pip install python-configuration[toml,yaml]
```

Without the optional dependencies, the TOML and YAML loaders will not be available,
Without the optional dependencies, the TOML (Python < 3.11) and YAML loaders will not be available,
and attempting to use them will raise an exception.

## Getting started

`python-configuration` converts the various config types into dictionaries with dotted-based keys. For example, given this JSON configuration
Expand Down Expand Up @@ -381,7 +383,7 @@ The `config.contrib` package contains extra implementations of the `Configuratio
* Ability to override with environment variables
* Merge parameters from different configuration types

## Contributing :tada:
## Contributing

If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are welcome.

Expand Down
Loading

0 comments on commit 2a226d5

Please sign in to comment.