Commit 18346b31 authored by Ole Streicher's avatar Ole Streicher

First upstream developer release 0.1

parents
Metadata-Version: 1.1
Name: astropy
Version: 0.1
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://cloud.github.com/downloads/astropy/astropy/astropy-0.1.tar.gz
Description:
Astropy is a package intended to contain core functionality and some
common tools needed for performing astronomy and astrophysics research with
Python. It also provides an index for other astronomy packages and tools for
managing them.
Platform: UNKNOWN
Requires: numpy
Provides: astropy
=======
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.
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>`_.
# Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Astropy is a package intended to contain core functionality and some
common tools needed for performing astronomy and astrophysics research with
Python. It also provides an index for other astronomy packages and tools for
managing them.
"""
#this indicates whether or not we are in astropy's setup.py
try:
_ASTROPY_SETUP_
except NameError:
from sys import version_info
if version_info[0] >= 3:
import builtins
else:
import __builtin__ as builtins
builtins._ASTROPY_SETUP_ = False
del version_info
try:
from .version import version as __version__
except ImportError:
# TODO: Issue a warning using the logging framework
__version__ = ''
try:
from .version import githash as __githash__
except ImportError:
# TODO: Issue a warning using the logging framework
__githash__ = ''
# set up the test command
_test_runner = None
def _get_test_runner():
from .tests.helper import TestRunner
return TestRunner(__path__[0])
def test(package=None, test_path=None, args=None, plugins=None,
verbose=False, pastebin=None, remote_data=False, pep8=False,
pdb=False, coverage=False):
"""
Run Astropy tests using py.test. A proper set of arguments is
constructed and passed to `pytest.main`.
Parameters
----------
package : str, optional
The name of a specific package to test, e.g. 'io.fits' or 'utils'.
If nothing is specified all default Astropy tests are run.
test_path : str, optional
Specify location to test by path. May be a single file or
directory. Must be specified absolutely or relative to the
calling directory.
args : str, optional
Additional arguments to be passed to `pytest.main` in the `args`
keyword argument.
plugins : list, optional
Plugins to be passed to `pytest.main` in the `plugins` keyword
argument.
verbose : bool, optional
Convenience option to turn on verbose output from py.test. Passing
True is the same as specifying `-v` in `args`.
pastebin : {'failed','all',None}, optional
Convenience option for turning on py.test pastebin output. Set to
'failed' to upload info for failed tests, or 'all' to upload info
for all tests.
remote_data : bool, optional
Controls whether to run tests marked with @remote_data. These
tests use online data and are not run by default. Set to True to
run these tests.
pep8 : bool, optional
Turn on PEP8 checking via the pytest-pep8 plugin and disable normal
tests. Same as specifying `--pep8 -k pep8` in `args`.
pdb : bool, optional
Turn on PDB post-mortem analysis for failing tests. Same as
specifying `--pdb` in `args`.
coverage : bool, optional
Generate a test coverage report. The result will be placed in
the directory htmlcov.
See Also
--------
pytest.main : py.test function wrapped by `run_tests`.
"""
test_runner = _get_test_runner()
return test_runner.run_tests(
package=package, test_path=test_path, args=args,
plugins=plugins, verbose=verbose, pastebin=pastebin,
remote_data=remote_data, pep8=pep8, pdb=pdb,
coverage=coverage)
#if we are *not* in setup mode, import the logger
if not _ASTROPY_SETUP_:
from logger import log
# Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This module contains configuration and setup utilities for the
`astropy` project. This includes all functionality related to the
affiliated package index.
"""
from .paths import *
from .configuration import *
from .data import *
from .affiliated import *
# Licensed under a 3-clause BSD style license - see LICENSE.rst
"""This module contains functions and classes for finding information about
affiliated packages and installing them.
"""
from __future__ import division
__all__ = []
This diff is collapsed.
This diff is collapsed.
# Licensed under a 3-clause BSD style license - see LICENSE.rst
""" This module contains functions to determine where configuration and
data/cache files used by Astropy should be placed.
"""
from __future__ import division
__all__ = ['get_config_dir', 'get_cache_dir']
def _find_home():
""" Locates and return the home directory (or best approximation) on this
system.
Raises
------
OSError
If the home directory cannot be located - usually means you are running
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
if sys.version_info[0] < 3: # pragma: py3
decodepath = lambda pth: pth.decode(sys.getfilesystemencoding())
else: # pragma: py2
decodepath = lambda pth: pth
#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'])
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'])
homedir = decodepath(homedir)
#Maybe a user profile?
elif 'USERPROFILE' in env:
homedir = decodepath(os.path.join(env['USERPROFILE']))
else:
try:
import _winreg as wreg
key = wreg.OpenKey(wreg.HKEY_CURRENT_USER,
'Software\Microsoft\Windows\CurrentVersion\Explorer\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'])
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'])
else:
raise OSError('Could not find a home directory to search for ' +\
'astropy config dir - are you on an unspported platform?')
return homedir
def get_config_dir(create=True):
"""
Determines the Astropy configuration directory name and creates the
directory if it doesn't exist.
This directory is typically ``$HOME/.astropy/config``, but if the
XDG_CONFIG_HOME environment variable is set and the
``$XDG_CONFIG_HOME/astropy`` directory exists, it will be that directory.
If neither exists, the former will be created and symlinked to the latter.
Returns
-------
configdir : str
The absolute path to the configuration directory.
"""
from os import path, environ
#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:
xchpth = path.join(xch, 'astropy')
if not path.islink(xchpth):
if path.exists(xchpth):
return path.abspath(xchpth)
else:
linkto = xchpth
return path.abspath(_find_or_create_astropy_dir('config', linkto))
def get_cache_dir():
"""
Determines the Astropy cache directory name and creates the directory if it
doesn't exist.
This directory is typically ``$HOME/.astropy/cache``, but if the
XDG_CACHE_HOME environment variable is set and the
``$XDG_CACHE_HOME/astropy`` directory exists, it will be that directory.
If neither exists, the former will be created and symlinked to the latter.
Returns
-------
cachedir : str
The absolute path to the cache directory.
"""
from os import path, environ
#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:
xchpth = path.join(xch, 'astropy')
if not path.islink(xchpth):
if path.exists(xchpth):
return path.abspath(xchpth)
else:
linkto = xchpth
return 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)
if not path.exists(maindir):
#first create .astropy dir if needed
if not path.exists(innerdir):
mkdir(innerdir)
elif not path.isdir(innerdir):
msg = 'Intended Astropy directory {0} is actually a file.'
raise IOError(msg.format(innerdir))
mkdir(maindir)
if (not sys.platform.startswith('win') and
linkto is not None and
not path.exists(linkto)):
from os import symlink
symlink(maindir, linkto)