mirror of
https://github.com/sprockets/sprockets.mixins.mediatype.git
synced 2024-11-22 03:00:25 +00:00
Use setuptools_scm
This allows us to remove the ImportError hack from __init__.py. It also simplifies how the package is versioned - deriving it solely from the repository tag. Both version_info and __version__ have been removed with this change. Given how these are a unofficial-standard at best, I've found it safer to always use pkg_resources to determine the version when I need to.
This commit is contained in:
parent
a28633aef5
commit
00b87a43cf
3 changed files with 7 additions and 25 deletions
|
@ -1,4 +1,4 @@
|
|||
from sprockets.mixins.mediatype import __version__
|
||||
import pkg_resources
|
||||
|
||||
needs_sphinx = '1.0'
|
||||
extensions = ['sphinx.ext.autodoc',
|
||||
|
@ -8,7 +8,7 @@ extensions = ['sphinx.ext.autodoc',
|
|||
master_doc = 'index'
|
||||
project = 'sprockets.mixins.mediatype'
|
||||
copyright = '2015-2016, AWeber Communications'
|
||||
release = __version__
|
||||
release = pkg_resources.get_distribution('sprockets.mixins.mediatype').version
|
||||
version = '.'.join(release.split('.')[0:1])
|
||||
|
||||
html_style = 'custom.css'
|
||||
|
|
5
setup.py
5
setup.py
|
@ -4,8 +4,6 @@
|
|||
import os
|
||||
import setuptools
|
||||
|
||||
from sprockets.mixins import mediatype
|
||||
|
||||
|
||||
def read_requirements(file_name):
|
||||
requirements = []
|
||||
|
@ -30,7 +28,6 @@ tests_require = read_requirements('testing.txt')
|
|||
|
||||
setuptools.setup(
|
||||
name='sprockets.mixins.mediatype',
|
||||
version=mediatype.__version__,
|
||||
description='A mixin for reporting handling content-type/accept headers',
|
||||
long_description='\n' + open('README.rst').read(),
|
||||
url='https://github.com/sprockets/sprockets.mixins.media_type',
|
||||
|
@ -61,6 +58,8 @@ setuptools.setup(
|
|||
extras_require={
|
||||
'msgpack': ['u-msgpack-python>=2.5.0,<3']
|
||||
},
|
||||
setup_requires=['setuptools_scm'],
|
||||
use_scm_version=True,
|
||||
namespace_packages=['sprockets', 'sprockets.mixins'],
|
||||
test_suite='nose.collector',
|
||||
python_requires='>=3.5',
|
||||
|
|
|
@ -3,28 +3,11 @@ sprockets.mixins.media_type
|
|||
|
||||
"""
|
||||
|
||||
try:
|
||||
from .content import (ContentMixin, ContentSettings,
|
||||
add_binary_content_type, add_text_content_type,
|
||||
set_default_content_type)
|
||||
|
||||
except ImportError as error: # pragma no cover
|
||||
def _error_closure(*args, **kwargs):
|
||||
raise error
|
||||
|
||||
class ErrorClosureClass:
|
||||
def __init__(self, *args, **kwargs):
|
||||
raise error
|
||||
|
||||
ContentMixin = ErrorClosureClass
|
||||
ContentSettings = ErrorClosureClass
|
||||
add_binary_content_type = _error_closure
|
||||
add_text_content_type = _error_closure
|
||||
set_default_content_type = _error_closure
|
||||
from .content import (ContentMixin, ContentSettings,
|
||||
add_binary_content_type, add_text_content_type,
|
||||
set_default_content_type)
|
||||
|
||||
|
||||
version_info = (2, 2, 2)
|
||||
__version__ = '.'.join(str(v) for v in version_info)
|
||||
__all__ = ['ContentMixin', 'ContentSettings', 'add_binary_content_type',
|
||||
'add_text_content_type', 'set_default_content_type',
|
||||
'version_info', '__version__']
|
||||
|
|
Loading…
Reference in a new issue