Skip to content

Commit

Permalink
Move from setup.py to poetry. (#36)
Browse files Browse the repository at this point in the history
Use poetry for dependencies etc instead of setup.py
  • Loading branch information
KPLauritzen authored Jul 12, 2022
1 parent d12e54f commit a119f74
Show file tree
Hide file tree
Showing 10 changed files with 2,786 additions and 79 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/code_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@ jobs:
COVERAGE_TOTAL: 50

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: 3.9
python-version: "3.10"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: pytester-cov
id: pytester-cov
uses: programmingwithalex/pytester-cov@main
with:
pytest-root-dir: '.'
cov-omit-list: 'tests/*, docs/*, setup.py, examples/*'
cov-omit-list: 'tests/*, docs/*, examples/*'
cov-threshold-single: ${{ env.COVERAGE_SINGLE }}
cov-threshold-total: ${{ env.COVERAGE_TOTAL }}

Expand Down
23 changes: 13 additions & 10 deletions .github/workflows/precommit-PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,31 @@ jobs:
matrix:
python-version: ["3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.1.13
virtualenvs-create: false
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pytest pytest-cov
pip install -e .
poetry install --no-interaction
- name: Test with pytest
run: |
pytest --cov dfds_ds_toolbox --cov-report=html:coverage
poetry run pytest --cov dfds_ds_toolbox --cov-report=html:coverage
precommit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
22 changes: 8 additions & 14 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,13 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install twine build
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python -m build
twine upload dist/*
python-version: "3.10"
- name: Build and publish to pypi
uses: JRubics/poetry-publish@v1.11
with:
repository_username: ${{ secrets.PYPI_USERNAME }}
repository_password: ${{ secrets.PYPI_PASSWORD }}
14 changes: 5 additions & 9 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ version: 2
build:
os: ubuntu-20.04
tools:
python: "3.9"
# You can also specify other tool versions:
# nodejs: "16"
# rust: "1.55"
# golang: "1.17"
python: "3.10"

# Build documentation in the docs/ directory with Sphinx
sphinx:
Expand All @@ -23,8 +19,8 @@ sphinx:
# formats:
# - pdf

# Optionally declare the Python requirements required to build your docs
python:
install:
- requirements: requirements.txt
- requirements: requirements-dev.txt
install:
- requirements: docs/requirements.txt
- method: pip
path: .
18 changes: 5 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,17 @@ the classes can be found in later sections.

## Install locally

Make a virtual environment:
We use poetry as the package manager and build tool. Make sure you have poetry
installed locally, then run

```shell
python -m venv venv
venv\Scripts\activate.bat
```

Install dependencies

```shell
pip install -r requirements.txt
pip install -r requirements-dev.txt
pre-commit install
pip install -e .
poetry install
```

Run tests to see everything working

```shell
pytest
poetry run pytest
```

## Install this library in another repo
Expand Down Expand Up @@ -120,6 +111,7 @@ https://dfds-ds-toolbox.readthedocs.io
To build the documentation locally run:

```shell
pip install -r docs/requirements.txt
cd docs/
sphinx-apidoc -o . ../dfds_ds_toolbox/ ../*tests*
make html
Expand Down
4 changes: 4 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sphinx==4.2.0
sphinx-autodoc-typehints==1.12.0
sphinx-rtd-theme==1.0.0
sphinx-gallery==0.10.0
Loading

0 comments on commit a119f74

Please sign in to comment.