Skip to content

Commit d4f9b5b

Browse files
authored
Merge pull request kimetrica#62 from kimetrica/enable_py312_django50
Enable Python 3.12 and Django 5.x
2 parents cab9b3c + 2d88159 commit d4f9b5b

18 files changed

+98
-40
lines changed

.github/workflows/test.yml

+6-5
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,20 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
12+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
1313

1414
steps:
15-
- uses: actions/checkout@v1
15+
- uses: actions/checkout@v4
1616
- name: Set up Python ${{ matrix.python-version }}
17-
uses: actions/setup-python@v2
17+
uses: actions/setup-python@v5
1818
with:
1919
python-version: ${{ matrix.python-version }}
2020
- name: Install dependencies
2121
run: |
2222
python -m pip install --upgrade pip
23-
pip install tox tox-gh-actions flake8 black
23+
pip install tox tox-gh-actions black==22.12.0 isort==5.12.0 ruff==0.0.270
24+
2425
- name: Lint
25-
run: ./pep8.sh
26+
run: ./lint.sh
2627
- name: Test with tox
2728
run: tox

README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Django Binary Database Files
22
============================
33

4-
[![](https://img.shields.io/pypi/v/django-binary-database-files.svg)](https://pypi.python.org/pypi/django-binary-database-files) [![Build Status](https://img.shields.io/travis/kimetrica/django-binary-database-files.svg?branch=master)](https://travis-ci.org/kimetrica/django-binary-database-files/) [![](https://pyup.io/repos/github/kimetrica/django-binary-database-files/shield.svg)](https://pyup.io/repos/github/kimetrica/django-binary-database-files)
4+
[![](https://img.shields.io/pypi/v/django-binary-database-files.svg)](https://pypi.python.org/pypi/django-binary-database-files) [![Build Status](https://github.com/Kimetrica/django-binary-database-files/actions/workflows/test.yml/badge.svg)](https://github.com/kimetrica/django-binary-database-files/actions) [![](https://pyup.io/repos/github/kimetrica/django-binary-database-files/shield.svg)](https://pyup.io/repos/github/kimetrica/django-binary-database-files)
55

66
This is a storage system for Django that stores uploaded
77
files in binary fields in the database. Files can be served from the database
@@ -95,27 +95,27 @@ Development
9595

9696
Code should be linted with:
9797

98-
./pep8.sh
98+
./lint.sh
9999

100100
Tests require the Python development headers to be installed, which you can install on Ubuntu with:
101101

102-
sudo apt-get install python3-dev python3.6-dev
102+
sudo apt-get install python3.12-minimal python3.12-dev
103103

104104
To run unittests across multiple Python versions, install:
105105

106-
sudo apt-get install python3.6-minimal python3.6-dev python3.7-minimal python3.7-dev
106+
sudo apt-get install python3.10-minimal python3.10-dev python3.11-minimal python3.11-dev python3.12-minimal python3.12-dev
107107

108108
To run all [tests](http://tox.readthedocs.org/en/latest/):
109109

110110
export TESTNAME=; tox
111111

112-
To run tests for a specific environment (e.g. Python 3.6 with Django 2.2):
112+
To run tests for a specific environment (e.g. Python 3.12 with Django 5.0):
113113

114-
export TESTNAME=; tox -e py36-django22
114+
export TESTNAME=; tox -e py312-django50
115115

116116
To run a specific test:
117117

118-
export TESTNAME=.test_adding_file; tox -e py36-django22
118+
export TESTNAME=.test_adding_file; tox -e py312-django50
119119

120120
To build and deploy a versioned package to PyPI, verify [all unittests are passing](https://travis-ci.com/kimetrica/django-binary-database-files/), then increase (and commit) the version number in `binary_database_files/__init__.py` and then run:
121121

binary_database_files/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION = (1, 0, 17)
1+
VERSION = (1, 0, 18)
22
__version__ = ".".join(map(str, VERSION))
33

44
default_app_config = "binary_database_files.apps.DatabaseFilesAppConfig"

binary_database_files/management/commands/database_files_cleanup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
from django.apps import apps
12
from django.conf import settings
23
from django.core.files.storage import default_storage
34
from django.core.management.base import BaseCommand
45
from django.db.models import FileField, ImageField
5-
from django.apps import apps
66

77
from binary_database_files.models import File
88

binary_database_files/management/commands/database_files_load.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import os
22

3+
from django.apps import apps
34
from django.conf import settings
45
from django.core.management.base import BaseCommand
56
from django.db.models import FileField, ImageField
6-
from django.apps import apps
77

88

99
class Command(BaseCommand):

binary_database_files/migrations/0001_initial.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Generated by Django 1.9.1 on 2016-10-11 18:11
2-
from django.db import migrations, models
32
import django.utils.timezone
3+
from django.db import migrations, models
44

55

66
class Migration(migrations.Migration):

binary_database_files/models.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
from django.conf import settings
22
from django.db import models
3-
from django.utils import timezone
4-
53
from django.db.models import BinaryField
4+
from django.utils import timezone
65

76
from binary_database_files import utils
8-
from binary_database_files.utils import write_file, is_fresh
97
from binary_database_files.manager import FileManager
8+
from binary_database_files.utils import is_fresh, write_file
109

1110

1211
class File(models.Model):

binary_database_files/storage.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
"""Custom storage backend that stores files in the database to facilitate scaling."""
22
import os
3-
from io import UnsupportedOperation, BytesIO
3+
from io import BytesIO, UnsupportedOperation
44

55
from django.conf import settings
66
from django.core import files
77
from django.core.files.storage import FileSystemStorage
88
from django.utils._os import safe_join
99

1010
from binary_database_files import models
11-
from binary_database_files import utils
1211
from binary_database_files import settings as _settings
12+
from binary_database_files import utils
1313

1414

1515
class DatabaseFile(files.File):

binary_database_files/tests/tests.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1+
import base64
12
import functools
23
import os
34
import shutil
45
import tempfile
5-
import base64
66
from io import BytesIO
77
from zipfile import ZipFile
88

99
from django.conf import settings
1010
from django.core import files
1111
from django.core.files import File as DjangoFile
12+
from django.core.files.base import ContentFile
1213
from django.core.files.storage import default_storage
1314
from django.core.files.temp import NamedTemporaryFile
1415
from django.core.management import call_command
1516
from django.db import models
1617
from django.test import TestCase, override_settings
17-
from django.core.files.base import ContentFile
1818

19+
from binary_database_files import utils
1920
from binary_database_files.models import File
2021
from binary_database_files.storage import DatabaseStorage
2122
from binary_database_files.tests.models import Thing
22-
from binary_database_files import utils
2323

2424
DIR = os.path.abspath(os.path.split(__file__)[0])
2525

binary_database_files/urls.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from django.urls import re_path
2+
23
from binary_database_files import views
34

45
urlpatterns = [

binary_database_files/utils.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import os
21
import hashlib
2+
import os
33

44
from django.conf import settings
5+
56
from binary_database_files import settings as _settings
67

78

binary_database_files/views.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
from django.views.decorators.cache import cache_control
77
from django.views.static import serve as django_serve
88

9-
from binary_database_files.models import File
109
from binary_database_files import settings as _settings
10+
from binary_database_files.models import File
1111

1212

1313
@cache_control(max_age=86400)

lint.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
ruff binary_database_files
3+
black --check binary_database_files
4+
isort --check binary_database_files

pep8.sh

-3
This file was deleted.

pip-requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Django>=2.2,<5
1+
Django>=2.2,<6

pyproject.toml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
[tool.ruff]
2+
line-length = 119 # Allow longer lines for ruff than black and isort, for comments and docstrings
3+
target-version = 'py310'
4+
exclude = [
5+
'.eggs', # exclude a few common directories in the
6+
'.git', # root of the project
7+
'.history',
8+
'.hg',
9+
'.mypy_cache',
10+
'.tox',
11+
'.venv',
12+
'_build',
13+
'migrations',
14+
'node_modules',
15+
'buck-out',
16+
'build',
17+
'builds',
18+
'dist',
19+
]
20+
21+
[tool.ruff.mccabe]
22+
# Unlike Flake8, default to a complexity level of 10.
23+
max-complexity = 10
24+
25+
[tool.ruff.flake8-quotes]
26+
docstring-quotes = "double"
27+
28+
[tool.black]
29+
line-length = 88
30+
target-version = ['py310']
31+
include = '\.pyi?$'
32+
exclude = '''
33+
(
34+
/(
35+
\.eggs # exclude a few common directories in the
36+
| \.git # root of the project
37+
| \.history
38+
| \.hg
39+
| \.mypy_cache
40+
| .ruff_cache
41+
| \.tox
42+
| \.venv
43+
| _build
44+
| node_modules
45+
| buck-out
46+
| build
47+
| dist
48+
)/
49+
)
50+
'''
51+
52+
[tool.isort]
53+
profile = "black"
54+
src_paths = ["binary_database_files"]
55+
line_length = 88

setup.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/usr/bin/env python
22
import io
33
import os
4-
from setuptools import setup, find_packages
4+
5+
from setuptools import find_packages, setup
56

67
import binary_database_files
78

@@ -46,21 +47,21 @@ def get_reqs(*fns):
4647
"License :: OSI Approved :: BSD License",
4748
"Operating System :: OS Independent",
4849
"Programming Language :: Python",
49-
"Programming Language :: Python :: 3.6",
50-
"Programming Language :: Python :: 3.7",
5150
"Programming Language :: Python :: 3.8",
5251
"Programming Language :: Python :: 3.9",
5352
"Programming Language :: Python :: 3.10",
5453
"Programming Language :: Python :: 3.11",
54+
"Programming Language :: Python :: 3.12",
5555
"Framework :: Django :: 2.2",
5656
"Framework :: Django :: 3.0",
5757
"Framework :: Django :: 3.1",
5858
"Framework :: Django :: 3.2",
5959
"Framework :: Django :: 4.0",
60+
"Framework :: Django :: 5.0",
6061
],
6162
install_requires=get_reqs(
6263
"pip-requirements.txt",
6364
),
6465
tests_require=get_reqs("pip-requirements-test.txt"),
65-
python_requires=">=3.6,<3.12",
66+
python_requires=">=3.6,<3.13",
6667
)

tox.ini

+5-6
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,30 @@ ignore = W503, E203 # See https://github.com/PyCQA/pycodestyle/issues/373
44
max-line-length=160
55

66
[tox]
7-
envlist = py{36,37}-django{22},py{36,37,38}-django{30},py{36,37,38,39,310,311}-django{31},py{36,37,38,39,310,311}-django{32},py{38,39,310,311}-django{40}
7+
envlist = py{38,39,310,311,312}-django{32,40},py{310,311,312}-django{50}
88
recreate = True
99

1010
[gh-actions]
1111
python =
12-
3.6: py36
13-
3.7: py37
1412
3.8: py38
1513
3.9: py39
1614
3.10: py310
1715
3.11: py311
16+
3.12: py312
1817

1918
[testenv]
2019
basepython =
21-
py36: python3.6
22-
py37: python3.7
2320
py38: python3.8
2421
py39: python3.9
2522
py310: python3.10
2623
py311: python3.11
24+
py312: python3.12
2725
deps =
2826
-r{toxinidir}/pip-requirements-test.txt
2927
django22: Django>=2.2,<2.3
3028
django30: Django>=3.0,<3.1
3129
django31: Django>=3.1,<3.2
3230
django32: Django>=3.2,<3.3
33-
django40: Django>=4.0,<4.1
31+
django40: Django>=4.0,<5.0
32+
django50: Django>=5.0,<6.0
3433
commands = django-admin test --traceback --pythonpath=. --settings=binary_database_files.tests.settings binary_database_files.tests.tests.DatabaseFilesTestCase{env:TESTNAME:}

0 commit comments

Comments
 (0)