diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index 256b9478..31f7c82a 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -26,6 +26,23 @@ jobs: run: | flake8 modeltranslation black --check modeltranslation *.py + Install: + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + strategy: + matrix: + python: [3.9] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python }} + - name: Install package + run: | + python -m pip install --upgrade pip + pip install . Test: runs-on: ubuntu-latest strategy: @@ -81,7 +98,7 @@ jobs: if [[ $DB == postgres ]]; then pip install -q psycopg2-binary fi - pip install Pillow coverage six $(./get-django-version.py ${{ matrix.django }}) + pip install coverage six $(./get-django-version.py ${{ matrix.django }}) - name: Run tests run: | coverage run --source=modeltranslation ./runtests.py diff --git a/.versionrc.json b/.versionrc.json index 9eb7cedd..8e15e34f 100644 --- a/.versionrc.json +++ b/.versionrc.json @@ -4,12 +4,8 @@ "repository": "django-modeltranslation", "bumpFiles": [ { - "filename": "PKG-INFO", - "updater": "pkg-info-updater.js" - }, - { - "filename": "modeltranslation/__init__.py", - "updater": "modeltranslation-version-updater.js" + "filename": "modeltranslation/VERSION", + "type": "plain-text" } ] } diff --git a/PKG-INFO b/PKG-INFO deleted file mode 100644 index 588e8fd6..00000000 --- a/PKG-INFO +++ /dev/null @@ -1,25 +0,0 @@ -Metadata-Version: 1.0 -Name: django-modeltranslation -Version: 0.17.7 -Summary: Translates Django models using a registration approach. -Home-page: https://github.com/deschler/django-modeltranslation -Author: Peter Eschler, - Dirk Eschler, - Jacek Tomaszewski -Author-email: "Peter Eschler" , - "Dirk Eschler" , - "Jacek Tomaszewski" -License: New BSD -Description: The modeltranslation application can be used to translate dynamic - content of existing Django models to an arbitrary number of - languages without having to change the original model classes. It - uses a registration approach (comparable to Django's admin app) to - be able to add translations to existing or new projects and is - fully integrated into the Django admin backend. - - The advantage of a registration approach is the ability to add - translations to models on a per-project basis. You can use the - same app in different projects, may they use translations or not, - and you never have to touch the original model class. -Platform: UNKNOWN -Keywords: django translation i18n diff --git a/docs/modeltranslation/conf.py b/docs/modeltranslation/conf.py index 50b7a6de..e83c89c5 100644 --- a/docs/modeltranslation/conf.py +++ b/docs/modeltranslation/conf.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -# # django-modeltranslation documentation build configuration file, created by # sphinx-quickstart on Wed Oct 17 10:26:58 2012. # @@ -22,23 +20,13 @@ # The version info for the project you're documenting, acts as replacement # for |version| and |release|, also used in various other places throughout # the built documents. - # - # The short X.Y version (e.g.'0.5'). - version = '.'.join(str(i) for i in modeltranslation.VERSION[:2]) + # The full PEP386-compliant version number version, including # normalized alpha/beta/rc/dev tags (e.g. '0.5a1'). - try: - # FIXME: Can we make this work on services like read-the-docs? - # The build script on rtf bails out early with: - # - # Failed to import project; skipping build. - # Please make sure your repo is correct and you have a conf.py - # - release = modeltranslation.get_version() - except: - # We are broad here with the exception handling because we don't know - # the environment we build on. - release = version + release = modeltranslation.__version__ + + # The short X.Y version (e.g.'0.5'). + version = '.'.join(i for i in release.split('.')[:2]) except ImportError: version = 'dev' release = 'dev' diff --git a/modeltranslation-version-updater.js b/modeltranslation-version-updater.js deleted file mode 100644 index 3c5bc6c5..00000000 --- a/modeltranslation-version-updater.js +++ /dev/null @@ -1,15 +0,0 @@ -const VERSION_REGEX = /^VERSION = \((?\d+), (?\d+), (?\d+), '(?\w+)', (?\d+)\)$/m; -const NEW_VERSION_REGEX = /(?\d+).(?\d+).(?\d+)(-(?\w+).(?\d+))?/; - -module.exports.readVersion = function (contents) { - let v = contents.match(VERSION_REGEX).groups; - let version = `${v.major}.${v.minor}.${v.patch}`; - if (v.tag == "final") - return version; - return version + `-${v.tag}.${v.tagVer}`; -} - -module.exports.writeVersion = function (contents, version) { - let v = version.match(NEW_VERSION_REGEX).groups; - return contents.replace(VERSION_REGEX, `VERSION = (${v.major}, ${v.minor}, ${v.patch}, '${v.tag || 'final'}', ${v.tagVer || 0})`); -} diff --git a/modeltranslation/VERSION b/modeltranslation/VERSION new file mode 100644 index 00000000..79394953 --- /dev/null +++ b/modeltranslation/VERSION @@ -0,0 +1 @@ +0.17.7 diff --git a/modeltranslation/__init__.py b/modeltranslation/__init__.py index 61f0e78b..d743c065 100644 --- a/modeltranslation/__init__.py +++ b/modeltranslation/__init__.py @@ -1,71 +1,5 @@ -# -*- coding: utf-8 -*- -""" -Version code adopted from Django development version. -https://github.com/django/django -""" +from pathlib import Path -VERSION = (0, 17, 7, 'final', 0) +__version__ = (Path(__file__).parent / "VERSION").open().read().strip() default_app_config = 'modeltranslation.apps.ModeltranslationConfig' - - -def get_version(version=None): - """ - Returns a PEP 386-compliant version number from VERSION. - """ - if version is None: - from modeltranslation import VERSION as version - else: - assert len(version) == 5 - assert version[3] in ('alpha', 'beta', 'rc', 'final') - - # Now build the two parts of the version number: - # main = X.Y[.Z] - # sub = .devN - for pre-alpha releases - # | {a|b|c}N - for alpha, beta and rc releases - - parts = 2 if version[2] == 0 else 3 - main = '.'.join(str(x) for x in version[:parts]) - - sub = '' - if version[3] == 'alpha' and version[4] == 0: - git_changeset = get_git_changeset() - if git_changeset: - sub = '.dev%s' % git_changeset - - elif version[3] != 'final': - mapping = {'alpha': 'a', 'beta': 'b', 'rc': 'rc'} - sub = mapping[version[3]] + str(version[4]) - - return str(main + sub) - - -def get_git_changeset(): - """ - Returns a numeric identifier of the latest git changeset. - - The result is the UTC timestamp of the changeset in YYYYMMDDHHMMSS format. - This value isn't guaranteed to be unique, but collisions are very unlikely, - so it's sufficient for generating the development version numbers. - - TODO: Check if we can rely on services like read-the-docs to pick this up. - """ - import datetime - import os - import subprocess - - repo_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - git_log = subprocess.Popen( - 'git log --pretty=format:%ct --quiet -1 HEAD', - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - shell=True, - cwd=repo_dir, - universal_newlines=True, - ) - timestamp = git_log.communicate()[0] - try: - timestamp = datetime.datetime.utcfromtimestamp(int(timestamp)) - except ValueError: - return None - return timestamp.strftime('%Y%m%d%H%M%S') diff --git a/pkg-info-updater.js b/pkg-info-updater.js deleted file mode 100644 index a13508a5..00000000 --- a/pkg-info-updater.js +++ /dev/null @@ -1,9 +0,0 @@ -const VERSION_REGEX = /^Version: (.*)$/m; - -module.exports.readVersion = function (contents) { - return contents.match(VERSION_REGEX)[1]; -} - -module.exports.writeVersion = function (contents, version) { - return contents.replace(VERSION_REGEX, `Version: ${version}`); -} diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..4a755328 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,35 @@ +[metadata] +name = django-modeltranslation +version = attr:modeltranslation.__version__ +description = Translates Django models using a registration approach. +long_description = file:README.rst +long_description_content_type = text/x-rst +author = Peter Eschler +author_email = peschler@gmail.com +maintainer = Sergiy Tereshchenko +maintainer_email = serg.partizan+modeltranslation@gmail.com +url = https://github.com/deschler/django-modeltranslation +classifiers = + Programming Language :: Python + Programming Language :: Python :: 3.6 + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Operating System :: OS Independent + Environment :: Web Environment + Intended Audience :: Developers + Framework :: Django + License :: OSI Approved :: BSD License +license = New BSD +[options] +install_requires = + Django>=2.2 + six +packages = + modeltranslation + modeltranslation.management + modeltranslation.management.commands +[options.package_data] +modeltranslation = + static/modeltranslation/css/*.css + static/modeltranslation/js/*.js diff --git a/setup.py b/setup.py index 32e67475..28c58a65 100755 --- a/setup.py +++ b/setup.py @@ -1,53 +1,8 @@ #!/usr/bin/env python +import pkg_resources from setuptools import setup -# Dynamically calculate the version based on modeltranslation.VERSION. -version = __import__('modeltranslation').get_version() +# (1) check required versions (from https://medium.com/@daveshawley/safely-using-setup-cfg-for-metadata-1babbe54c108) +pkg_resources.require("setuptools>=39.2") - -setup( - name='django-modeltranslation', - version=version, - description='Translates Django models using a registration approach.', - long_description=( - 'The modeltranslation application can be used to translate dynamic ' - 'content of existing models to an arbitrary number of languages ' - 'without having to change the original model classes. It uses a ' - 'registration approach (comparable to Django\'s admin app) to be able ' - 'to add translations to existing or new projects and is fully ' - 'integrated into the Django admin backend.' - ), - author='Peter Eschler', - author_email='peschler@gmail.com', - maintainer='Dirk Eschler', - maintainer_email='eschler@gmail.com', - url='https://github.com/deschler/django-modeltranslation', - packages=[ - 'modeltranslation', - 'modeltranslation.management', - 'modeltranslation.management.commands', - ], - package_data={ - 'modeltranslation': [ - 'static/modeltranslation/css/*.css', - 'static/modeltranslation/js/*.js', - ] - }, - install_requires=['Django>=2.2', 'six'], - download_url=( - 'https://github.com/deschler/django-modeltranslation/archive/%s.tar.gz' % version - ), - classifiers=[ - 'Programming Language :: Python', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Operating System :: OS Independent', - 'Environment :: Web Environment', - 'Intended Audience :: Developers', - 'Framework :: Django', - 'License :: OSI Approved :: BSD License', - ], - license='New BSD', -) +setup()