Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #217 from Unidata/import_error
print more informative error msg when importing from install dir
- Loading branch information
Showing
6 changed files
with
33 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
# | ||
|
||
[run] | ||
relative_files = True | ||
branch = True | ||
plugins = Cython.Coverage | ||
include = | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,22 @@ | ||
# When importing from the root of the unpacked tarball or git checkout, | ||
# Python sees the "cftime" source directory and tries to load it, which fails. | ||
# (unless the package was built using "python setup.py build_ext --inplace" | ||
# so that _cftime.so exists in the cftime source dir). | ||
try: | ||
# init for cftime package | ||
from ._cftime import datetime | ||
except ImportError: | ||
import os.path as _op | ||
if _op.exists(_op.join(_op.dirname(__file__), '..', 'setup.py')): | ||
msg="You cannot import cftime from inside the install directory.\nChange to another directory first." | ||
raise ImportError(msg) | ||
else: | ||
raise | ||
from ._cftime import utime, JulianDayFromDate, DateFromJulianDay, UNIT_CONVERSION_FACTORS | ||
from ._cftime import _parse_date, date2index, time2index | ||
from ._cftime import datetime, real_datetime | ||
from ._cftime import _parse_date, date2index, time2index, real_datetime | ||
from ._cftime import DatetimeNoLeap, DatetimeAllLeap, Datetime360Day, DatetimeJulian, \ | ||
DatetimeGregorian, DatetimeProlepticGregorian | ||
DatetimeGregorian, DatetimeProlepticGregorian | ||
from ._cftime import microsec_units, millisec_units, \ | ||
sec_units, hr_units, day_units, min_units | ||
sec_units, hr_units, day_units, min_units | ||
from ._cftime import num2date, date2num, date2index, num2pydate | ||
from ._cftime import __version__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.