diff --git a/.editorconfig b/.editorconfig index f69b8ec1..d7e0de91 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,7 +10,7 @@ insert_final_newline = true charset = utf-8 end_of_line = lf -[*.{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 042d813a..bc44000f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,8 +34,8 @@ jobs: - uses: actions/setup-python@v4 with: python-version: "3.x" - - run: python -m pip install --upgrade pip setuptools wheel twine readme-renderer - - run: python setup.py sdist bdist_wheel + - run: python -m pip install --upgrade pip build wheel twine readme-renderer + - run: python -m build --sdist --wheel - run: python -m twine check dist/* standardjs: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f8e3b587..f6548af4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,6 +28,7 @@ jobs: - uses: actions/setup-python@v4 with: python-version: "3.x" + - run: python -m pip install --upgrade setuptools_scm - run: python set_version.py - name: Upload packages run: npm publish diff --git a/.gitignore b/.gitignore index d1ef58f6..8c43d48c 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,5 @@ ghostdriver.log coverage.xml .eggs/ db.sqlite3 + +_version.py diff --git a/LICENSE b/LICENSE index d5d8ec80..3f28e2b7 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017 Johannes Hoppe +Copyright (c) 2022 Johannes Maron Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/django_select2/__init__.py b/django_select2/__init__.py index 575a0213..95783ce7 100644 --- a/django_select2/__init__.py +++ b/django_select2/__init__.py @@ -9,5 +9,10 @@ """ from django import get_version +from . import _version + +__version__ = _version.version +VERSION = _version.version_tuple + if get_version() < "3.2": default_app_config = "django_select2.apps.Select2AppConfig" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..1d4fb2f5 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,89 @@ +[build-system] +requires = ["flit_core>=3.2", "flit_scm", "wheel"] +build-backend = "flit_scm:buildapi" + +[project] +name = "django-select2" +authors = [ + { name = "Johannes Maron", email = "johannes@maron.family" }, +] +readme = "README.rst" +license = { file = "LICENSE" } +keywords = ["Django", "select2", "autocomplete", "typeahead"] +dynamic = ["version", "description"] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "License :: OSI Approved :: MIT License", + "Intended Audience :: Developers", + "Environment :: Web Environment", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Framework :: Django", + "Framework :: Django :: 3.2", + "Framework :: Django :: 4.0", + "Framework :: Django :: 4.1", + "Topic :: Software Development", +] +requires-python = ">=3.8" +dependencies = [ + "django>=3.2", + "django-appconf>=0.6.0" +] + +[project.optional-dependencies] +test = [ + "pytest", + "pytest-cov", + "pytest-django", + "selenium", +] +selenium = [ + "selenium", +] +docs = [ + "sphinx", +] + +[project.urls] +Project-URL = "https://github.com/codingjoe/django-select2" +Changelog = "https://github.com/codingjoe/django-select2/releases" +Source = "https://github.com/codingjoe/django-select2" +Documentation = "https://django-select2.rtfd.io/" +Issue-Tracker = "https://github.com/codingjoe/django-select2/issues" + +[tool.flit.module] +name = "django_select2" + +[tool.setuptools_scm] +write_to = "django_select2/_version.py" + +[tool.pytest.ini_options] +minversion = "6.0" +addopts = "--cov --tb=short -rxs" +testpaths = ["tests"] +DJANGO_SETTINGS_MODULE = "tests.testapp.settings" + +[tool.coverage.run] +source = ["django_select2"] + +[tool.coverage.report] +show_missing = true + +[tool.isort] +atomic = true +line_length = 88 +multi_line_output = 3 +include_trailing_comma = true +force_grid_wrap = 0 +use_parentheses = true +known_first_party = "django_select2, tests" +default_section = "THIRDPARTY" +combine_as_imports = true + +[tool.pydocstyle] +add_ignore = "D1" diff --git a/set_version.py b/set_version.py index 50ffa7bf..fa18ce33 100755 --- a/set_version.py +++ b/set_version.py @@ -1,12 +1,13 @@ #!/usr/bin/env python3 """Set the version in NPM's package.json to match the git tag.""" import json -import os + +from setuptools_scm import get_version if __name__ == "__main__": with open("package.json", "r+") as f: data = json.load(f) f.seek(0) - data["version"] = os.environ["GITHUB_REF"].rsplit("/")[-1] + data["version"] = get_version(root=".", relative_to=__file__) json.dump(data, f) f.truncate() diff --git a/setup.cfg b/setup.cfg index f02b95dc..6f60592c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,87 +1,4 @@ -[metadata] -name = django-select2 -author = Johannes Hoppe -author_email = info@johanneshoppe.com -description = Select2 option fields for Django -long_description = file: README.rst -url = https://github.com/codingjoe/django-select2 -license = MIT -license_file = LICENSE -classifier = - Development Status :: 5 - Production/Stable - Environment :: Web Environment - Intended Audience :: Developers - License :: OSI Approved :: Apache Software License - Operating System :: OS Independent - Programming Language :: Python - Programming Language :: Python :: 3 - Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Framework :: Django - Framework :: Django :: 3.2 - Framework :: Django :: 4.0 - Framework :: Django :: 4.1 - -[options] -include_package_data = True -packages = django_select2 -install_requires = - django>=3.2 - django-appconf>=0.6.0 -setup_requires = - setuptools_scm - -[options.extras_require] -test = - pytest - pytest-cov - pytest-django - selenium -selenium = - selenium -docs = - sphinx - -[bdist_wheel] -universal = 1 - -[bdist_rpm] -requires = - python-django-appconf >= 2.0 - -[aliases] -test = pytest - -[build_sphinx] -source-dir = docs -build-dir = docs/_build - -[tool:pytest] -addopts = - tests - --doctest-glob='*.rst' - --doctest-modules - --cov=django_select2 -DJANGO_SETTINGS_MODULE=tests.testapp.settings - [flake8] max-line-length=88 select = C,E,F,W,B,B950 -ignore = E203, E501, W503 -exclude = venv,.tox,.eggs - -[pydocstyle] -add-ignore = D1 - -[isort] -atomic = true -line_length = 88 -multi_line_output = 3 -include_trailing_comma = True -force_grid_wrap = 0 -use_parentheses = True -known_first_party = django_select2, tests -default_section = THIRDPARTY -combine_as_imports = true +ignore = E203, E501, W503, E731 diff --git a/setup.py b/setup.py deleted file mode 100755 index f4bd8e57..00000000 --- a/setup.py +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env python - -from setuptools import setup - -setup(name="django-select2", use_scm_version=True)