-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Store version as plain text file to simplify bumping (#636)
BREAKING CHANGE: Replaced `VERSION` in tuple format by `__version__` as a string
- Loading branch information
1 parent
155445f
commit 6b4bb73
Showing
10 changed files
with
67 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.17.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = [email protected] | ||
maintainer = Sergiy Tereshchenko | ||
maintainer_email = [email protected] | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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='[email protected]', | ||
maintainer='Dirk Eschler', | ||
maintainer_email='[email protected]', | ||
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() |