Skip to content

Commit

Permalink
Merge pull request #61 from guyskk/feat-py310
Browse files Browse the repository at this point in the history
Support Python 3.10 ~ 3.12
  • Loading branch information
guyskk authored Dec 13, 2023
2 parents 23968bb + 29f2d08 commit 5dc5df1
Show file tree
Hide file tree
Showing 22 changed files with 564 additions and 406 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Build-Test
on: [push]
jobs:
build:
runs-on: ubuntu-22.04
env:
PIP_DISABLE_PIP_VERSION_CHECK: "1"
strategy:
matrix:
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "pypy3.9"
- "pypy3.10"
steps:
- uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Display Python version
run: python -VV && pip --version
- name: Bootstrap requirements
run: ./bootstrap.sh
- name: Run test
run: inv test
- name: Run e2e-test
run: inv e2e-test
- name: Run benchmark
run: inv benchmark
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
13 changes: 13 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Pre-Commit
on: [push]
jobs:
build:
runs-on: ubuntu-22.04
env:
PIP_DISABLE_PIP_VERSION_CHECK: "1"
steps:
- uses: actions/checkout@v4
- name: Install pre-commit
run: ./pre-commit-install.sh
- name: Run pre-commit
run: .pre-commit/bin/pre-commit run --verbose --all-files
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,6 @@ ENV/
.mypy_cache/

# editor
.vscode
.vscode/

.pre-commit/
4 changes: 4 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[settings]
multi_line_output=VERTICAL_HANGING_INDENT
include_trailing_comma=true
sections=FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
26 changes: 17 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
- repo: git://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
files: \.(py|pyx|sh|md|txt|in|ini|json|yaml|yml)$
- id: end-of-file-fixer
files: \.(py|pyx|sh|md|txt|in|ini|json|yaml|yml)$
- id: check-byte-order-marker
- id: fix-byte-order-marker
files: \.(py|pyx)$
- id: check-case-conflict
- id: check-added-large-files
args:
- '--maxkb=2000'
- id: check-merge-conflict
- id: check-symlinks
- id: check-json
- id: check-yaml
- id: debug-statements
- id: check-docstring-first
files: \.(py|pyx)$
- id: fix-encoding-pragma
files: \.(py|pyx)$
args:
- '--remove'
- id: mixed-line-ending
args:
- '--fix=no'
- id: check-executables-have-shebangs
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
- id: check-json
- id: check-yaml
- id: debug-statements
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
args:
- '--max-line-length=119'
Expand Down
33 changes: 0 additions & 33 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Validr

