Skip to content

Commit

Permalink
compile MO files during develop and build
Browse files Browse the repository at this point in the history
  • Loading branch information
davidism committed Jun 4, 2018
1 parent 2c1bb40 commit 15c6422
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 16 deletions.
23 changes: 10 additions & 13 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
# File extensions
*.pyc
*.pyo
__pycache__/
.*.swp
.idea/
.DS_Store

# Extra Files
MANIFEST
WTForms.egg-info
.coverage
.coveralls.yml

# Directories
env/
venv/
WTForms.egg-info/
.eggs/
wtforms/locale/**/wtforms.mo
build/
dist/
docs/_build
docs/html
env/
.pytest_cache/
.tox/
.coverage
.coverage.*
htmlcov/
wtforms/locale/**/wtforms.mo

.eggs/
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ matrix:
fast_finish: true

install:
- python setup.py compile_catalog
- pip install tox

script:
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ include AUTHORS.rst
include CHANGES.rst
include LICENSE.rst
include README.rst
include tox.ini
graft docs
prune docs/_build
graft tests
Expand Down
53 changes: 51 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,61 @@
import io
import re

from setuptools import setup, find_packages
from setuptools import Command, find_packages, setup
from setuptools.command.develop import develop as BaseDevelop
from setuptools.command.sdist import sdist as BaseSDist

try:
from wheel.bdist_wheel import bdist_wheel as BaseBDistWheel
except ImportError:
BaseBDistWheel = None

with io.open("README.rst", "rt", encoding="utf8") as f:
readme = f.read()

with io.open("wtforms/__init__.py", "rt", encoding="utf8") as f:
version = re.search(r"__version__ = \'(.*?)\'", f.read()).group(1)


class CompileCatalogMixin(object):
"""Compile MO files with Babel's ``compile_catalog`` command. This
happens after installing in development mode, or before building
sdist and wheel.
"""

def __init__(self, dist, **kw):
# underlying commands are old-style classes on Python 2 :-(
Command.__init__(self, dist, **kw)

def run(self):
is_develop = isinstance(self, Develop)

if not is_develop:
self.run_command("compile_catalog")

super(CompileCatalogMixin, self).run()

if is_develop and not self.uninstall:
self.run_command("compile_catalog")


class Develop(CompileCatalogMixin, BaseDevelop):
pass


class SDist(CompileCatalogMixin, BaseSDist):
pass


command_classes = {"develop": Develop, "sdist": SDist}

if BaseBDistWheel:
class BDistWheel(CompileCatalogMixin, BaseBDistWheel):
pass

command_classes["bdist_wheel"] = BDistWheel


setup(
name="WTForms",
version=version,
Expand Down Expand Up @@ -45,8 +92,10 @@
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
"Topic :: Software Development :: Libraries :: Python Modules",
],
packages=find_packages(),
packages=find_packages(exclude=("tests",)),
include_package_data=True,
python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*",
setup_requires=["Babel"],
extras_require={"locale": ["Babel"]},
cmdclass=command_classes,
)

0 comments on commit 15c6422

Please sign in to comment.