Skip to content

Commit 2a226d5

Browse files
authored
Switch to hatch package manager (#92)
1 parent 7a5e329 commit 2a226d5

File tree

20 files changed

+188
-114
lines changed

20 files changed

+188
-114
lines changed

.github/workflows/publish.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
permissions:
9+
contents: read
10+
11+
env:
12+
PYTHON_VERSION: 3.11
13+
14+
jobs:
15+
deploy:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v3
21+
22+
- name: Set up Python
23+
uses: actions/setup-python@v4
24+
with:
25+
python-version: ${{ env.PYTHON_VERSION }}
26+
27+
- name: Install hatch
28+
run: |
29+
python -m pip install hatch
30+
31+
- name: Build package
32+
run: hatch build
33+
34+
- name: Publish
35+
run: hatch build
36+
env:
37+
HATCH_INDEX_USER: ${{ vars.HATCH_INDEX_USER }}
38+
HATCH_INDEX_AUTH: ${{ secrets.HATCH_INDEX_AUTH }}

.github/workflows/run_tests.yml

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ concurrency:
1010
group: ${{ github.workflow }}-${{ github.ref }}
1111
cancel-in-progress: true
1212

13-
env:
14-
POETRY_VERSION: 1.7.1
15-
1613
jobs:
1714
testing:
1815
runs-on: ubuntu-latest
@@ -28,35 +25,15 @@ jobs:
2825
uses: actions/setup-python@v4
2926
with:
3027
python-version: ${{ matrix.python-version }}
31-
32-
- name: Load cached Poetry installation
33-
id: poetry
34-
uses: actions/cache@v3
35-
with:
36-
path: ~/.local
37-
key: poetry-install-${{env.POETRY_VERSION}}-${{ runner.os }}-${{ matrix.python-version }}
38-
39-
- name: Install and configure Poetry
40-
uses: snok/install-poetry@v1
41-
if: steps.poetry.outputs.cache-hit != 'true'
42-
with:
43-
version: ${{env.POETRY_VERSION}}
44-
virtualenvs-create: true
45-
virtualenvs-in-project: false
46-
47-
- name: Cache Poetry cache
48-
uses: actions/cache@v3
49-
id: cache
50-
with:
51-
path: ~/.cache/pypoetry
52-
key: poetry-cache-${{env.POETRY_VERSION}}-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }}
53-
54-
- name: Install dependencies
55-
if: steps.cache.outputs.cache-hit != 'true'
56-
run: poetry install -v --all-extras
28+
29+
- name: Install hatch
30+
run: |
31+
python -m pip install hatch
5732
5833
- name: Run pytest
59-
run: poetry run pytest --cov=./ --cov-report=xml
34+
run: |
35+
hatch build --hooks-only
36+
hatch run +py=${{ matrix.python-version }} testing:test --cov=./ --cov-report=xml
6037
6138
- name: Coverage report
6239
uses: codecov/codecov-action@v1

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,3 @@ cover
1818
.mypy_cache
1919
.idea
2020
.vscode
21-
poetry.lock

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

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

810
## [0.9.1] - 2023-08-06
911

CONTRIBUTING.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Contributing to python-configuration
22

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

55
## Setting up a dev environment
66

@@ -12,14 +12,23 @@
1212
cd python-configuration
1313
```
1414

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

17-
```shell
18-
poetry install
19-
```
17+
```shell
18+
hatch build --hooks-only # generate a version file from the git commit
19+
# or
20+
hatch build
21+
```
2022

2123
### Running the tests
2224

25+
To run the tests (which include linting and type checks), run:
26+
```shell
27+
hatch run test:test
28+
```
29+
30+
Before opening a PR, make sure to run
2331
```shell
24-
poetry run pytest
32+
hatch run testing:test
2533
```
34+
which executes the previous test command on all Python versions supported by the library.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 Tiago Requeijo
3+
Copyright (c) 2024 Tiago Requeijo
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# python-configuration
22
> A library to load configuration parameters hierarchically from multiple sources and formats
33
4+
[![Hatch project](https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg)](https://github.com/pypa/hatch)
45
[![version](https://img.shields.io/pypi/v/python-configuration)](https://pypi.org/project/python-configuration/)
56
![python](https://img.shields.io/pypi/pyversions/python-configuration)
67
![wheel](https://img.shields.io/pypi/wheel/python-configuration)
@@ -15,20 +16,20 @@ This library is intended as a helper mechanism to load configuration files hiera
1516

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

18-
- Python files: ...
19-
- Dictionaries: ...
20-
- Environment variables: ...
21-
- Filesystem paths: ...
22-
- JSON files: ...
23-
- INI files: ...
24-
- dotenv type files: ...
19+
- Python files
20+
- Dictionaries
21+
- Environment variables
22+
- Filesystem paths
23+
- JSON files
24+
- INI files
25+
- dotenv type files
2526
- Optional support for:
2627
- YAML files: requires `yaml`
27-
- TOML files: requires `toml`
28-
- Azure Key Vault credentials: ...
29-
- AWS Secrets Manager credentials: ...
30-
- GCP Secret Manager credentials: ...
31-
- Hashicorp Vault credentials: ...
28+
- TOML files: requires `tomli` for Python < 3.11
29+
- Azure Key Vault credentials: requires `azure-keyvault`
30+
- AWS Secrets Manager credentials: requires `boto3`
31+
- GCP Secret Manager credentials: requires `google-cloud-secret-manager`
32+
- Hashicorp Vault credentials: requires `hvac`
3233

3334

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

48-
Without the optional dependencies, the TOML and YAML loaders will not be available,
49+
Without the optional dependencies, the TOML (Python < 3.11) and YAML loaders will not be available,
4950
and attempting to use them will raise an exception.
51+
5052
## Getting started
5153

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

384-
## Contributing :tada:
386+
## Contributing
385387

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

0 commit comments

Comments
 (0)