Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to poetry #144

Merged
merged 19 commits into from
Aug 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ jobs:
# key: ubuntu-20.04-${{ env.pythonLocation }}-${{ hashFiles('**/Pipfile') }}
- name: Install dependencies
run: |
pip install pipenv
pipenv install --skip-lock --system --dev
pip install poetry
poetry install
- name: Get PR number
uses: jwalton/gh-find-current-pr@v1
id: findPr
Expand All @@ -44,10 +44,7 @@ jobs:
env:
PR: ${{ steps.findPr.outputs.pr }}
- name: Build docs
run: |
mkdir -p docs
pdoc serde --html -o html --force
cp -f html/serde/* docs/
run: make docs
- name: Deploy on gh-pages
uses: JamesIves/github-pages-deploy-action@3.7.1
with:
Expand Down
25 changes: 11 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9, 3.10-dev, pypy3]
python-version: [3.6, 3.7, 3.8, 3.9, pypy3]
os: [ubuntu-20.04, macos-10.15, windows-2019]
steps:
- name: Checkout
Expand All @@ -27,14 +27,12 @@ jobs:
# key: ${{ matrix.os }}-${{ env.pythonLocation }}-${{ hashFiles('**/Pipfile') }}
- name: Install dependencies
run: |
pip install pipenv
pipenv install --skip-lock --system --dev
pip list
cd examples && pipenv install --skip-lock --system --dev
pip install poetry
make setup
- name: Run tests
run: |
pytest tests --doctest-modules serde -v
cd examples && python runner.py
make test
make examples

check_formatting:
name: Check formatting
Expand Down Expand Up @@ -83,10 +81,10 @@ jobs:
# key: ubuntu-20.04-${{ env.pythonLocation }}-${{ hashFiles('**/Pipfile') }}
- name: Install dependencies
run: |
pip install pipenv
pipenv install --skip-lock --system --dev
pip install poetry
poetry install
- name: Check coverage
run: pytest tests --doctest-modules serde -v --cov=serde --cov-report term --cov-report xml
run: make coverage
- name: Upload coverage report to codecov.io
uses: codecov/codecov-action@v1

Expand All @@ -108,8 +106,7 @@ jobs:
# key: ubuntu-20.04-${{ env.pythonLocation }}-${{ hashFiles('**/Pipfile') }}
- name: Install dependencies
run: |
pip install pipenv
cd bench && pipenv install --skip-lock --system
pip install poetry
make setup-bench
- name: Run benchmark
run: |
python bench/bench.py
run: make bench
12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,20 @@ repos:
rev: 19.3b0
hooks:
- id: black
args: [
"--target-version=py36",
"--target-version=py37",
"--target-version=py38",
"--line-length=120",
"--skip-string-normalization",
]

- repo: https://github.com/timothycrosley/isort
rev: 5.7.0
hooks:
- id: isort
args: [
"--profile=black",
"--line-length=120",
"--atomic",
]
10 changes: 8 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,15 @@ Thank you for considering contributing to Pyserde!
git remote add upstream https://github.com/yukinarit/pyserde
git fetch upstream
```
- Install pipenv:
- Install Poetry (used for dependency management and packaging):

For macOS / Linux / WSL
```bash
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
```
For Windows Powershell
```bash
pip install pipenv
(Invoke-WebRequest -Uri https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py -UseBasicParsing).Content | python -
```
- Run setup script:
```bash
Expand Down
33 changes: 16 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,49 +1,48 @@
SHELL:=/bin/bash
PYTHON ?= python
PIPENV ?= pipenv
POETRY ?= poetry

.PHONY: all setup build test examples coverage pep8 mypy fmt docs open-docs bench

all: setup pep8 mypy docs test examples

setup:
$(PIPENV) install --dev --skip-lock
$(PIPENV) run pip list
$(PIPENV) run pre-commit install
pushd examples && $(PIPENV) install --dev && popd
$(POETRY) install
$(POETRY) run pip list
$(POETRY) run pre-commit install
pushd examples && $(POETRY) install && popd

setup-bench:
pushd bench && $(PIPENV) install && popd
pushd bench && $(POETRY) install && popd

build:
$(PIPENV) run $(PYTHON) setup.py sdist
$(PIPENV) run $(PYTHON) setup.py bdist_wheel
$(POETRY) build

test:
$(PIPENV) run pytest tests --doctest-modules serde -v
$(POETRY) run pytest tests --doctest-modules serde -v

examples:
pushd examples && $(PIPENV) run $(PYTHON) runner.py && popd
pushd examples && $(POETRY) run $(PYTHON) runner.py && popd

coverage:
$(PIPENV) run pytest tests --doctest-modules serde -v --cov=serde --cov-report term --cov-report xml
$(POETRY) run pytest tests --doctest-modules serde -v --cov=serde --cov-report term --cov-report xml

pep8:
$(PIPENV) run flake8
$(POETRY) run flake8

