Commit cf3b11f4 authored by Ole Streicher's avatar Ole Streicher

New upstream version 0.3

parent ac88cfc7
This diff is collapsed.
Metadata-Version: 1.1
Name: astropy
Version: 0.2.5
Version: 0.3
Summary: Community-developed python astronomy tools
Home-page: http://astropy.org
Author: The Astropy Developers
Author-email: astropy.team@gmail.com
License: BSD
Download-URL: http://pypi.python.org/packages/source/a/astropy/astropy-0.2.5.tar.gz
Download-URL: http://pypi.python.org/packages/source/a/astropy/astropy-0.3.tar.gz
Description:
Astropy is a package intended to contain core functionality and some
common tools needed for performing astronomy and astrophysics research with
......
......@@ -2,6 +2,12 @@
Astropy
=======
.. image:: https://pypip.in/v/astropy/badge.png
:target: https://pypi.python.org/pypi/astropy
.. image:: https://pypip.in/d/astropy/badge.png
:target: https://pypi.python.org/pypi/astropy
Astropy (http://astropy.org/) is a package intended to contain much of
the core functionality and some common tools needed for performing
astronomy and astrophysics with Python.
......@@ -10,5 +16,21 @@ Releases are `registered on PyPI <http://pypi.python.org/pypi/astropy>`_,
and development is occuring at the
`project's github page <http://github.com/astropy/astropy>`_.
For installation instructions, see the `online documentation <http://docs.astropy.org/>`_
For installation instructions, see the `online documentation <http://docs.astropy.org/>`_
or ``docs/install.rst`` in this source distribution.
Jenkins Build Status
--------------------
.. image:: https://jenkins.shiningpanda-ci.com/astropy/job/astropy-master-debian-multiconfig/badge/icon
:target: https://jenkins.shiningpanda-ci.com/astropy/job/astropy-master-debian-multiconfig/
Travis Build Status
-------------------
.. image:: https://travis-ci.org/astropy/astropy.png
:target: https://travis-ci.org/astropy/astropy
Test Coverage Status
--------------------
.. image:: https://coveralls.io/repos/astropy/astropy/badge.png
:target: https://coveralls.io/r/astropy/astropy
......@@ -17,6 +17,7 @@ except NameError:
import __builtin__ as builtins
builtins._ASTROPY_SETUP_ = False
del version_info
del builtins
try:
from .version import version as __version__
......@@ -30,7 +31,7 @@ except ImportError:
__githash__ = ''
import logging
__minimum_numpy_version__ = '1.5.0'
# The location of the online documentation for astropy
......@@ -41,6 +42,47 @@ else:
online_docs_root = 'http://docs.astropy.org/en/{0}/'.format(__version__)
def _check_numpy():
"""
Check that Numpy is installed and it is of the minimum version we
require.
"""
# Note: We could have used distutils.version for this comparison,
# but it seems like overkill to import distutils at runtime.
requirement_met = False
try:
import numpy
except ImportError:
pass
else:
major, minor, rest = numpy.__version__.split(".", 2)
rmajor, rminor, rest = __minimum_numpy_version__.split(".", 2)
requirement_met = ((int(major), int(minor)) >=
(int(rmajor), int(rminor)))
if not requirement_met:
msg = ("numpy version {0} or later must be installed to use "
"astropy".format(
__minimum_numpy_version__))
raise ImportError(msg)
return numpy
if not _ASTROPY_SETUP_:
_check_numpy()
from .config import ConfigurationItem
UNICODE_OUTPUT = ConfigurationItem(
'unicode_output', False,
'Use Unicode characters when outputting values, and writing widgets '
'to the console.')
# set up the test command
def _get_test_runner():
from .tests.helper import TestRunner
......@@ -49,7 +91,7 @@ def _get_test_runner():
def test(package=None, test_path=None, args=None, plugins=None,
verbose=False, pastebin=None, remote_data=False, pep8=False,
pdb=False, coverage=False, open_files=False):
pdb=False, coverage=False, open_files=False, parallel=0):
"""
Run Astropy tests using py.test. A proper set of arguments is
constructed and passed to `pytest.main`.
......@@ -104,6 +146,12 @@ def test(package=None, test_path=None, args=None, plugins=None,
this adds extra run time to the test suite. Works only on
platforms with a working `lsof` command.
parallel : int, optional
When provided, run the tests in parallel on the specified
number of CPUs. If parallel is negative, it will use the all
the cores on the machine. Requires the `pytest-xdist` plugin
is installed.
See Also
--------
pytest.main : py.test function wrapped by `run_tests`.
......@@ -114,43 +162,49 @@ def test(package=None, test_path=None, args=None, plugins=None,
package=package, test_path=test_path, args=args,
plugins=plugins, verbose=verbose, pastebin=pastebin,
remote_data=remote_data, pep8=pep8, pdb=pdb,
coverage=coverage, open_files=open_files)
coverage=coverage, open_files=open_files,
parallel=parallel)
# Use the root logger as a dummy log before initilizing Astropy's logger
log = logging.getLogger()
# if we are *not* in setup mode, import the logger and possibly populate the
# configuration file with the defaults
if not _ASTROPY_SETUP_:
from .logger import _init_log, _teardown_log
def _initialize_astropy():
from . import config
import os
import sys
from warnings import warn
log = _init_log()
def _rollback_import(message):
log.error(message)
# Now disable exception logging to avoid an annoying error in the
# exception logger before we raise the import error:
_teardown_log()
# Roll back any astropy sub-modules that have been imported thus
# far
for key in list(sys.modules):
if key.startswith('astropy.'):
del sys.modules[key]
raise ImportError('astropy')
if sys.version_info[0] >= 3 and os.path.exists('setup.py'):
_rollback_import(
"You appear to be trying to import astropy from within a source "
"checkout. This is currently not possible using Python 3 due to "
"the reliance of 2to3 to convert some of Astropy's subpackages "
"for Python 3 compatibility.")
try:
from .utils import _compiler
except ImportError:
if os.path.exists('setup.py'):
log.error('You appear to be trying to import astropy from within '
'a source checkout; please run `./setup.py develop` or '
'`./setup.py build_ext --inplace` first so that '
'extension modules can be compiled and made importable.')
# Now disable exception logging to avoid an annoying error in the
# exception logger before we raise the import error:
_teardown_log()
# Roll back any astropy sub-modules that have been imported thus
# far
for key in sys.modules.keys():
if key.startswith('astropy.'):
del sys.modules[key]
raise ImportError('astropy')
_rollback_import(
'You appear to be trying to import astropy from within a '
'source checkout; please run `./setup.py develop` or '
'`./setup.py build_ext --inplace` first so that extension '
'modules can be compiled and made importable.')
else:
# Outright broken installation; don't be nice.
raise
......@@ -165,6 +219,19 @@ if not _ASTROPY_SETUP_:
wmsg = (e.args[0] + " Cannot install default profile. If you are "
"importing from source, this is expected.")
warn(config.configuration.ConfigurationDefaultMissingWarning(wmsg))
del e
del _init_log, os, warn, config_dir # clean up namespace
import logging
# Use the root logger as a dummy log before initilizing Astropy's logger
log = logging.getLogger()
if not _ASTROPY_SETUP_:
from .logger import _init_log, _teardown_log
log = _init_log()
_initialize_astropy()
from .utils.misc import find_api_page
......@@ -5,6 +5,8 @@ This module contains configuration and setup utilities for the
`astropy` project. This includes all functionality related to the
affiliated package index.
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from .paths import *
from .configuration import *
......
......@@ -3,6 +3,7 @@
affiliated packages and installing them.
"""
from __future__ import division
from __future__ import (absolute_import, division, print_function,
unicode_literals)
__all__ = []
This diff is collapsed.
......@@ -2,8 +2,12 @@
""" This module contains functions to determine where configuration and
data/cache files used by Astropy should be placed.
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import os
import sys
from __future__ import division
__all__ = ['get_config_dir', 'get_cache_dir']
......@@ -19,9 +23,7 @@ def _find_home():
Astropy on some obscure platform that doesn't have standard home
directories.
"""
import os
import sys
from os import environ as env
# this is used below to make fix up encoding issues that sometimes crop up
# in py2.x but not in py3.x
......@@ -30,46 +32,47 @@ def _find_home():
else: # pragma: py2
decodepath = lambda pth: pth
#First find the home directory - this is inspired by the scheme ipython
#uses to identify "home"
# First find the home directory - this is inspired by the scheme ipython
# uses to identify "home"
if os.name == 'posix':
# Linux, Unix, AIX, OS X
if 'HOME' in env:
homedir = decodepath(env['HOME'])
if 'HOME' in os.environ:
homedir = decodepath(os.environ['HOME'])
else:
raise OSError('Could not find unix home directory to search for '
'astropy config dir')
elif os.name == 'nt': # This is for all modern Windows (NT or after)
#Try for a network home first
if 'HOMESHARE' in env:
homedir = decodepath(env['HOMESHARE'])
#See if there's a local home
elif 'HOMEDRIVE' in env and 'HOMEPATH' in env:
homedir = os.path.join(env['HOMEDRIVE'], env['HOMEPATH'])
# Try for a network home first
if 'HOMESHARE' in os.environ:
homedir = decodepath(os.environ['HOMESHARE'])
# See if there's a local home
elif 'HOMEDRIVE' in os.environ and 'HOMEPATH' in os.environ:
homedir = os.path.join(os.environ['HOMEDRIVE'],
os.environ['HOMEPATH'])
homedir = decodepath(homedir)
#Maybe a user profile?
elif 'USERPROFILE' in env:
homedir = decodepath(os.path.join(env['USERPROFILE']))
# Maybe a user profile?
elif 'USERPROFILE' in os.environ:
homedir = decodepath(os.path.join(os.environ['USERPROFILE']))
else:
try:
import _winreg as wreg
key = wreg.OpenKey(wreg.HKEY_CURRENT_USER,
r'Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders')
from ..extern.six.moves import winreg as wreg
shell_folders = r'Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders'
key = wreg.OpenKey(wreg.HKEY_CURRENT_USER, shell_folders)
homedir = wreg.QueryValueEx(key, 'Personal')[0]
homedir = decodepath(homedir)
key.Close()
except:
#As a final possible resort, see if HOME is present
if 'HOME' in env:
homedir = decodepath(env['HOME'])
# As a final possible resort, see if HOME is present
if 'HOME' in os.environ:
homedir = decodepath(os.environ['HOME'])
else:
raise OSError('Could not find windows home directory to '
'search for astropy config dir')
else:
#for other platforms, try HOME, although it probably isn't there
if 'HOME' in env:
homedir = decodepath(env['HOME'])
# for other platforms, try HOME, although it probably isn't there
if 'HOME' in os.environ:
homedir = decodepath(os.environ['HOME'])
else:
raise OSError('Could not find a home directory to search for '
'astropy config dir - are you on an unspported '
......@@ -94,21 +97,19 @@ def get_config_dir(create=True):
"""
from os import path, environ
#symlink will be set to this if the directory is created
# symlink will be set to this if the directory is created
linkto = None
#first look for XDG_CONFIG_HOME
xch = environ.get('XDG_CONFIG_HOME')
if xch is not None and path.exists(xch):
xchpth = path.join(xch, 'astropy')
if not path.islink(xchpth):
if path.exists(xchpth):
return path.abspath(xchpth)
# first look for XDG_CONFIG_HOME
xch = os.environ.get('XDG_CONFIG_HOME')
if xch is not None and os.path.exists(xch):
xchpth = os.path.join(xch, 'astropy')
if not os.path.islink(xchpth):
if os.path.exists(xchpth):
return os.path.abspath(xchpth)
else:
linkto = xchpth
return path.abspath(_find_or_create_astropy_dir('config', linkto))
return os.path.abspath(_find_or_create_astropy_dir('config', linkto))
def get_cache_dir():
......@@ -127,57 +128,52 @@ def get_cache_dir():
The absolute path to the cache directory.
"""
from os import path, environ
#symlink will be set to this if the directory is created
# symlink will be set to this if the directory is created
linkto = None
#first look for XDG_CACHE_HOME
xch = environ.get('XDG_CACHE_HOME')
if xch is not None and path.exists(xch):
xchpth = path.join(xch, 'astropy')
if not path.islink(xchpth):
if path.exists(xchpth):
return path.abspath(xchpth)
# first look for XDG_CACHE_HOME
xch = os.environ.get('XDG_CACHE_HOME')
if xch is not None and os.path.exists(xch):
xchpth = os.path.join(xch, 'astropy')
if not os.path.islink(xchpth):
if os.path.exists(xchpth):
return os.path.abspath(xchpth)
else:
linkto = xchpth
return path.abspath(_find_or_create_astropy_dir('cache', linkto))
return os.path.abspath(_find_or_create_astropy_dir('cache', linkto))
def _find_or_create_astropy_dir(dirnm, linkto):
from os import path, mkdir
import sys
innerdir = path.join(_find_home(), '.astropy')
maindir = path.join(_find_home(), '.astropy', dirnm)
innerdir = os.path.join(_find_home(), '.astropy')
maindir = os.path.join(_find_home(), '.astropy', dirnm)
if not path.exists(maindir):
#first create .astropy dir if needed
if not path.exists(innerdir):
if not os.path.exists(maindir):
# first create .astropy dir if needed
if not os.path.exists(innerdir):
try:
mkdir(innerdir)
os.mkdir(innerdir)
except OSError:
if not path.isdir(innerdir):
if not os.path.isdir(innerdir):
raise
elif not path.isdir(innerdir):
elif not os.path.isdir(innerdir):
msg = 'Intended Astropy directory {0} is actually a file.'
raise IOError(msg.format(innerdir))
try:
mkdir(maindir)
os.mkdir(maindir)
except OSError:
if not path.isdir(maindir):
if not os.path.isdir(maindir):
raise
if (not sys.platform.startswith('win') and
linkto is not None and
not path.exists(linkto)):