mirror of
https://github.com/Hopiu/django-modeltranslation.git
synced 2026-05-11 14:53:09 +00:00
Central definition of version in module's __init__.py. The version is reused by setup.py and sphinx.
This commit is contained in:
parent
08a9683ae1
commit
6ad3e839aa
3 changed files with 88 additions and 26 deletions
|
|
@ -3,7 +3,8 @@
|
|||
# django-modeltranslation documentation build configuration file, created by
|
||||
# sphinx-quickstart on Wed Oct 17 10:26:58 2012.
|
||||
#
|
||||
# This file is execfile()d with the current directory set to its containing dir.
|
||||
# This file is execfile()d with the current directory set to its containing
|
||||
# dir.
|
||||
#
|
||||
# Note that not all possible configuration values are present in this
|
||||
# autogenerated file.
|
||||
|
|
@ -11,20 +12,41 @@
|
|||
# All configuration values have a default; values that are commented out
|
||||
# serve to show the default.
|
||||
|
||||
import sys, os
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, os.path.abspath(os.path.join(
|
||||
os.path.dirname(__file__), '../..')))
|
||||
|
||||
try:
|
||||
import modeltranslation
|
||||
# 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.
|
||||
#version = '0.4'
|
||||
version = modeltranslation.get_version(pep386=False, short=True)
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
#release = '0.4.0-rc1'
|
||||
release = modeltranslation.get_version(pep386=False)
|
||||
except ImportError:
|
||||
version = 'dev'
|
||||
release = 'dev'
|
||||
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
# -- General configuration -----------------------------------------------------
|
||||
# -- General configuration ----------------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
needs_sphinx = '1.0'
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be extensions
|
||||
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.todo']
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
|
|
@ -43,15 +65,6 @@ master_doc = 'index'
|
|||
project = u'django-modeltranslation'
|
||||
copyright = u'2009-2012, Peter Eschler, Dirk Eschler'
|
||||
|
||||
# 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.
|
||||
version = '0.4'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '0.4.0-beta2'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
#language = None
|
||||
|
|
@ -66,7 +79,8 @@ release = '0.4.0-beta2'
|
|||
# directories to ignore when looking for source files.
|
||||
exclude_patterns = ['_build']
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all documents.
|
||||
# The reST default role (used for this markup: `text`) to use for all
|
||||
# documents.
|
||||
#default_role = None
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
|
|
@ -91,7 +105,7 @@ pygments_style = 'sphinx'
|
|||
todo_include_todos = True
|
||||
|
||||
|
||||
# -- Options for HTML output ---------------------------------------------------
|
||||
# -- Options for HTML output --------------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
|
|
@ -171,7 +185,7 @@ html_static_path = ['_static']
|
|||
htmlhelp_basename = 'django-modeltranslationdoc'
|
||||
|
||||
|
||||
# -- Options for LaTeX output --------------------------------------------------
|
||||
# -- Options for LaTeX output -------------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
|
|
@ -187,7 +201,8 @@ latex_elements = {
|
|||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title, author, documentclass [howto/manual]).
|
||||
latex_documents = [
|
||||
('index', 'django-modeltranslation.tex', u'django-modeltranslation Documentation',
|
||||
('index', 'django-modeltranslation.tex',
|
||||
u'django-modeltranslation Documentation',
|
||||
u'Dirk Eschler', 'manual'),
|
||||
]
|
||||
|
||||
|
|
@ -212,12 +227,13 @@ latex_documents = [
|
|||
#latex_domain_indices = True
|
||||
|
||||
|
||||
# -- Options for manual page output --------------------------------------------
|
||||
# -- Options for manual page output -------------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
('index', 'django-modeltranslation', u'django-modeltranslation Documentation',
|
||||
('index', 'django-modeltranslation',
|
||||
u'django-modeltranslation Documentation',
|
||||
[u'Dirk Eschler'], 1)
|
||||
]
|
||||
|
||||
|
|
@ -225,14 +241,15 @@ man_pages = [
|
|||
#man_show_urls = False
|
||||
|
||||
|
||||
# -- Options for Texinfo output ------------------------------------------------
|
||||
# -- Options for Texinfo output -----------------------------------------------
|
||||
|
||||
# Grouping the document tree into Texinfo files. List of tuples
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
('index', 'django-modeltranslation', u'django-modeltranslation Documentation',
|
||||
u'Dirk Eschler', 'django-modeltranslation', 'One line description of project.',
|
||||
('index', 'django-modeltranslation',
|
||||
u'django-modeltranslation Documentation', u'Dirk Eschler',
|
||||
'django-modeltranslation', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
||||
|
|
@ -246,7 +263,7 @@ texinfo_documents = [
|
|||
#texinfo_show_urls = 'footnote'
|
||||
|
||||
|
||||
# -- Options for Epub output ---------------------------------------------------
|
||||
# -- Options for Epub output --------------------------------------------------
|
||||
|
||||
# Bibliographic Dublin Core info.
|
||||
epub_title = u'django-modeltranslation'
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
VERSION = (0, 4, 0, 'beta', 2)
|
||||
|
||||
|
||||
def get_version(version=None, pep386=True, short=False):
|
||||
"""
|
||||
Derives a version number as string from VERSION.
|
||||
|
||||
If the ``pep386`` parameter is ``True`` (default) the returned version will
|
||||
be PEP386-compliant (e.g. 0.4.0c1), else the release style naming
|
||||
will be used (e.g. 0.4.0-rc1).
|
||||
|
||||
If the ``short`` parameter is ``True``, the release style naming version
|
||||
will omit the patch level and sub (e.g. 0.4). The is for example used for
|
||||
sphinx.
|
||||
"""
|
||||
if version is None:
|
||||
version = VERSION
|
||||
assert len(version) == 5
|
||||
assert version[3] in ('alpha', 'beta', 'rc', 'final')
|
||||
|
||||
if pep386:
|
||||
# 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:
|
||||
sub = 'a%d' % (version[4])
|
||||
elif version[3] != 'final':
|
||||
mapping = {'alpha': 'a', 'beta': 'b', 'rc': 'c'}
|
||||
sub = mapping[version[3]] + str(version[4])
|
||||
return main + sub
|
||||
|
||||
if short:
|
||||
return '{0:d}.{0:d}'.format(*version)
|
||||
return '{0:d}.{1:d}.{2:d}-{3:s}{4:d}'.format(*version)
|
||||
|
||||
|
||||
__version__ = get_version()
|
||||
7
setup.py
7
setup.py
|
|
@ -1,10 +1,13 @@
|
|||
#!/usr/bin/env python
|
||||
from distutils.core import setup
|
||||
|
||||
# Dynamically calculate the version based on modeltranslation.VERSION.
|
||||
version = __import__('modeltranslation').get_version(pep386=False)
|
||||
|
||||
|
||||
setup(
|
||||
name='django-modeltranslation',
|
||||
version='0.4.0-beta2',
|
||||
version=version,
|
||||
description='Translates Django models using a registration approach.',
|
||||
long_description=(
|
||||
'The modeltranslation application can be used to translate dynamic '
|
||||
|
|
@ -23,7 +26,7 @@ setup(
|
|||
package_data={'modeltranslation': ['static/modeltranslation/css/*.css',
|
||||
'static/modeltranslation/js/*.js']},
|
||||
requires=['django(>=1.3)'],
|
||||
download_url='https://github.com/downloads/deschler/django-modeltranslation/django-modeltranslation-0.4.0-beta2.tar.gz',
|
||||
download_url='https://github.com/downloads/deschler/django-modeltranslation/django-modeltranslation-%s.tar.gz' % version,
|
||||
classifiers=[
|
||||
'Programming Language :: Python',
|
||||
'Programming Language :: Python :: 2.5',
|
||||
|
|
|
|||
Loading…
Reference in a new issue