[![travis-ci](https://travis-ci.org/guyskk/validr.svg?branch=master)](https://travis-ci.org/guyskk/validr) [![codecov](https://codecov.io/gh/guyskk/validr/branch/master/graph/badge.svg)](https://codecov.io/gh/guyskk/validr)
[![github-action](https://github.com/guyskk/validr/actions/workflows/build-test.yml/badge.svg?branch=main)](https://github.com/guyskk/validr/actions/workflows/build-test.yml) [![codecov](https://codecov.io/gh/guyskk/validr/branch/master/graph/badge.svg)](https://codecov.io/gh/guyskk/validr)

A simple, fast, extensible python library for data validation.

Expand Down
10 changes: 4 additions & 6 deletions bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/bin/bash
set -ex

pip install 'pip>=19.1.1'
pip install 'py>=1.8.0' # work around pytest requirement
pip install 'cython>=0.25.2'
VALIDR_SETUP_MODE=dist pip install -e '.[dev,benchmark]' -r requirements.txt

pre-commit install
pip install 'pip>=22.3.1' 'wheel>=0.38.4'
pip install -r requirements.txt
pip list
VALIDR_SETUP_MODE=dist pip install --no-build-isolation -e .
7 changes: 7 additions & 0 deletions pre-commit-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -ex

python -m venv .pre-commit/
.pre-commit/bin/pip install 'pre-commit==3.6.0'
.pre-commit/bin/pre-commit install
.pre-commit/bin/pre-commit install-hooks
71 changes: 37 additions & 34 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,57 +1,60 @@
appdirs==1.4.3
aspy.yaml==1.3.0
attrs==19.3.0
autopep8==1.5
bleach==3.3.0
autopep8==2.0.4
bleach==6.1.0
certifi==2019.11.28
cfgv==2.0.1
chardet==3.0.4
charset-normalizer==2.1.1
Click==7.0
codecov==2.0.15
codecov==2.1.13
contextlib2==0.5.5
coverage==5.0.3
Cython==0.29.15
distlib==0.3.0
coverage==7.3.2
Cython==3.0.6
distlib==0.3.8
docutils==0.16
entrypoints==0.3
exceptiongroup==1.2.0
filelock==3.0.12
flake8==3.7.9
identify==1.4.11
flake8==6.1.0
idna==2.8
importlib-metadata==1.5.0
importlib-metadata==7.0.0
importlib-resources==1.0.2
invoke==1.4.1
iniconfig==2.0.0
invoke==2.2.0
isort==5.13.1
jaraco.classes==3.3.0
jsonschema==3.2.0
mccabe==0.6.1
keyring==24.3.0
markdown-it-py==3.0.0
mccabe==0.7.0
mdurl==0.1.2
more-itertools==8.2.0
nodeenv==1.3.5
nh3==0.2.15
packaging==20.1
pathlib2==2.3.5
pkginfo==1.5.0.1
pkginfo==1.9.6
pluggy==0.13.1
pre-commit==1.21.0
py==1.10.0
pycodestyle==2.5.0
pyflakes==2.1.1
Pygments==2.7.4
pyparsing==2.4.6
py==1.11.0
pycodestyle==2.11.1
pyflakes==3.1.0
Pygments==2.17.2
pyparsing==3.1.1
pyrsistent==0.15.7
pytest==5.3.5
pytest-cov==2.8.1
PyYAML==5.4
readme-renderer==24.0
requests==2.22.0
requests-toolbelt==0.9.1
pytest==7.4.3
pytest-cov==4.1.0
readme-renderer==42.0
requests==2.31.0
requests-toolbelt==1.0.0
rfc3986==2.0.0
rich==13.7.0
schema==0.7.1
schematics==2.1.0
six==1.14.0
terminaltables==3.1.0
toml==0.10.0
schematics==2.1.1
six==1.16.0
tomli==2.0.1
tqdm==4.42.1
twine==1.15.0
twine==4.0.2
urllib3==1.26.5
virtualenv==20.0.4
voluptuous==0.11.7
voluptuous==0.14.1
wcwidth==0.1.8
webencodings==0.5.1
zipp==1.1.0
43 changes: 16 additions & 27 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import os
from os.path import dirname, basename, splitext
from glob import glob
from multiprocessing import cpu_count
from os.path import basename, dirname, splitext
from platform import python_implementation

from setuptools import Extension, setup


def _read_file(filepath):
with open(os.path.join(dirname(__file__), filepath), 'r', encoding='utf-8') as f:
filepath = os.path.join(dirname(__file__), filepath)
with open(filepath, 'r', encoding='utf-8') as f:
return f.read()


Expand All @@ -28,26 +32,7 @@ def _read_file(filepath):
install_requires=[
'idna>=2.5',
'pyparsing>=2.1.0',
'terminaltables>=3.1.0',
],
extras_require={
'dev': [
'pre-commit>=0.13.3',
'flake8>=3.2.1',
'pytest>=3.0.6',
'pytest-cov>=2.4.0',
'codecov>=2.0.5',
'invoke>=1.0.0',
'twine>=1.11.0',
],
'benchmark': [
'click>=6.7',
'schema>=0.6.5',
'jsonschema>=2.5.1',
'schematics>=2.0.0a1',
'voluptuous>=0.9.3',
],
},
zip_safe=False,
classifiers=[
'Intended Audience :: Developers',
Expand Down Expand Up @@ -84,7 +69,9 @@ def _get_validr_setup_mode():
mode = os.getenv('VALIDR_SETUP_MODE')
if mode:
mode = mode.strip().lower()
assert mode in _SETUP_MODES, 'unknown validr setup mode {}'.format(mode)
if mode not in _SETUP_MODES:
err_msg = 'unknown validr setup mode {}'.format(mode)
raise RuntimeError(err_msg)
return mode
if _has_c_compiler():
return 'c'
Expand All @@ -95,12 +82,12 @@ def _get_validr_setup_mode():
def _prepare_setup_options(mode):
is_pyx = mode in ['pyx', 'pyx_dbg']
is_c = mode in ['c', 'c_dbg']
is_dist = mode in ['dist', 'dist_dbg']
is_debug = mode.endswith('_dbg')
is_dist = mode in ['dist', 'dist_dbg']
enable_c = python_implementation() == 'CPython'
ext_modules = None
if is_pyx or is_c or is_dist:
if enable_c and (is_pyx or is_c or is_dist):
if is_pyx or is_dist:
from multiprocessing import cpu_count
from Cython.Build import cythonize
directives = {'language_level': 3}
if is_debug:
Expand All @@ -115,7 +102,8 @@ def _prepare_setup_options(mode):
)
if is_c:
sources = list(glob('src/validr/*.c'))
assert sources, 'Not found any *.c source files'
if not sources:
raise RuntimeError('Not found any *.c source files')
ext_modules = []
for filepath in sources:
module_name = 'validr.' + splitext(basename(filepath))[0]
Expand All @@ -142,4 +130,5 @@ def _validr_setup():
setup(**options)


_validr_setup()
if __name__ == '__main__':
_validr_setup()
17 changes: 13 additions & 4 deletions src/validr/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
"""A simple, fast, extensible python library for data validation."""
from .exception import Invalid, ModelInvalid, SchemaError, ValidrError, mark_index, mark_key
from .model import ImmutableInstanceError, asdict, fields, modelclass
from .schema import Builder, Compiler, Schema, T
from .validator import (
create_re_validator, create_enum_validator, builtin_validators, validator)
from .schema import Schema, Compiler, T, Builder
from .model import modelclass, fields, asdict, ImmutableInstanceError
Invalid,
ModelInvalid,
SchemaError,
ValidrError,
builtin_validators,
create_enum_validator,
create_re_validator,
)
from .validator import py_mark_index as mark_index
from .validator import py_mark_key as mark_key
from .validator import validator

__all__ = (
'ValidrError', 'Invalid', 'ModelInvalid', 'SchemaError',
Expand Down
Loading

0 comments on commit 5dc5df1

Please sign in to comment.