Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow import and use of module from source directory and development build #420

Merged
merged 1 commit into from
Jan 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
``.update`` method of ``AsdfInFits``, even though it didn't appear to be
working previously. [#412]

- Allow package to be imported and used from source directory and builds in
development mode. [#420]

1.3.2 (unreleased)
------------------

Expand Down
13 changes: 10 additions & 3 deletions asdf/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@
from . import util


SCHEMA_PATH = os.path.abspath(
os.path.join(os.path.dirname(__file__), 'schemas'))
def find_schema_path():
dirname = os.path.dirname(__file__)

# This means we are working within a development build
if os.path.exists(os.path.join(dirname, '..', 'asdf-standard')):
return os.path.join(dirname, '..', 'asdf-standard', 'schemas')

# Otherwise, we return the installed location
return os.path.join(dirname, 'schemas')


class Resolver(object):
Expand Down Expand Up @@ -103,7 +110,7 @@ def __hash__(self):
DEFAULT_URL_MAPPING = [
(constants.STSCI_SCHEMA_URI_BASE,
util.filepath_to_url(
os.path.join(SCHEMA_PATH, 'stsci.edu')) +
os.path.join(find_schema_path(), 'stsci.edu')) +
'/{url_suffix}.yaml')]
DEFAULT_TAG_TO_URL_MAPPING = [
(constants.STSCI_SCHEMA_TAG_BASE,
Expand Down