Skip to content

Commit

Permalink
Use pyproject.toml with poetry (#18)
Browse files Browse the repository at this point in the history
This PR removes the old installation via setup.py, and introduces poetry with pyproject.toml
  • Loading branch information
margau committed Nov 20, 2022
1 parent d1b17a7 commit 8651ca4
Show file tree
Hide file tree
Showing 13 changed files with 178 additions and 156 deletions.
35 changes: 0 additions & 35 deletions .github/workflows/build.yml

This file was deleted.

11 changes: 6 additions & 5 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ jobs:
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-pip-${{ hashFiles('**/poetry.lock') }}
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
python -m pip install poetry
poetry self add "poetry-dynamic-versioning[plugin]"
poetry install
- name: Lint with flake8
run: ./scripts/lint.py
run: poetry run flake8 --show-source src
36 changes: 16 additions & 20 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,25 @@ jobs:
name: Build and publish Python
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
fetch-depth: 0
- name: Set up Python 3.9
uses: actions/setup-python@v1
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
${{ runner.os }}-pip-${{ hashFiles('**/poetry.lock') }}
- name: Install Dependencies
run: |
python -m pip install poetry
poetry self add "poetry-dynamic-versioning[plugin]"
poetry install
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
poetry build
- name: Publish distribution 📦 to PyPI
if: ${{startsWith(github.ref, 'refs/tags') || (github.ref == 'refs/heads/main')}}
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}
run: poetry publish --username __token__ --password ${{ secrets.PYPI_API_TOKEN }}
40 changes: 0 additions & 40 deletions .github/workflows/release.yml

This file was deleted.

6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ Feel free to contribute improvements, as well as support for non-apt based syste

## Installation

Clone the repository and run `python setup.py install` from the main directory.
Run `pip3 install pkg-exporter`.

Clone the repository and run `poetry install` from the main directory.
You can also use other standard installation methods for python packages, like directly installing from this git repository.

Alternatively, a single binary built using pyinstaller is provided.
The pyinstaller-based binary is not provided any more.

### apt-based systems

Expand Down
123 changes: 123 additions & 0 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[tool.poetry]
name = "pkg-exporter"
version = "0.0.0"
description = "This project provides an textfile-based exporter for apt-repositories"
authors = ["Marvin Gaube <dev@marvingaube.de>"]
license = "GPL3"
readme = "README.md"


[tool.poetry.dependencies]
python = "^3.6"
prometheus-client = "^0.15.0"

[tool.poetry.group.dev.dependencies]
flake8 = "*"

[tool.poetry-dynamic-versioning]
enable = true
dirty = true

[build-system]
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning"]
build-backend = "poetry_dynamic_versioning.backend"

[tool.poetry.scripts]
pkg-exporter = 'pkg_exporter.textfile:main'
3 changes: 0 additions & 3 deletions requirements.txt

This file was deleted.

9 changes: 0 additions & 9 deletions scripts/build.py

This file was deleted.

9 changes: 0 additions & 9 deletions scripts/lint.py

This file was deleted.

23 changes: 0 additions & 23 deletions setup.cfg

This file was deleted.

8 changes: 0 additions & 8 deletions setup.py

This file was deleted.

5 changes: 3 additions & 2 deletions src/pkg_exporter/textfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,12 @@ def main():
reboot_gauge.set(rebootmanager.getMetricValue())

exporter_file = os.getenv("PKG_EXPORTER_FILE",
"/var/prometheus/pkg-exporter.prom")
"/var/prometheus/pkg-exporter.prom")
exporter_dir = os.path.dirname(exporter_file)
os.makedirs(exporter_dir, exist_ok=True)

write_to_textfile(exporter_file, registry)


if __name__ == "__main__":
main()
main()

0 comments on commit 8651ca4

Please sign in to comment.