data directory not copied by install script
Data directory with astropy_iers_data files are not copied during package generation. As a result running a simple Time command fails as follows.
In [1]: from astropy.time import Time
...: Time.now().ut1
WARNING: IERSWarning: malformed IERS table from https://datacenter.iers.org/data/9/finals2000A.all: [Errno 2] No such file or directory: '/usr/lib/python3.11/site-packages/astropy_iers_data/data/ReadMe.finals2000A' [astropy.utils.iers.iers]
WARNING: IERSWarning: malformed IERS table from https://maia.usno.navy.mil/ser7/finals2000A.all: [Errno 2] No such file or directory: '/usr/lib/python3.11/site-packages/astropy_iers_data/data/ReadMe.finals2000A' [astropy.utils.iers.iers]
WARNING: IERSWarning: unable to download valid IERS file, using local IERS-B [astropy.utils.iers.iers]
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
Cell In[1], line 2
1 from astropy.time import Time
----> 2 Time.now().ut1
File /usr/lib/python3.11/site-packages/astropy/time/core.py:1758, in TimeBase.__getattr__(self, attr)
1756 else:
1757 tm = self.replicate()
-> 1758 tm._set_scale(attr)
1759 if tm.shape:
1760 # Prevent future modification of cached array-like object
1761 tm.writeable = False
File /usr/lib/python3.11/site-packages/astropy/time/core.py:797, in TimeBase._set_scale(self, scale)
795 pass
796 else:
--> 797 args.append(get_dt(jd1, jd2))
798 break
800 conv_func = getattr(erfa, sys1 + sys2)
File /usr/lib/python3.11/site-packages/astropy/time/core.py:2538, in Time._get_delta_ut1_utc(self, jd1, jd2)
2535 if not hasattr(self, "_delta_ut1_utc"):
2536 from astropy.utils.iers import earth_orientation_table
-> 2538 iers_table = earth_orientation_table.get()
2539 # jd1, jd2 are normally set (see above), except if delta_ut1_utc
2540 # is access directly; ensure we behave as expected for that case
2541 if jd1 is None:
File /usr/lib/python3.11/site-packages/astropy/utils/state.py:58, in ScienceState.get(cls)
53 @classmethod
54 def get(cls):
55 """
56 Get the current science state value.
57 """
---> 58 return cls.validate(cls._value)
File /usr/lib/python3.11/site-packages/astropy/utils/iers/iers.py:1001, in earth_orientation_table.validate(cls, value)
998 @classmethod
999 def validate(cls, value):
1000 if value is None:
-> 1001 value = IERS_Auto.open()
1002 if not isinstance(value, IERS):
1003
File /usr/lib/python3.11/site-packages/astropy/utils/iers/iers.py:1001, in earth_orientation_table.validate(cls, value)
998 @classmethod
999 def validate(cls, value):
1000 if value is None:
-> 1001 value = IERS_Auto.open()
1002 if not isinstance(value, IERS):
1003 raise ValueError("earth_orientation_table requires an IERS Table.")
raise ValueError("earth_orientation_table requires an IERS Table.")
File /usr/lib/python3.11/site-packages/astropy/utils/iers/iers.py:822, in IERS_Auto.open(cls)
817 else:
818 # Issue a warning here, perhaps user is offline. An exception
819 # will be raised downstream if actually trying to interpolate
820 # predictive values.
821 warn("unable to download valid IERS file, using local IERS-B", IERSWarning)
--> 822 cls.iers_table = IERS_B.open()
824 return cls.iers_table
File /usr/lib/python3.11/site-packages/astropy/utils/iers/iers.py:274, in IERS.open(cls, file, cache, **kwargs)
272 cls.iers_table = IERS_B.read(**kwargs)
273 else:
--> 274 cls.iers_table = cls.read(**kwargs)
275 return cls.iers_table
File /usr/lib/python3.11/site-packages/astropy/utils/iers/iers.py:739, in IERS_B.read(cls, file, readme, data_start)
736 if readme is None:
737 readme = IERS_B_README
--> 739 table = super().read(file, format="cds", readme=readme, data_start=data_start)
741 table.meta["data_path"] = file
742 table.meta["readme_path"] = readme
File /usr/lib/python3.11/site-packages/astropy/table/connect.py:62, in TableRead.__call__(self, *args, **kwargs)
59 units = kwargs.pop("units", None)
60 descriptions = kwargs.pop("descriptions", None)
---> 62 out = self.registry.read(cls, *args, **kwargs)
64 # For some readers (e.g., ascii.ecsv), the returned `out` class is not
65 # guaranteed to be the same as the desired output `cls`. If so,
66 # try coercing to desired class without copying (io.registry.read
67 # would normally do a copy). The normal case here is swapping
68 # Table <=> QTable.
69 if cls is not out.__class__:
File /usr/lib/python3.11/site-packages/astropy/io/registry/core.py:221, in UnifiedInputRegistry.read(self, cls, format, cache, *args, **kwargs)
218 kwargs.update({"filename": path})
220 reader = self.get_reader(format, cls)
--> 221 data = reader(*args, **kwargs)
223 if not isinstance(data, cls):
224 # User has read with a subclass where only the parent class is
225 # registered. This returns the parent class, so try coercing
226 # to desired subclass.
227 try:
File /usr/lib/python3.11/site-packages/astropy/io/ascii/connect.py:19, in io_read(format, filename, **kwargs)
17 format = re.sub(r"^ascii\.", "", format)
18 kwargs["format"] = format
---> 19 return read(filename, **kwargs)
File /usr/lib/python3.11/site-packages/astropy/utils/decorators.py:604, in deprecated_renamed_argument.<locals>.decorator.<locals>.wrapper(*args, **kwargs)
601 msg += f"\n Use {alternative} instead."
602 warnings.warn(msg, warning_type, stacklevel=2)
--> 604 return function(*args, **kwargs)
File /usr/lib/python3.11/site-packages/astropy/utils/decorators.py:604, in deprecated_renamed_argument.<locals>.decorator.<locals>.wrapper(*args, **kwargs)
601 msg += f"\n Use {alternative} instead."
602 warnings.warn(msg, warning_type, stacklevel=2)
--> 604 return function(*args, **kwargs)
[... skipping similar frames: deprecated_renamed_argument.<locals>.decorator.<locals>.wrapper at line 604 (2 times)]
File /usr/lib/python3.11/site-packages/astropy/utils/decorators.py:604, in deprecated_renamed_argument.<locals>.decorator.<locals>.wrapper(*args, **kwargs)
601 msg += f"\n Use {alternative} instead."
602 warnings.warn(msg, warning_type, stacklevel=2)
--> 604 return function(*args, **kwargs)
File /usr/lib/python3.11/site-packages/astropy/io/ascii/ui.py:463, in read(table, guess, **kwargs)
461 else:
462 reader = get_reader(**new_kwargs)
--> 463 dat = reader.read(table)
464 _read_trace.append(
465 {
466 "kwargs": copy.deepcopy(new_kwargs),
(...)
469 }
470 )
472 # Static analysis (pyright) indicates `dat` might be left undefined, so just
473 # to be sure define it at the beginning and check here.
File /usr/lib/python3.11/site-packages/astropy/io/ascii/cds.py:357, in Cds.read(self, table)
355 return table
356 else:
--> 357 return super().read(table)
File /usr/lib/python3.11/site-packages/astropy/io/ascii/core.py:1414, in BaseReader.read(self, table)
1411 newline = None
1413 # Get a list of the lines (rows) in the table
-> 1414 self.lines = self.inputter.get_lines(table, newline=newline)
1416 # Set self.data.data_lines to a slice of lines contain the data rows
1417 self.data.get_data_lines(self.lines)
File /usr/lib/python3.11/site-packages/astropy/io/ascii/core.py:335, in BaseInputter.get_lines(self, table, newline)
331 try:
332 if hasattr(table, "read") or (
333 "\n" not in table + "" and "\r" not in table + ""
334 ):
--> 335 with get_readable_fileobj(table, encoding=self.encoding) as fileobj:
336 table = fileobj.read()
337 if newline is None:
File /usr/lib/python3.11/contextlib.py:137, in _GeneratorContextManager.__enter__(self)
135 del self.args, self.kwds, self.func
136 try:
--> 137 return next(self.gen)
138 except StopIteration:
139 raise RuntimeError("generator didn't yield") from None
File /usr/lib/python3.11/site-packages/astropy/utils/data.py:364, in get_readable_fileobj(name_or_obj, encoding, cache, show_progress, remote_timeout, sources, http_headers, use_fsspec, fsspec_kwargs, close_files)
355 if is_url:
356 name_or_obj = download_file(
357 name_or_obj,
358 cache=cache,
(...)
362 http_headers=http_headers,
363 )
--> 364 fileobj = io.FileIO(name_or_obj, "r")
365 if is_url and not cache:
366 delete_fds.append(fileobj)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/python3.11/site-packages/astropy_iers_data/data/eopc04.1962-now'
To fix this I had to edit PKGBUILD and add a couple of commands to copy the data properly. I'm not sure where the proper fix for this should go, but the following fixes it for me.
diff --git a/PKGBUILD b/PKGBUILD
index 1a31553..3d05d9d 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -15,6 +15,8 @@ sha256sums=('348dad7dc09012e5abb490706c176ba3e4e384e68dbc505f5b7a79ca1a912940')
build() {
cd $_pyname-$pkgver
+ mkdir -p build/lib/astropy_iers_data/
+ cp -R astropy_iers_data/data build/lib/astropy_iers_data/
SETUPTOOLS_SCM_PRETEND_VERSION=${pkgver} \
python -m build --wheel --no-isolation --skip-dependency-check
}
This might be an upstream issue. My python packaging skills are very limited so this is probably not an optimal fix.