diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5e56804..1cb739f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,7 +8,7 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: [3.7, 3.8, 3.9, "3.10"] + python-version: ["3.7", "3.8", "3.9", "3.10"] steps: - uses: actions/checkout@v2 @@ -19,9 +19,9 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install tox tox-gh-actions wheel + pip install tox tox-gh-actions build wheel sed -i '/Django==.*/d' ./requirements.txt # delete django dependency - name: Test with tox run: | tox - python setup.py sdist bdist_wheel install + python -m build diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index e66a9cc..4001285 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -14,8 +14,8 @@ jobs: pip install -r requirements.txt pip install coverage pip install -q -e . - python manage.py makemigrations --check --dry-run - coverage run manage.py test + python tests/manage.py makemigrations --check --dry-run + coverage run --source=admin_smoke tests/manage.py test testproject coverage xml - name: Upload coverage to Codecov uses: codecov/codecov-action@v2 diff --git a/.github/workflows/pythonpublish.yml b/.github/workflows/pythonpublish.yml index eda9ad3..97a49fb 100644 --- a/.github/workflows/pythonpublish.yml +++ b/.github/workflows/pythonpublish.yml @@ -20,11 +20,11 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install setuptools wheel twine + pip install build wheel twine - name: Build and publish env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} run: | - python setup.py sdist bdist_wheel + python -m build twine upload dist/* \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..30d8b5b --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,49 @@ +[build-system] +requires = ["setuptools>=61.0", "setuptools-git-versioning"] +build-backend = "setuptools.build_meta" + +[tool.setuptools-git-versioning] +enabled = true + + +[project] +name = "django-image-assets" +dynamic = ["version"] +description = "Django application for image assets management" +readme = "README.md" +authors = [ + { name = "Sergey Tikhonov", email = "zimbler@gmail.com" }, +] + +dependencies = [ + # Django Framework and batteries + "Django>=2.2,<4.2", + "django-bitfield~=2.0", + # Images + "Pillow>=8.1.2,<10.0.0", +] +license = { text = "MIT" } +keywords = [ + "django", + "image", + "assets", +] +classifiers = [ + 'Development Status :: 4 - Beta', + 'Environment :: Console', + 'Framework :: Django :: 3.2', + 'Framework :: Django :: 4.0', + 'Framework :: Django :: 4.1', + 'Operating System :: POSIX', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Topic :: Internet :: WWW/HTTP :: Dynamic Content :: Content Management System', +] + +[project.urls] +homepage = "https://github.com/just-work/django-image-assets" +documentation = "https://github.com/just-work/django-image-assets/blob/master/README.md" +repository = "https://github.com/just-work/django-image-assets.git" +issues = "https://github.com/just-work/django-image-assets/issues" diff --git a/setup.py b/setup.py deleted file mode 100644 index 4af33e9..0000000 --- a/setup.py +++ /dev/null @@ -1,94 +0,0 @@ -import os -import re -import subprocess -from setuptools import setup, find_packages # type: ignore -from pathlib import Path - -with open('README.md') as f: - long_description = f.read() - -version_re = re.compile('^Version: (.+)$', re.M) -package_name = 'django-image-assets' - - -def get_version(): - """ - Reads version from git status or PKG-INFO - - https://gist.github.com/pwithnall/7bc5f320b3bdf418265a - """ - d: Path = Path(__file__).absolute().parent - git_dir = d.joinpath('.git') - if git_dir.is_dir(): - # Get the version using "git describe". - cmd = 'git describe --tags --match [0-9]*'.split() - try: - version = subprocess.check_output(cmd).decode().strip() - except subprocess.CalledProcessError: - return None - - # PEP 386 compatibility - if '-' in version: - version = '.post'.join(version.split('-')[:2]) - - # Don't declare a version "dirty" merely because a time stamp has - # changed. If it is dirty, append a ".dev1" suffix to indicate a - # development revision after the release. - with open(os.devnull, 'w') as fd_devnull: - subprocess.call(['git', 'status'], - stdout=fd_devnull, stderr=fd_devnull) - - cmd = 'git diff-index --name-only HEAD'.split() - try: - dirty = subprocess.check_output(cmd).decode().strip() - except subprocess.CalledProcessError: - return None - - if dirty != '': - version += '.dev1' - else: - # Extract the version from the PKG-INFO file. - try: - with open('PKG-INFO') as v: - version = version_re.search(v.read()).group(1) - except FileNotFoundError: - version = None - - return version - - -setup( - name='django-image-assets', - version=get_version() or 'dev', - long_description=long_description, - long_description_content_type='text/markdown', - packages=find_packages(), - include_package_data=True, - url='https://github.com/just-work/django-image-assets', - license='MIT', - author='Sergey Tikhonov', - author_email='zimbler@gmail.com', - description='Django application for image assets management', - install_requires=[ - 'Django>=2.2,<4.2', - 'Pillow>=8.1.2,<10.0.0', - 'django-bitfield~=2.0', - ], - classifiers=[ - 'Development Status :: 4 - Beta', - 'Environment :: Console', - 'Framework :: Django :: 2.2', - 'Framework :: Django :: 3.0', - 'Framework :: Django :: 3.1', - 'Framework :: Django :: 3.2', - 'Framework :: Django :: 4.0', - 'Framework :: Django :: 4.1', - 'Operating System :: POSIX', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - ('Topic :: Internet :: WWW/HTTP :: Dynamic Content :: ' - 'Content Management System'), - ] -) diff --git a/image_assets/migrations/__init__.py b/src/__init__.py similarity index 100% rename from image_assets/migrations/__init__.py rename to src/__init__.py diff --git a/image_assets/__init__.py b/src/image_assets/__init__.py similarity index 100% rename from image_assets/__init__.py rename to src/image_assets/__init__.py diff --git a/image_assets/admin.py b/src/image_assets/admin.py similarity index 100% rename from image_assets/admin.py rename to src/image_assets/admin.py diff --git a/image_assets/apps.py b/src/image_assets/apps.py similarity index 100% rename from image_assets/apps.py rename to src/image_assets/apps.py diff --git a/image_assets/defaults.py b/src/image_assets/defaults.py similarity index 100% rename from image_assets/defaults.py rename to src/image_assets/defaults.py diff --git a/image_assets/forms.py b/src/image_assets/forms.py similarity index 100% rename from image_assets/forms.py rename to src/image_assets/forms.py diff --git a/image_assets/locale/ru/LC_MESSAGES/django.po b/src/image_assets/locale/ru/LC_MESSAGES/django.po similarity index 100% rename from image_assets/locale/ru/LC_MESSAGES/django.po rename to src/image_assets/locale/ru/LC_MESSAGES/django.po diff --git a/image_assets/migrations/0001_initial.py b/src/image_assets/migrations/0001_initial.py similarity index 99% rename from image_assets/migrations/0001_initial.py rename to src/image_assets/migrations/0001_initial.py index 857a344..f398593 100644 --- a/image_assets/migrations/0001_initial.py +++ b/src/image_assets/migrations/0001_initial.py @@ -2,7 +2,7 @@ from django.db import migrations, models import django.db.models.deletion -import image_assets.models +import image_assets from image_assets import defaults diff --git a/image_assets/migrations/0002_models_localization.py b/src/image_assets/migrations/0002_models_localization.py similarity index 99% rename from image_assets/migrations/0002_models_localization.py rename to src/image_assets/migrations/0002_models_localization.py index a042e6a..91ca3ab 100644 --- a/image_assets/migrations/0002_models_localization.py +++ b/src/image_assets/migrations/0002_models_localization.py @@ -2,7 +2,7 @@ from django.db import migrations, models import django.db.models.deletion -import image_assets.models +import image_assets from image_assets import defaults diff --git a/image_assets/migrations/0003_auto_20200402_0915.py b/src/image_assets/migrations/0003_auto_20200402_0915.py similarity index 100% rename from image_assets/migrations/0003_auto_20200402_0915.py rename to src/image_assets/migrations/0003_auto_20200402_0915.py diff --git a/image_assets/migrations/0004_auto_20200402_0942.py b/src/image_assets/migrations/0004_auto_20200402_0942.py similarity index 100% rename from image_assets/migrations/0004_auto_20200402_0942.py rename to src/image_assets/migrations/0004_auto_20200402_0942.py diff --git a/image_assets/migrations/0005_assettype_formats.py b/src/image_assets/migrations/0005_assettype_formats.py similarity index 100% rename from image_assets/migrations/0005_assettype_formats.py rename to src/image_assets/migrations/0005_assettype_formats.py diff --git a/image_assets/migrations/0006_migrate_formats.py b/src/image_assets/migrations/0006_migrate_formats.py similarity index 100% rename from image_assets/migrations/0006_migrate_formats.py rename to src/image_assets/migrations/0006_migrate_formats.py diff --git a/image_assets/migrations/0007_auto_20200406_1313.py b/src/image_assets/migrations/0007_auto_20200406_1313.py similarity index 97% rename from image_assets/migrations/0007_auto_20200406_1313.py rename to src/image_assets/migrations/0007_auto_20200406_1313.py index 5b832ed..e32cb00 100644 --- a/image_assets/migrations/0007_auto_20200406_1313.py +++ b/src/image_assets/migrations/0007_auto_20200406_1313.py @@ -2,7 +2,7 @@ import bitfield.models from django.db import migrations, models -import image_assets.validators +import image_assets from image_assets import defaults diff --git a/image_assets/migrations/0008_auto_20200528_0725.py b/src/image_assets/migrations/0008_auto_20200528_0725.py similarity index 100% rename from image_assets/migrations/0008_auto_20200528_0725.py rename to src/image_assets/migrations/0008_auto_20200528_0725.py diff --git a/image_assets/tests/__init__.py b/src/image_assets/migrations/__init__.py similarity index 100% rename from image_assets/tests/__init__.py rename to src/image_assets/migrations/__init__.py diff --git a/image_assets/models.py b/src/image_assets/models.py similarity index 100% rename from image_assets/models.py rename to src/image_assets/models.py diff --git a/image_assets/signals.py b/src/image_assets/signals.py similarity index 100% rename from image_assets/signals.py rename to src/image_assets/signals.py diff --git a/testproject/__init__.py b/src/image_assets/tests/__init__.py similarity index 100% rename from testproject/__init__.py rename to src/image_assets/tests/__init__.py diff --git a/image_assets/tests/factories.py b/src/image_assets/tests/factories.py similarity index 100% rename from image_assets/tests/factories.py rename to src/image_assets/tests/factories.py diff --git a/image_assets/tests/mixins.py b/src/image_assets/tests/mixins.py similarity index 100% rename from image_assets/tests/mixins.py rename to src/image_assets/tests/mixins.py diff --git a/image_assets/validators.py b/src/image_assets/validators.py similarity index 100% rename from image_assets/validators.py rename to src/image_assets/validators.py diff --git a/testproject/testapp/__init__.py b/tests/__init__.py similarity index 100% rename from testproject/testapp/__init__.py rename to tests/__init__.py diff --git a/manage.py b/tests/manage.py similarity index 100% rename from manage.py rename to tests/manage.py diff --git a/testproject/testapp/migrations/__init__.py b/tests/testproject/__init__.py similarity index 100% rename from testproject/testapp/migrations/__init__.py rename to tests/testproject/__init__.py diff --git a/testproject/asgi.py b/tests/testproject/asgi.py similarity index 100% rename from testproject/asgi.py rename to tests/testproject/asgi.py diff --git a/testproject/settings.py b/tests/testproject/settings.py similarity index 96% rename from testproject/settings.py rename to tests/testproject/settings.py index ae6a26c..821ef71 100644 --- a/testproject/settings.py +++ b/tests/testproject/settings.py @@ -78,10 +78,12 @@ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + 'NAME': os.path.join(BASE_DIR, '../../db.sqlite3'), } } +DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' + # Password validation # https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators diff --git a/tests/testproject/testapp/__init__.py b/tests/testproject/testapp/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/testproject/testapp/admin.py b/tests/testproject/testapp/admin.py similarity index 100% rename from testproject/testapp/admin.py rename to tests/testproject/testapp/admin.py diff --git a/testproject/testapp/apps.py b/tests/testproject/testapp/apps.py similarity index 100% rename from testproject/testapp/apps.py rename to tests/testproject/testapp/apps.py diff --git a/testproject/testapp/migrations/0001_initial.py b/tests/testproject/testapp/migrations/0001_initial.py similarity index 100% rename from testproject/testapp/migrations/0001_initial.py rename to tests/testproject/testapp/migrations/0001_initial.py diff --git a/tests/testproject/testapp/migrations/__init__.py b/tests/testproject/testapp/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/testproject/testapp/models.py b/tests/testproject/testapp/models.py similarity index 100% rename from testproject/testapp/models.py rename to tests/testproject/testapp/models.py diff --git a/testproject/testapp/tests.py b/tests/testproject/testapp/tests.py similarity index 100% rename from testproject/testapp/tests.py rename to tests/testproject/testapp/tests.py diff --git a/testproject/testapp/views.py b/tests/testproject/testapp/views.py similarity index 100% rename from testproject/testapp/views.py rename to tests/testproject/testapp/views.py diff --git a/testproject/urls.py b/tests/testproject/urls.py similarity index 100% rename from testproject/urls.py rename to tests/testproject/urls.py diff --git a/testproject/wsgi.py b/tests/testproject/wsgi.py similarity index 100% rename from testproject/wsgi.py rename to tests/testproject/wsgi.py diff --git a/tox.ini b/tox.ini index 1962f2f..f465550 100644 --- a/tox.ini +++ b/tox.ini @@ -28,4 +28,6 @@ deps = django3.2: Django~=3.2.0 django4.0: Django~=4.0.0 django4.1: Django~=4.1.0 + +change_dir = tests commands = python manage.py test \ No newline at end of file