Skip to content

Commit

Permalink
Don't install enum34 when it's not required
Browse files Browse the repository at this point in the history
Having enum34 breaks Python 3.6 in some cases.

h/t https://hynek.me/articles/conditional-python-dependencies/
  • Loading branch information
akx committed Mar 27, 2017
1 parent 8cb2a3d commit cedb209
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
10 changes: 7 additions & 3 deletions enumfields/enums.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import inspect
from enum import Enum as BaseEnum
from enum import EnumMeta as BaseEnumMeta
from enum import _EnumDict

try:
from enum import Enum as BaseEnum
from enum import EnumMeta as BaseEnumMeta
from enum import _EnumDict
except ImportError: # pragma: no cover
raise ImportError('Missing the enum module. Please install enum34.')

from django.utils.encoding import python_2_unicode_compatible

Expand Down
15 changes: 7 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/bin/env python

import os
from setuptools import setup, find_packages
from setuptools.command.test import test as TestCommand
import sys

from setuptools import find_packages, setup
from setuptools.command.test import test as TestCommand


def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
Expand All @@ -25,11 +26,6 @@ def run_tests(self):
errno = pytest.main(self.test_args)
sys.exit(errno)

install_requires = ['six']
try:
import enum
except ImportError:
install_requires.append('enum34')

setup(
name='django-enumfields',
Expand Down Expand Up @@ -57,10 +53,13 @@ def run_tests(self):
"Programming Language :: Python :: 3.5",
'Topic :: Internet :: WWW/HTTP',
],
install_requires=install_requires,
install_requires=['six'],
tests_require=[
'pytest-django<3.0',
'Django',
],
extras_require={
':python_version<"3.4"': ['enum34'],
},
cmdclass={'test': PyTest},
)

0 comments on commit cedb209

Please sign in to comment.