From 1d7ce33aa27ba56ab4bab480f5dee43a49e12e11 Mon Sep 17 00:00:00 2001 From: Johannes Maron Date: Sat, 19 Mar 2022 11:01:51 +0100 Subject: [PATCH] Update package build tools --- .editorconfig | 2 +- .github/workflows/ci.yml | 23 +++++-------- .gitignore | 1 + pyproject.toml | 71 ++++++++++++++++++++++++++++++++++++++ s3file/__init__.py | 11 +++++- setup.cfg | 74 ++-------------------------------------- setup.py | 4 --- tests/conftest.py | 4 +-- 8 files changed, 96 insertions(+), 94 deletions(-) create mode 100644 pyproject.toml delete mode 100755 setup.py diff --git a/.editorconfig b/.editorconfig index 788f064..ef5f8a5 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,7 +11,7 @@ charset = utf-8 end_of_line = lf max_line_length = 88 -[*.{json,yml,yaml,js,jsx}] +[*.{json,yml,yaml,js,jsx,toml}] indent_size = 2 [LICENSE] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7160444..5054b29 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,9 +12,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/setup-python@v3 - - run: python -m pip install --upgrade pip setuptools wheel twine readme-renderer - uses: actions/checkout@v3 - - run: python setup.py sdist bdist_wheel + - run: python -m build --sdist --wheel - run: python -m twine check dist/* standardjs: @@ -66,13 +65,11 @@ jobs: strategy: matrix: python-version: - - "3.7" - - "3.8" - "3.9" + - "3.10" django-version: - - "2.2" - - "3.1" - "3.2" + - "4.0" steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} @@ -89,12 +86,10 @@ jobs: mkdir bin curl -qO "https://chromedriver.storage.googleapis.com/$(curl -q https://chromedriver.storage.googleapis.com/LATEST_RELEASE)/chromedriver_linux64.zip" unzip chromedriver_linux64.zip -d bin - - name: Upgrade Python setuptools - run: python -m pip install --upgrade pip setuptools wheel codecov - - name: Install Django version ${{ matrix.django-version }} - run: python -m pip install django~=${{ matrix.django-version }} - - name: Run tests - run: PATH=$PATH:$(pwd)/bin python setup.py test - - run: codecov + + - run: python -m pip install .[test] + - run: python -m pip install django~=${{ matrix.django-version }} + - run: python -m pyteset env: - CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}} + PATH: $PATH:$(pwd)/bin + - run: codecov diff --git a/.gitignore b/.gitignore index b106a28..cfb6375 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,7 @@ var/ *.egg-info/ .installed.cfg *.egg +_version.py # PyInstaller # Usually these files are written by a python script from a template diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..06880cc --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,71 @@ +[project] +name = "django-s3file" +authors = [ + { name = "Johannes Maron", email = "johannes@maron.family" } +] +readme = "README.rst" +license = { file = "LICENSE" } +dynamic = ["version", "description"] +classifiers = [ + "Development Status :: 6 - Mature", + "Environment :: Web Environment", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: JavaScript", + "Topic :: Software Development", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Framework :: Django", + "Framework :: Django :: 3.2", + "Framework :: Django :: 4.0", +] +requires-python = ">=3.9" +dependencies = [ + "django>=2.0", + "django-storages", + "boto3", +] + +[project.optional-dependencies] +test = [ + "pytest >=2.7.3", + "pytest-cov", + "pytest-django", + "selenium", +] + +[project.urls] +Project-URL = "https://github.com/codingjoe/django-s3file" + +[build-system] +requires = ["flit_core>=3.2", "flit_scm", "wheel"] +build-backend = "flit_scm:buildapi" + +[tool.flit.module] +name = "s3file" + +[tool.setuptools_scm] +write_to = "s3file/_version.py" + +[tool.pytest.ini_options] +minversion = "6.0" +addopts = "--cov=s3file --cov-report xml --tb=short -rxs" +testpaths = [ + "tests", +] +DJANGO_SETTINGS_MODULE = "tests.testapp.settings" + +[tool.isort] +atomic = true +line_length = 88 +known_first_party = "s3file, tests" +include_trailing_comma = true +default_section = "THIRDPARTY" +combine_as_imports = true + +[tool.pydocstyle] +add_ignore = "D1" diff --git a/s3file/__init__.py b/s3file/__init__.py index 40b3e5d..d3bbc61 100644 --- a/s3file/__init__.py +++ b/s3file/__init__.py @@ -1 +1,10 @@ -default_app_config = "s3file.apps.S3FileConfig" +"""A lightweight file uploader input for Django and Amazon S3.""" + +import django +from . import _version + +__version__ = _version.version +VERSION = _version.version_tuple + +if django.VERSION < (4, 0): + default_app_config = "s3file.apps.S3FileConfig" diff --git a/setup.cfg b/setup.cfg index 46f9260..ecfad47 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,78 +1,8 @@ -[metadata] -name = django-s3file -author = Johannes Hoppe -author_email = info@johanneshoppe.com -description = A lightweight file uploader input for Django and Amazon S3 -long_description = file: README.rst -long_description_content_type = text/x-rst -url = https://github.com/codingjoe/django-s3file -license = MIT -license_files = LICENSE -classifier = - Development Status :: 6 - Mature - Environment :: Web Environment - Framework :: Django - Intended Audience :: Developers - License :: OSI Approved :: MIT License - Operating System :: OS Independent - Programming Language :: Python - Programming Language :: JavaScript - Topic :: Software Development - Programming Language :: Python :: 3 - Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.6 - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Framework :: Django - Framework :: Django :: 2.2 - Framework :: Django :: 3.1 - -[options] -include_package_data = True -packages = find: -install_requires = - django>=2.0 - django-storages - boto3 -setup_requires = - setuptools_scm - pytest-runner -tests_require = - pytest - pytest-cov - pytest-django - selenium - -[options.package_data] -* = *.txt, *.rst, *.html, *.po - -[options.packages.find] -exclude = - tests - -[bdist_wheel] -universal = 1 - -[aliases] -test = pytest - -[tool:pytest] -addopts = --cov=s3file --cov-report xml --tb=short -rxs -DJANGO_SETTINGS_MODULE=tests.testapp.settings - [flake8] max-line-length=88 select = C,E,F,W,B,B950 ignore = E203, E501, W503, E731 -[pydocstyle] -add_ignore = D1 -[isort] -atomic = true -line_length = 88 -known_first_party = s3file, tests -include_trailing_comma = True -default_section=THIRDPARTY -combine_as_imports = true + + diff --git a/setup.py b/setup.py deleted file mode 100755 index 04b296e..0000000 --- a/setup.py +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env python -from setuptools import setup - -setup(name="django-s3file", use_scm_version=True) diff --git a/tests/conftest.py b/tests/conftest.py index 439783d..4bfefd2 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,7 +3,7 @@ import pytest from django.core.files.base import ContentFile -from django.utils.encoding import force_text +from django.utils.encoding import force_str from selenium import webdriver from selenium.common.exceptions import WebDriverException @@ -15,7 +15,7 @@ def driver(): try: b = webdriver.Chrome(options=chrome_options) except WebDriverException as e: - pytest.skip(force_text(e)) + pytest.skip(force_str(e)) else: yield b b.quit()