Skip to content

Commit 05c036f

Browse files
authored
modern python builds (#49)
* modern take 1 * poetry toml, rejson docker * need an explicit call to poetry install - maybe because of zip safe * title
1 parent 2de5c29 commit 05c036f

File tree

8 files changed

+200
-107
lines changed

8 files changed

+200
-107
lines changed

.circleci/circle_requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
poetry>=1.1.6
2+
tox>=3.23.1
3+
tox-poetry>=0.3.0

.circleci/config.yml

Lines changed: 106 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,67 +2,135 @@
22
#
33
# Check https://circleci.com/docs/2.0/language-python/ for more details
44
#
5-
version: 2
6-
jobs:
7-
build:
8-
docker:
9-
- image: circleci/python:3.6.1
10-
11-
- image: redislabs/rejson:edge
12-
port: 6379:6379
5+
version: 2.1
136

14-
working_directory: ~/repo
7+
commands:
158

9+
abort_for_docs:
1610
steps:
11+
- run:
12+
name: Avoid tests for docs
13+
command: |
14+
if [[ $CIRCLE_BRANCH == *docs ]]; then
15+
echo "Identifies as documents PR, no testing required"
16+
circleci step halt
17+
fi
18+
19+
abort_for_noci:
20+
steps:
21+
- run:
22+
name: Ignore CI for specific branches
23+
command: |
24+
if [[ $CIRCLE_BRANCH == *noci ]]; then
25+
echo "Identifies as actively ignoring CI, no testing required."
26+
circleci step halt
27+
fi
28+
29+
30+
early_return_for_forked_pull_requests:
31+
description: >-
32+
If this build is from a fork, stop executing the current job and return success.
33+
This is useful to avoid steps that will fail due to missing credentials.
34+
steps:
35+
- run:
36+
name: Early return if this build is from a forked PR
37+
command: |
38+
if [[ -n "$CIRCLE_PR_NUMBER" ]]; then
39+
echo "Nothing to do for forked PRs, so marking this step successful"
40+
circleci step halt
41+
fi
42+
43+
build_and_test:
44+
steps:
45+
- abort_for_docs
46+
- abort_for_noci
1747
- checkout
1848

19-
# Download and cache dependencies
20-
- restore_cache:
49+
- restore_cache: # Download and cache dependencies
2150
keys:
22-
- v1-dependencies-{{ checksum "requirements.txt" }}
51+
- v1-dependencies-{{ checksum "pyproject.toml" }}
2352
# fallback to using the latest cache if no exact match is found
2453
- v1-dependencies-
2554

55+
- run:
56+
name: install tox dependencies
57+
command: |
58+
pip install --user --quiet -r .circleci/circle_requirements.txt
59+
2660
- run:
2761
name: install dependencies
2862
command: |
29-
python -m venv venv
30-
. venv/bin/activate
31-
pip install -r requirements.txt
32-
pip install codecov
63+
poetry install
3364
34-
- save_cache:
35-
paths:
36-
- ./venv
37-
key: v1-dependencies-{{ checksum "requirements.txt" }}
65+
- run:
66+
name: build sdist and wheels
67+
command: |
68+
poetry build
3869
3970
- run:
40-
name: test dist
41-
command: python setup.py sdist
71+
name: lint
72+
command: |
73+
tox -e linters
4274
4375
- run:
4476
name: run tests
45-
command: |
46-
. venv/bin/activate
47-
coverage run --source=rejson setup.py test
48-
codecov
49-
50-
# - store_artifacts:
51-
# path: test-reports
52-
# destination: test-reports
53-
77+
command:
78+
tox -e cover
79+
80+
- save_cache:
81+
paths:
82+
- ./.tox
83+
- ~/.cache/pip
84+
key: v1-dependencies-{{ checksum "pyproject.toml" }}
85+
86+
jobs:
87+
build:
88+
parameters:
89+
python_version:
90+
type: string
91+
default: "latest"
92+
docker:
93+
- image: circleci/python:<<parameters.python_version>>
94+
- image: redislabs/rejson:edge
95+
steps:
96+
- build_and_test
97+
98+
on-any-branch: &on-any-branch
99+
filters:
100+
branches:
101+
only:
102+
- /.*/
103+
tags:
104+
ignore: /.*/
105+
106+
on-master: &on-master
107+
filters:
108+
branches:
109+
only:
110+
- master
111+
112+
# the is to build and test, per commit against all supported python versions
113+
python-versions: &python-versions
114+
matrix:
115+
parameters:
116+
python_version:
117+
- "3.6.9"
118+
- "3.7.9"
119+
- "3.8.9"
120+
- "3.9.4"
121+
- "latest"
122+
54123
workflows:
55-
version: 2
56124
commit:
57125
jobs:
58-
- build
126+
- build:
127+
<<: *on-any-branch
128+
<<: *python-versions
129+
59130
nightly:
60131
triggers:
61132
- schedule:
62133
cron: "0 0 * * *"
63-
filters:
64-
branches:
65-
only:
66-
- master
134+
<<: *on-master
67135
jobs:
68-
- build
136+
- build

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
[![PyVersions](https://img.shields.io/pypi/pyversions/rejson.svg)](https://github.com/RedisJSON/redisjson-py)
55
[![GitHub issues](https://img.shields.io/github/release/RedisJSON/redisjson-py.svg)](https://github.com/RedisJSON/redisjson-py/releases/latest)
66
[![Codecov](https://coveralls.io/repos/github/RedisLabs/rejson-py/badge.svg?branch=master)](https://coveralls.io/github/RedisLabs/rejson-py?branch=master)
7+
[![Known Vulnerabilities](https://snyk.io/test/github/RedisJSON/redisjson-py/badge.svg?targetFile=pyproject.toml)](https://snyk.io/test/github/RedisJSON/redisjson-py?targetFile=pyproject.toml)
78

89
# RedisJSON Python Client
910

1011
[![Forum](https://img.shields.io/badge/Forum-RedisJSON-blue)](https://forum.redislabs.com/c/modules/redisjson)
1112
[![Discord](https://img.shields.io/discord/697882427875393627?style=flat-square)](https://discord.gg/QUkjSsk)
12-
13+
1314
rejson-py is a package that allows storing, updating and querying objects as
1415
JSON documents in a [Redis](https://redis.io) database that is extended with the
1516
[ReJSON module](https://github.com/redislabsmodules/rejson). The package extends
@@ -23,6 +24,17 @@ JSON.
2324
$ pip install rejson
2425
```
2526

27+
## Development
28+
29+
1. Create a virtualenv to manage your python dependencies, and ensure it's active.
30+
```virtualenv -v venv```
31+
2. Install [pypoetry](https://python-poetry.org/) to manage your dependencies.
32+
```pip install --user poetry```
33+
3. Install dependencies.
34+
```poetry install```
35+
36+
[tox](https://tox.readthedocs.io/en/latest/) runs all tests as its default target. Running *tox* by itself will run unit tests. Ensure you have a running redis, with the module loaded.
37+
2638
## Usage example
2739

2840
```python

build.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from typing import Any, Dict
2+
from rejson import __version__
3+
4+
def build(setup_kwargs: Dict[str, Any]) -> None:
5+
setup_kwargs.update({
6+
"zip_safe": False,
7+
"version": __version__
8+
})

pyproject.toml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
[tool.poetry]
2+
name = "rejson"
3+
version = "0.5.4"
4+
description = "RedisJSON Python Client"
5+
authors = ["RedisLabs <[email protected]>"]
6+
license = "BSD-3-Clause"
7+
readme = "README.md"
8+
build = "build.py"
9+
10+
classifiers = [
11+
'Topic :: Database',
12+
'Programming Language :: Python',
13+
'Intended Audience :: Developers',
14+
'Programming Language :: Python :: 3.6',
15+
'Programming Language :: Python :: 3.7',
16+
'Programming Language :: Python :: 3.8',
17+
'Programming Language :: Python :: 3.9',
18+
'License :: OSI Approved :: BSD License',
19+
'Operating System :: OS Independent',
20+
'Development Status :: 5 - Production/Stable'
21+
]
22+
keywords = ["Redis JSON Extension"]
23+
24+
[tool.poetry.dependencies]
25+
python = "^3.6"
26+
redis = "^3.5.3"
27+
six = "^1.16.0"
28+
29+
30+
[tool.poetry.urls]
31+
url = "https://redisjson.io"
32+
repository = "https://github.com/RedisJSON/redisjson-py"
33+
34+
[tool.poetry.dev-dependencies]
35+
codecov = "^2.1.11"
36+
flake8 = "^3.9.2"
37+
tox = "^3.23.1"
38+
tox-poetry = "^0.3.0"
39+
bandit = "^1.7.0"
40+
vulture = "^2.3"
41+
42+
[build-system]
43+
requires = ["poetry-core>=1.0.0"]
44+
build-backend = "poetry.core.masonry.api"

requirements.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 66 deletions
This file was deleted.

tox.ini

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[tox]
2+
skipsdist = True
3+
envlist = linters
4+
5+
[flake8]
6+
max-complexity = 10
7+
ignore = E127,E265,E266,E301,E501
8+
srcdir = rejson
9+
show-source = true
10+
exclude =.git,.tox,dist,doc,*/__pycache__/*,*test*.py
11+
12+
[testenv:cover]
13+
whitelist_externals = find
14+
commands_pre =
15+
find . -type f -name "*.pyc" -delete
16+
setenv =
17+
REDIS_PORT = 6379
18+
commands =
19+
coverage run tests/test_rejson.py
20+
codecov
21+
22+
[testenv:linters]
23+
commands =
24+
# flake8 --show-source
25+
vulture rejson --min-confidence 80
26+
bandit rejson/**

0 commit comments

Comments
 (0)