Skip to content

Commit

Permalink
Merge pull request #2 from irtazaakram/upgrade
Browse files Browse the repository at this point in the history
Add support for official Python & Django versions
  • Loading branch information
jpic authored Apr 28, 2024
2 parents c04fb4f + ae6ed13 commit 1fef064
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 95 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: ci

on: [push, pull_request]

jobs:
build:
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9, "3.10", "3.11"]
services:
postgres:
image: postgres:latest
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions
- name: Run Tests
run: tox
10 changes: 0 additions & 10 deletions .gitlab-ci.yml

This file was deleted.

25 changes: 0 additions & 25 deletions .travis.yml

This file was deleted.

10 changes: 10 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
Changelog
=========

master
------

- Add support for Django 3.2, 4.1 & 4.2
- Add support for Python 3.8, 3.9, 3.10 & 3.11
- Drop support for Django 1.11, 2.1, 2.2 & 3.0
- Drop support for Python 2.7, 3.5, 3.6 & 3.7
- Shifted CI from travis/gitlab to github actions


0.8.0
-----

Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ versions) and generate a coverage report in the ``htmlcov/`` directory::

make test

This requires that you have ``python2.7``, ``python3.3``, ``python3.4``,
``pypy``, and ``pypy3`` binaries on your system's shell path.
This requires that you have ``python3.8``, ``python3.9``, ``python3.10``,
and ``python3.11`` binaries on your system's shell path.

To install PostgreSQL on Debian-based systems::

Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = 'en'

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
Expand Down
4 changes: 2 additions & 2 deletions fernet_fields/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.utils.encoding import force_bytes
from django.utils.functional import cached_property

from .utils import force_text
from django.utils.encoding import force_str
from . import hkdf


Expand Down Expand Up @@ -77,7 +77,7 @@ def get_db_prep_save(self, value, connection):
def from_db_value(self, value, expression, connection, *args):
if value is not None:
value = bytes(value)
return self.to_python(force_text(self.fernet.decrypt(value)))
return self.to_python(force_str(self.fernet.decrypt(value)))

@cached_property
def validators(self):
Expand Down
11 changes: 4 additions & 7 deletions fernet_fields/test/settings/pg.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
from .base import * # noqa

import platform

if platform.python_implementation() == 'PyPy':
from psycopg2cffi import compat
compat.register()


DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
# matches travis config
# matches github actions config
'NAME': 'djftest',
'USER': 'postgres',
'PASSWORD': 'postgres',
'HOST': 'localhost',
'TEST': {
'NAME': 'djftest',
},
Expand Down
4 changes: 2 additions & 2 deletions fernet_fields/test/test_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from django.utils.encoding import force_bytes

import fernet_fields as fields
from fernet_fields.utils import force_text
from django.utils.encoding import force_str

from . import models

Expand Down Expand Up @@ -82,7 +82,7 @@ def test_insert(self, db, model, vals):
with connection.cursor() as cur:
cur.execute('SELECT value FROM %s' % model._meta.db_table)
data = [
force_text(field.fernet.decrypt(force_bytes(r[0])))
force_str(field.fernet.decrypt(force_bytes(r[0])))
for r in cur.fetchall()
]

Expand Down
7 changes: 0 additions & 7 deletions fernet_fields/utils.py

This file was deleted.

25 changes: 10 additions & 15 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
# Requirements for running djfernet tests

Django>=1.11

cryptography>=0.9

tox>=2.0.1
pytest-django>=2.8.0
pytest>=2.7.3
coverage>=3.7.1

psycopg2>=2.7
psycopg2cffi>=2.6.1

Sphinx>=1.3.1

flake8>=2.4.1
Django>=3.2

cryptography
tox
pytest-django
pytest
coverage
psycopg2
Sphinx
flake8
19 changes: 18 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,30 @@
name='djfernet',
versioning='dev',
setup_requires='setupmeta',
install_requires=['cryptography'],
install_requires=[
'cryptography',
"Django>=3.2"
],
author='James Pic',
author_email='[email protected]',
url='https://yourlabs.io/oss/djfernet',
include_package_data=True,
license='MIT',
keywords='fernet cryptography django',
classifiers=[
"Environment :: Web Environment",
"Framework :: Django",
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.1",
"Framework :: Django :: 4.2",
"Intended Audience :: Developers",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11"
],
python_requires='>=3.8',
packages=['fernet_fields'],
)
43 changes: 20 additions & 23 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,46 +1,43 @@
[tox]
envlist =
py36-{docs,flake8},
py{27,35,36,37,py}-django111-{pg,sqlite},
py{35,36,37}-{django21,django22,django30,djangolatest}-{pg,sqlite},
flake8,
py{38,39,310}-django{32}-{pg,sqlite}
py{38,39,310,311}-django{41,42}-{pg,sqlite}
py{311}-{docs,flake8}
flake8
docs

[gh-actions]
python =
3.8: py38
3.9: py39
3.10: py310
3.11: py311

[testenv]
deps =
-crequirements.txt
cryptography
pytest-django
pytest
coverage

psycopg2
psycopg2cffi

django111: Django>=1.11,<2
django21: Django>=2.1,<2.2
django22: Django>=2.2,<2.3
django30: Django>=3.0,<3.1
djangolatest: Django>=3.0

# Older PyPy versions (and all released PyPy3 versions) don't work with cryptography 1.0
py{py,py3}: cryptography<1
-rrequirements.txt
django32: Django>=3.2,<4.0
django41: Django>=4.1,<4.2
django42: Django>=4.2,<5.0
setenv =
sqlite: DJANGO_SETTINGS_MODULE = fernet_fields.test.settings.sqlite
pg: DJANGO_SETTINGS_MODULE = fernet_fields.test.settings.pg
allowlist_externals =
coverage
commands =
coverage run -a runtests.py fernet_fields/test --tb short

[testenv:py36-flake8]
[testenv:py311-flake8]
deps = flake8
changedir = {toxinidir}
commands = flake8 .

[testenv:py36-docs]
[testenv:py311-docs]
deps = Sphinx
changedir = {toxinidir}/doc
commands =
sphinx-build -aEWq -b html . _build/html

[flake8]
exclude = .tox,.git,__pycache__,doc/conf.py
max-line-length = 100

0 comments on commit 1fef064

Please sign in to comment.