mypy:
$(PIPENV) run mypy serde
$(POETRY) run mypy serde

fmt:
$(PIPENV) run pre-commit run -a
$(POETRY) run pre-commit run -a

docs:
mkdir -p docs
$(PIPENV) run pdoc serde --html -o html --force --template-dir docs/template
$(POETRY) run pdoc serde --html -o html --force --template-dir docs/template
cp -f html/serde/* docs/

open-docs:
$(PIPENV) run pdoc serde --html -o html --force --template-dir docs/template --http 127.0.0.1:5001
$(POETRY) run pdoc serde --html -o html --force --template-dir docs/template --http 127.0.0.1:5001

bench:
pushd bench && $(PIPENV) run $(PYTHON) bench.py && popd
pushd bench && $(POETRY) run $(PYTHON) bench.py && popd
28 changes: 0 additions & 28 deletions Pipfile

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ To run benchmark in your environment:
```sh
git clone git@github.com:yukinarit/pyserde.git
cd pyserde/bench
pipenv install
pipenv run python bench.py --full
poetry install
poetry run python bench.py --full
```

You can check [the benchmarking code](https://github.com/yukinarit/pyserde/blob/master/bench/bench.py) for more information.
Expand Down Expand Up @@ -435,7 +435,7 @@ e.g. in pyserde project

```
cd pyserde
pipenv shell
poetry shell
python -m serde.inspect examples/simple.py Foo
```

Expand Down
24 changes: 0 additions & 24 deletions bench/Pipfile

This file was deleted.

20 changes: 20 additions & 0 deletions bench/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[tool.poetry]
name = "pyserde_bench"
version = "0.1.0"
description = "Benchmark package for pyserde"
authors = ["yukinarit <yukinarit84@gmail.com>"]

[tool.poetry.dependencies]
python = "^3.6.1"
click = "*"
pyserde = {path = "../"}

[tool.poetry.dev-dependencies]
dacite = "*"
mashumaro = "*"
marshmallow = "~=3.2"
attrs = "*"
cattrs = "*"
seaborn = "==0.9.0"
matplotlib = "==3.1.1"
numpy = "==1.17.2"
4 changes: 2 additions & 2 deletions examples/jsonfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
Make an http request to JSON WebAPI.

Usage:
$ pipenv install
$ pipenv run jsonfile.py
$ poetry install
$ poetry run python jsonfile.py
"""
from dataclasses import dataclass
from typing import List, Optional
Expand Down
13 changes: 13 additions & 0 deletions examples/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[tool.poetry]
name = "pyserde_examples"
version = "0.1.0"
description = "Examples package for pyserde"
authors = ["yukinarit <yukinarit84@gmail.com>"]

[tool.poetry.dependencies]
python = "^3.6.1"
pyserde = {path = "../"}
toml = "*"
pytoml = "*"
requests = "*"
envclasses = "==0.2.1"
4 changes: 2 additions & 2 deletions examples/rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@


Usage:
$ pipenv install
$ pipenv run rename.py
$ poetry install
$ poetry run python rename.py
"""
from dataclasses import dataclass, field

Expand Down
4 changes: 2 additions & 2 deletions examples/rename_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@


Usage:
$ pipenv install
$ pipenv run rename_all.py
$ poetry install
$ poetry run python rename_all.py
"""
from dataclasses import dataclass
from typing import Optional
Expand Down
4 changes: 2 additions & 2 deletions examples/skip.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
Example usage of skip and skip_if attributes.

Usage:
$ pipenv install
$ pipenv run skip.py
$ poetry install
$ poetry run python skip.py
"""

from dataclasses import dataclass, field
Expand Down
4 changes: 2 additions & 2 deletions examples/tomlfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
Read Pipenv Pipfile by pyserde.

Usage:
$ pipenv install
$ pipenv run tomlfile.py
$ poetry install
$ poetry run python tomlfile.py
"""
from dataclasses import dataclass
from typing import Dict, List, Optional, Union
Expand Down
8 changes: 0 additions & 8 deletions examples/webapi/Pipfile

This file was deleted.

4 changes: 2 additions & 2 deletions examples/webapi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
## Run

```
pipenv install
pipenv run python app.py
poetry install
poetry run python app.py
```

## Usage
Expand Down
10 changes: 10 additions & 0 deletions examples/webapi/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[tool.poetry]
name = "pyserde_examples_webapi"
version = "0.1.0"
description = "WebAPI example package for pyserde"
authors = ["yukinarit <yukinarit84@gmail.com>"]

[tool.poetry.dependencies]
python = "^3.6.1"
pyserde = {path = "../../"}
flask = "~=1.1"
4 changes: 2 additions & 2 deletions examples/yamlfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
Read swagger echo example yaml.

Usage:
$ pipenv install
$ pipenv run yamlfile.py
$ poetry install
$ poetry run python yamlfile.py
"""
from dataclasses import dataclass
from typing import Dict, List, Optional, Union
Expand Down
Loading