install python-magic-bin in win32 and macOS

This commit is contained in:
nitely 2018-01-30 10:01:47 -03:00
parent 5addf36d6a
commit e00e4f0311
2 changed files with 9 additions and 1 deletions

View File

@ -3,6 +3,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import sys
import os import os
import io import io
from setuptools import setup, find_packages from setuptools import setup, find_packages
@ -18,6 +19,11 @@ VERSION = __import__('spirit').__version__
with io.open(os.path.join(BASE_DIR, 'requirements.txt'), encoding='utf-8') as fh: with io.open(os.path.join(BASE_DIR, 'requirements.txt'), encoding='utf-8') as fh:
REQUIREMENTS = fh.read() REQUIREMENTS = fh.read()
if sys.platform.startswith(('win32', 'darwin')):
PYTHON_MAGIC_DEP = ['python-magic-bin==0.4.14']
else: # Linux?
PYTHON_MAGIC_DEP = ['python-magic==0.4.15']
# allow setup.py to be run from any path # allow setup.py to be run from any path
os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir))) os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))
@ -39,7 +45,7 @@ spirit=spirit.extra.bin.spirit:main
zip_safe=False, zip_safe=False,
install_requires=REQUIREMENTS, install_requires=REQUIREMENTS,
extras_require={ extras_require={
'files': ['python-magic==0.4.15']}, 'files': PYTHON_MAGIC_DEP},
license='MIT License', license='MIT License',
classifiers=[ classifiers=[
'Development Status :: 5 - Production/Stable', 'Development Status :: 5 - Production/Stable',

View File

@ -67,6 +67,8 @@ ST_ALLOWED_UPLOAD_IMAGE_FORMAT = ('jpeg', 'jpg', 'gif')
ST_UPLOAD_FILE_ENABLED = True ST_UPLOAD_FILE_ENABLED = True
#: Uploaded files will be validated against these formats. #: Uploaded files will be validated against these formats.
#: This is a map of extension and media-type. Both are used for validation. #: This is a map of extension and media-type. Both are used for validation.
#: Requires running ``pip install django-spirit[files]`` to install
#: `python-magic <https://github.com/ahupp/python-magic#installation>`_
#: #:
#: .. Note:: #: .. Note::
#: To find a media-type just add an extension and an empty media-type, #: To find a media-type just add an extension and an empty media-type,