Skip to content

Commit

Permalink
feat: cythonize effect monad
Browse files Browse the repository at this point in the history
  • Loading branch information
Sune Debel authored Apr 3, 2021
1 parent c8629ab commit 097265d
Show file tree
Hide file tree
Showing 43 changed files with 2,953 additions and 2,056 deletions.
107 changes: 0 additions & 107 deletions .circleci/config.yml

This file was deleted.

170 changes: 170 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
name: ci

on:
pull_request:
branches:
- master
release:
types: ["published"]


jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Restore cache
uses: actions/cache@v1
with:
path: .venv
key: py3.7-ubuntu-latest-venv-cache-${{ hashFiles('**/poetry.lock') }}
- name: Install poetry
run: |
pip install poetry==1.1.5
poetry config virtualenvs.in-project true
- name: Install dependencies
run: |
poetry install -E http -E sql --no-root
poetry run task compile
poetry install
- name: Lint
run: poetry run task lint
build_docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Restore cache
uses: actions/cache@v1
with:
path: .venv
key: py3.7-ubuntu-latest-venv-cache-${{ hashFiles('**/poetry.lock') }}
- name: Install poetry
run: |
pip install poetry==1.1.5
poetry config virtualenvs.in-project true
- name: Install dependencies
run: |
poetry install -E http -E sql --no-root
poetry run task compile
poetry install
- name: Build docs
run: poetry run mkdocs build
test_sdist:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Restore cache
uses: actions/cache@v1
with:
path: .venv
key: py3.7-ubuntu-latest-venv-cache-${{ hashFiles('**/poetry.lock') }}
- name: Install poetry
run: |
pip install poetry==1.1.5
poetry config virtualenvs.in-project true
- name: Install dependencies
run: |
poetry install -E http -E sql --no-root
poetry run task compile
poetry build -f sdist
poetry run pip install --ignore-installed dist/*
- name: Run tests
run: poetry run pytest -n 4 --mypy-ini-file=tests/mypy.ini
- name: Upload sdist
uses: actions/upload-artifact@v2
with:
name: sdist
path: dist/*.tar.gz
test_wheel:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: [3.7, 3.8]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Restore cache
uses: actions/cache@v1
with:
path: .venv
key: py${{ matrix.python-version }}-${{ matrix.os }}-venv-cache-${{ hashFiles('**/poetry.lock') }}
- name: Install poetry
run: |
pip install poetry==1.1.5
poetry config virtualenvs.in-project true
- name: Install dependencies
run: |
poetry install -E http -E sql --no-root
poetry run task compile
poetry build -f wheel
poetry run pip install --ignore-installed dist/*
- name: Run tests
run: poetry run pytest -n 4 --mypy-ini-file=tests/mypy.ini
- name: Upload wheel
uses: actions/upload-artifact@v2
with:
name: wheel-${{ matrix.os }}-py${{ matrix.python-version }}
path: dist/*.whl
release:
needs: [lint, build_docs, test_wheel, test_sdist]
if: github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Restore cache
uses: actions/cache@v1
with:
path: .venv
key: py3.7-ubuntu-latest-venv-cache-${{ hashFiles('**/poetry.lock') }}
- name: Install poetry
run: |
pip install poetry==1.1.5
poetry config virtualenvs.in-project true
- name: Download wheels and sdist
uses: actions/download-artifact@v2
- name: Gather artifacts
run: |
mkdir dist
mv sdist/*.tar.gz dist
mv wheel-*/*.whl dist
- name: Install dependencies
run: |
poetry install -E http -E sql --no-root
poetry run task compile
poetry install
- name: Check version
run: |
tag=$(echo ${{ github.ref }} | cut -d / -f 3)
poetry run python scripts/check_version.py pyproject.toml $tag
- name: Release pfun
env:
PYPI_USERNAME: ${{ secrets.PYPI_USER }}
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: poetry publish --username $PYPI_USERNAME --password $PYPI_PASSWORD
- name: Release docs
run: poetry run mkdocs gh-deploy
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,4 @@ docs/build
.idea
.vscode
.DS_Store
*.c
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ repos:
language: system
entry: end-of-file-fixer
types: [text]
exclude: docs/CNAME

- id: isort
name: isort
Expand All @@ -40,6 +41,6 @@ repos:
name: mypy
stages: [commit]
language: system
entry: mypy pfun
entry: mypy src/pfun
types: [python]
pass_filenames: false
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## <img src="https://raw.githubusercontent.com/suned/pfun/master/logo/pfun_logo.svg?sanitize=true" style=" width:50px ; height:50px "/> <br> <p align="center">Functional, composable, asynchronous, type-safe Python.</p>

- [Documentation](https://pfun.readthedocs.io/en/stable/)
- [Documentation](https://pfun.dev)
- [Known issues](https://github.com/suned/pfun/issues?q=is%3Aopen+is%3Aissue+label%3Abug)

## Install
Expand Down Expand Up @@ -32,7 +32,7 @@ On [ko-fi](https://ko-fi.com/python_pfun)

Requires [poetry](https://poetry.eustace.io/)

- Install dependencies with `poetry install`
- Build documentation with `poetry run mkdocs serve`
- Run tests with `poetry run tox`
- Lint with `poetry run pre-commit run --all`
- Install dependencies with `poetry install -E http -E sql`
- Build documentation with `poetry run task serve-docs`
- Run tests with `poetry run task test`
- Lint with `poetry run task lint`
6 changes: 5 additions & 1 deletion build.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from setuptools.extension import Extension


def build(setup_kwargs):
extensions = [Extension("pfun.effect", ['src/pfun/effect.c'])]
setup_kwargs.update(
{
"package_data": {"pfun": ["py.typed"]}
"ext_modules": extensions
}
)
1 change: 1 addition & 0 deletions docs/CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pfun.dev
22 changes: 20 additions & 2 deletions docs/effect_api.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
::: pfun.Effect
selection:
inherited_members: true
members: [
__call__,
and_then,
map,
run,
discard_and_then,
either,
recover,
memoize,
ensure
]

::: pfun.Success
::: pfun.Try
::: pfun.Depends
Expand All @@ -11,8 +25,12 @@
::: pfun.absolve
::: pfun.combine
::: pfun.lift
::: pfun.lift_cpu_bound
::: pfun.lift_io_bound
::: pfun.catch
::: pfun.catch_cpu_bound
::: pfun.catch_io_bound
::: pfun.from_awaitable
::: pfun.from_callable
::: pfun.cpu_bound
::: pfun.io_bound
::: pfun.from_cpu_bound_callable
::: pfun.from_io_bound_callable
Loading

0 comments on commit 097265d

Please sign in to comment.