Skip to content

Commit

Permalink
update top-level package init
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverba137 committed Jul 22, 2021
1 parent eaa72fa commit 4098a6c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 58 deletions.
17 changes: 8 additions & 9 deletions pydl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# Packages may add whatever they like to this file, but
# should keep this content at the top.
# ----------------------------------------------------------------------------
from ._astropy_init import *
from ._astropy_init import * # noqa
# ----------------------------------------------------------------------------

# Enforce Python version check during package import.
Expand All @@ -31,14 +31,13 @@ class UnsupportedPythonError(Exception):
if sys.version_info < tuple((int(val) for val in __minimum_python_version__.split('.'))):
raise UnsupportedPythonError("packagename does not support Python < {}".format(__minimum_python_version__))

if not _ASTROPY_SETUP_:
# For egg_info test builds to pass, put package imports here.
from .file_lines import file_lines
from .median import median
from .pcomp import pcomp
from .rebin import rebin
from .smooth import smooth
from .uniq import uniq

from .file_lines import file_lines
from .median import median
from .pcomp import pcomp
from .rebin import rebin
from .smooth import smooth
from .uniq import uniq


# Workaround: Numpy 1.14.x changes the way arrays are printed.
Expand Down
49 changes: 5 additions & 44 deletions pydl/_astropy_init.py
Original file line number Diff line number Diff line change
@@ -1,52 +1,13 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst
import os

__all__ = ['__version__']

# this indicates whether or not we are in the package's setup.py
try:
_ASTROPY_SETUP_
except NameError:
import builtins
builtins._ASTROPY_SETUP_ = False
__all__ = ['__version__', 'test']

try:
from .version import version as __version__
except ImportError:
__version__ = ''


if not _ASTROPY_SETUP_: # noqa
import os
from warnings import warn
from astropy.config.configuration import (
update_default_config,
ConfigurationDefaultMissingError,
ConfigurationDefaultMissingWarning)

# Create the test function for self test
from astropy.tests.runner import TestRunner
test = TestRunner.make_test_runner_in(os.path.dirname(__file__))
test.__test__ = False
__all__ += ['test']

# add these here so we only need to cleanup the namespace at the end
config_dir = None

if not os.environ.get('ASTROPY_SKIP_CONFIG_UPDATE', False):
config_dir = os.path.dirname(__file__)
config_template = os.path.join(config_dir, __package__ + ".cfg")
if os.path.isfile(config_template):
try:
update_default_config(
__package__, config_dir, version=__version__)
except TypeError as orig_error:
try:
update_default_config(__package__, config_dir)
except ConfigurationDefaultMissingError as e:
wmsg = (e.args[0] +
" Cannot install default profile. If you are "
"importing from source, this is expected.")
warn(ConfigurationDefaultMissingWarning(wmsg))
del e
except Exception:
raise orig_error
# Create the test function for self test
from astropy.tests.runner import TestRunner
test = TestRunner.make_test_runner_in(os.path.dirname(__file__))
20 changes: 15 additions & 5 deletions pydl/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# This file is used to configure the behavior of pytest when using the Astropy
# test infrastructure. It needs to live inside the package in order for it to
# get picked up when running the tests inside an interpreter using
# packagename.test
"""Configure Test Suite.
This file is used to configure the behavior of pytest when using the Astropy
test infrastructure. It needs to live inside the package in order for it to
get picked up when running the tests inside an interpreter using
packagename.test
"""

import os

Expand All @@ -10,7 +14,7 @@
# For Astropy 3.0 and later, we can use the standalone pytest plugin
if astropy_version < '3.0':
from astropy.tests.pytest_plugins import * # noqa
# del pytest_report_header
del pytest_report_header
ASTROPY_HEADER = True
else:
try:
Expand All @@ -21,7 +25,13 @@


def pytest_configure(config):
"""Configure Pytest with Astropy.
Parameters
----------
config : pytest configuration
"""
if ASTROPY_HEADER:

config.option.astropy_header = True
Expand Down

0 comments on commit 4098a6c

Please sign in to comment.