Skip to content

Commit

Permalink
Merge pull request #408 from drdavella/simplify-setup
Browse files Browse the repository at this point in the history
Make improvements and simplifications to the package setup.py
  • Loading branch information
drdavella authored Dec 12, 2017
2 parents 30f5cbb + 49e74e2 commit 735eaea
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 61 deletions.
64 changes: 32 additions & 32 deletions asdf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,35 @@
from ._internal_init import *
# ----------------------------------------------------------------------------

if _ASDF_SETUP_ is False:
__all__ = ['AsdfFile', 'CustomType', 'AsdfExtension',
'Stream', 'open', 'test', 'commands',
'ValidationError']

try:
import yaml as _
except ImportError:
raise ImportError("asdf requires pyyaml")

try:
import jsonschema as _
except ImportError:
raise ImportError("asdf requires jsonschema")

try:
import numpy as _
except ImportError:
raise ImportError("asdf requires numpy")

from .asdf import AsdfFile
from .asdftypes import CustomType
from .extension import AsdfExtension
from .stream import Stream
from . import commands

from jsonschema import ValidationError

class ValidationError(ValidationError):
pass

open = AsdfFile.open
__all__ = [
'AsdfFile', 'CustomType', 'AsdfExtension', 'Stream', 'open', 'test',
'commands', 'ValidationError'
]

try:
import yaml as _
except ImportError:
raise ImportError("asdf requires pyyaml")

try:
import jsonschema as _
except ImportError:
raise ImportError("asdf requires jsonschema")

try:
import numpy as _
except ImportError:
raise ImportError("asdf requires numpy")

from .asdf import AsdfFile
from .asdftypes import CustomType
from .extension import AsdfExtension
from .stream import Stream
from . import commands

from jsonschema import ValidationError

class ValidationError(ValidationError):
pass

open = AsdfFile.open
12 changes: 0 additions & 12 deletions asdf/_internal_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,6 @@

__all__ = ['__version__', '__githash__', 'test']

# this indicates whether or not we are in the package's setup.py
try:
_ASDF_SETUP_
except NameError:
from sys import version_info
if version_info < (2, 7, 0): # pragma: no cover
raise ImportError("ASDF requires Python 2.7 or newer")
if version_info[0] >= 3:
import builtins
else:
import __builtin__ as builtins
builtins._ASDF_SETUP_ = False

try:
from .version import version as __version__
Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ upload-dir = docs/_build/html
show-response = 1

[tool:pytest]
minversion = 2.2
testpaths = asdf docs
minversion = 3.1
norecursedirs = build docs/_build
doctest_plus = enabled
remote_data_strict = True
Expand Down
23 changes: 7 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,12 @@
import glob
import os
import sys
import builtins
import subprocess as sp

import ah_bootstrap
from setuptools import setup

#A dirty hack to get around some early import/configurations ambiguities
if sys.version_info[0] >= 3:
import builtins
else:
import __builtin__ as builtins
builtins._ASDF_SETUP_ = True

from astropy_helpers.setup_helpers import (
register_commands, get_debug_option, get_package_info)
Expand All @@ -27,10 +22,7 @@ def _null_validate(self):
test_helpers.AstropyTest._validate_required_deps = _null_validate

# Get some values from the setup.cfg
try:
from ConfigParser import ConfigParser
except ImportError:
from configparser import ConfigParser
from configparser import ConfigParser
conf = ConfigParser()
conf.read(['setup.cfg'])
metadata = dict(conf.items('metadata'))
Expand All @@ -42,10 +34,9 @@ def _null_validate(self):
LICENSE = metadata.get('license', 'unknown')
URL = metadata.get('url', '')

# Get the long description from the package's docstring
__import__('asdf')
package = sys.modules['asdf']
LONG_DESCRIPTION = package.__doc__
def readme():
with open('README.md') as ff:
return ff.read()

# Store the package name in a built-in variable so it's easy
# to get from other parts of the setup infrastructure
Expand Down Expand Up @@ -133,15 +124,15 @@ def _null_validate(self):
'pyyaml>=3.10',
'jsonschema>=2.3.0',
'six>=1.9.0',
'pytest>=2.7.2',
'numpy>=1.8',
'astropy>=1.3',
] + extra_requires,
tests_require=['pytest-astropy'],
author=AUTHOR,
author_email=AUTHOR_EMAIL,
license=LICENSE,
url=URL,
long_description=LONG_DESCRIPTION,
long_description=readme(),
cmdclass=cmdclassd,
zip_safe=False,
use_2to3=True,
Expand Down

0 comments on commit 735eaea

Please sign in to comment.