Skip to content

Commit

Permalink
Include compiled messages in dist packages (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
codingjoe committed Jun 29, 2019
1 parent 26577af commit c9db965
Show file tree
Hide file tree
Showing 19 changed files with 148 additions and 178 deletions.
18 changes: 1 addition & 17 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,11 @@ charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 88

[*.py]
indent_style = space
indent_size = 4
# isort config
atomic = true
multi_line_output = 5
line_length = 79
combine_as_imports = true
skip = wsgi.py,docs,.tox,env
known_first_party = stdimage,tests
known_third_party = django


[*.{rst,ini}]
indent_style = space
Expand All @@ -29,14 +21,6 @@ indent_size = 4
indent_style = space
indent_size = 2

[*.{css,less}]
indent_style = space
indent_size = 2

[*.{js,coffee}]
indent_style = space
indent_size = 4

[Makefile]
indent_style = tab
indent_size = 1
4 changes: 4 additions & 0 deletions .fussyfox.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- bandit
- flake8
- isort
- pydocstyle
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ build/
dist/
.idea/
.tox/
coverage.xml


.cache/
.coverage
htmlcov/

.eggs/
25 changes: 0 additions & 25 deletions .pre-commit-config.yaml

This file was deleted.

7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
language: python
sudo: false
dist: xenial
cache: pip
python:
- '3.6'
- '3.7'
env:
matrix:
- TOXENV=qa
- DJANGO=111
- DJANGO=22
- DJANGO=master
matrix:
fast_finish: true
Expand All @@ -31,5 +32,5 @@ deploy:
secure: dnmVaqnmG6mSrmI9q6nL2l0aGkX56+WAsqdT/J1O2hBpFBOE4NiqH+2ryIqZj1wrvHZ72/jjyT5Xi1MWYxwDtDfkBIp+juHUGPbFfGy3J7EVgGkmf38E5SC2Q9IHc3A1iHxTZAX3o816TP3bt5vwGll3UzSMiaaPRQ/AiK4+og4=
on:
tags: true
distributions: sdist bdist_wheel
distributions: compile_translations sdist bdist_wheel
repo: codingjoe/django-stdimage
23 changes: 0 additions & 23 deletions CONTRIBUTING.md

This file was deleted.

5 changes: 5 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include stdimage/locale/*/LC_MESSAGES/django.po
include stdimage/locale/*/LC_MESSAGES/django.mo
prune tests
prune .github
exclude .*
26 changes: 11 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
[![Django-CC](https://img.shields.io/badge/Django-CC-ee66dd.svg)](https://github.com/codingjoe/django-cc)
[![version](https://img.shields.io/pypi/v/django-stdimage.svg)](https://pypi.python.org/pypi/django-stdimage/)
[![ci](https://api.travis-ci.org/codingjoe/django-stdimage.svg?branch=master)](https://travis-ci.org/codingjoe/django-stdimage)
[![codecov](https://codecov.io/gh/codingjoe/django-stdimage/branch/master/graph/badge.svg)](https://codecov.io/gh/codingjoe/django-stdimage)
[![code-health](https://landscape.io/github/codingjoe/django-stdimage/master/landscape.svg?style=flat)](https://landscape.io/github/codingjoe/django-stdimage/master)
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)

# Django Standardized Image Field
Expand All @@ -22,7 +20,11 @@ Django Field that implement the following features:

Simply install the latest stable package using the command

`pip install django-stdimage`
```bash
pip install django-stdimage
# or
pipenv install django-stdimage
```

and add `'stdimage'` to `INSTALLED_APP`s in your settings.py, that's it!

Expand All @@ -38,6 +40,7 @@ Variations are specified within a dictionary. The key will be the attribute refe
A variation can be defined both as a tuple or a dictionary.

Example:

```python
from django.db import models
from stdimage.models import StdImageField
Expand Down Expand Up @@ -70,6 +73,7 @@ class MyModel(models.Model):
For using generated variations in templates use `myimagefield.variation_name`.

Example:

```html
<a href="{{ object.myimage.url }}"><img alt="" src="{{ object.myimage.thumbnail.url }}"/></a>
```
Expand All @@ -86,7 +90,8 @@ The `StdImageField` doesn't implement any size validation. Validation can be spe
and using a set of validators shipped with this package.
Validators can be used for both Forms and Models.

Example
Example

```python
from django.db import models
from stdimage.validators import MinSizeValidator, MaxSizeValidator
Expand Down Expand Up @@ -123,7 +128,6 @@ pre_save.connect(pre_save_delete_callback, sender=models.MyModel)

**Warning:** You should not use the signal callbacks in production. They may result in data loss.


### Async image processing
Tools like celery allow to execute time-consuming tasks outside of the request. If you don't want
to wait for your variations to be rendered in request, StdImage provides your the option to pass a
Expand All @@ -133,11 +137,7 @@ This example is based on celery.

`tasks.py`:
```python
try:
from django.apps import apps
get_model = apps.get_model
except ImportError:
from django.apps import apps
from django.apps import apps

from celery import shared_task

Expand All @@ -157,7 +157,7 @@ def process_photo_image(file_name, variations, storage):
from django.db import models
from stdimage.models import StdImageField

from tasks import process_photo_image
from .tasks import process_photo_image

def image_processor(file_name, variations, storage):
process_photo_image.delay(file_name, variations, storage)
Expand Down Expand Up @@ -191,7 +191,3 @@ and therefore the huge memory footprint from previous versions.

**Note:** PyPy seems to have some problems regarding multiprocessing,
for that matter all multiprocessing is disabled in PyPy.

## [Contributing](CONTRIBUTING.md)

## [License](LICENSE)
1 change: 0 additions & 1 deletion _config.yml

This file was deleted.

6 changes: 0 additions & 6 deletions requirements-dev.txt

This file was deleted.

2 changes: 0 additions & 2 deletions requirements.txt

This file was deleted.

65 changes: 50 additions & 15 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
[metadata]
name = django-stdimage
author = Johannes Hoppe
author-email = info@johanneshoppe.com
summary = Django Standarized Image Field
description-file = README.md
home-page = https://github.com/codingjoe/django-stdimage
author_email = info@johanneshoppe.com
description = Django Standarized Image Field
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/codingjoe/django-stdimage
license = MIT
license_file = LICENSE
classifier =
Development Status :: 5 - Production/Stable
Environment :: Web Environment
Expand All @@ -17,24 +19,58 @@ classifier =
Programming Language :: Python
Topic :: Software Development
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Framework :: Django

[files]
packages =
stdimage
[options]
include_package_data = True
packages = stdimage
install_requires =
Django>=1.11
pillow>=2.5
progressbar2>=3.0.0
setup_requires =
setuptools_scm
pytest-runner
tests_require =
pytest>=4.0,<5.0
pytest-cov
pytest-django

[options.package_data]
* = *.txt, *.rst, *.html, *.po

[options.packages.find]
exclude =
tests

[bdist_wheel]
universal = 1

[aliases]
test = pytest

[tool:pytest]
norecursedirs=venv env .eggs
DJANGO_SETTINGS_MODULE=tests.settings
addopts = --tb=short -rxs --nomigrations
addopts = --cov=stdimage --cov-report xml --tb=short -rxs --nomigrations

[tox:tox]
envlist = py{36,37}-dj{111,22,master}

[testenv]
deps =
dj111: https://github.com/django/django/archive/stable/1.11.x.tar.gz#egg=django
dj22: https://github.com/django/django/archive/stable/2.2.x.tar.gz#egg=django
djmaster: https://github.com/django/django/archive/master.tar.gz#egg=django
commands = python setup.py test

[flake8]
max-line-length = 79
max-line-length = 88
statistics = true
show-source = true
exclude = */migrations/*,docs/*,env/*,venv/*,.tox/*,.eggs


[pydocstyle]
add-ignore = D1
match-dir = (?!tests|env|docs|\.).*
Expand All @@ -53,9 +89,8 @@ show_missing = True

[isort]
atomic = true
multi_line_output = 5
line_length = 79
line_length = 88
known_first_party = stdimage, tests
include_trailing_comma = True
default_section=THIRDPARTY
combine_as_imports = true
skip = wsgi.py,docs,tests/test_models.py,.tox,env,.eggs
known_first_party = stdimage,tests
known_third_party = django
53 changes: 51 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,56 @@
#!/usr/bin/env python
import distutils
import glob
import os
import subprocess # nosec
from distutils.cmd import Command
from distutils.command.build import build as _build

from setuptools import setup
from setuptools.command.install_lib import install_lib as _install_lib

BASE_DIR = os.path.dirname((os.path.abspath(__file__)))


class compile_translations(Command):
description = 'Compile i18n translations using gettext.'
user_options = []

def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
pattern = 'stdimage/locale/*/LC_MESSAGES/django.po'
for file in glob.glob(pattern):
cmd = ['msgfmt', '-c']
name, ext = os.path.splitext(file)

cmd += ['-o', '%s.mo' % name]
cmd += ['%s.po' % name]
self.announce(
'running command: %s' % ' '.join(cmd),
level=distutils.log.INFO)
subprocess.check_call(cmd, cwd=BASE_DIR) # nosec


class build(_build):
sub_commands = [('compile_translations', None)] + _build.sub_commands


class install_lib(_install_lib):
def run(self):
self.run_command('compile_translations')
_install_lib.run(self)


setup(
setup_requires=['pbr'],
pbr=True,
use_scm_version=True,
cmdclass={
'build': build,
'install_lib': install_lib,
'compile_translations': compile_translations,
},
)
2 changes: 1 addition & 1 deletion stdimage/management/commands/rendervariations.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def render(field, images, count, replace, ignore_missing, do_render):
)
for file_name in images
)
with progressbar.ProgressBar(maxval=count, widgets=(
with progressbar.ProgressBar(max_value=count, widgets=(
progressbar.RotatingMarker(),
' | CPUs: {}'.format(cpu_count()),
' | ', progressbar.AdaptiveETA(),
Expand Down
Loading

0 comments on commit c9db965

Please sign in to comment.