Skip to content
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
1 change: 0 additions & 1 deletion .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ lint.unfixable = [
"PLR0911", # too-many-return-statements
]
"astropy/table/*" = [
"PTH", # all flake8-use-pathlib
"S605", # Starting a process with a shell, possible injection detected
"TRY300", # Consider `else` block
]
Expand Down
16 changes: 8 additions & 8 deletions astropy/table/jsviewer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst

from os.path import abspath, dirname, join
from pathlib import Path

import astropy.config as _config
import astropy.io.registry as io_registry
Expand Down Expand Up @@ -32,9 +32,9 @@ class Conf(_config.ConfigNamespace):

conf = Conf()


EXTERN_JS_DIR = abspath(join(dirname(extern.__file__), "jquery", "data", "js"))
EXTERN_CSS_DIR = abspath(join(dirname(extern.__file__), "jquery", "data", "css"))
_TABLE_DIR = Path(extern.__file__).parent
EXTERN_JS_DIR = _TABLE_DIR.joinpath("jquery", "data", "js").resolve()
EXTERN_CSS_DIR = _TABLE_DIR.joinpath("jquery", "data", "css").resolve()
Comment thread
taldcroft marked this conversation as resolved.
Resolved

_SORTING_SCRIPT_PART_1 = """
var astropy_sort_num = function(a, b) {{
Expand Down Expand Up @@ -145,22 +145,22 @@ def __init__(self, use_local_files=False, display_length=50):
def jquery_urls(self):
if self._use_local_files:
return [
"file://" + join(EXTERN_JS_DIR, "jquery-3.6.0.min.js"),
"file://" + join(EXTERN_JS_DIR, "jquery.dataTables.min.js"),
f"file://{EXTERN_JS_DIR / 'jquery-3.6.0.min.js'}",
f"file://{EXTERN_JS_DIR / 'jquery.dataTables.min.js'}",
]
else:
return [conf.jquery_url, conf.datatables_url]

@property
def css_urls(self):
if self._use_local_files:
return ["file://" + join(EXTERN_CSS_DIR, "jquery.dataTables.css")]
return [f"file://{EXTERN_CSS_DIR / 'jquery.dataTables.css'}"]
else:
return conf.css_urls

def _jstable_file(self):
if self._use_local_files:
return "file://" + join(EXTERN_JS_DIR, "jquery.dataTables.min")
return f"file://{EXTERN_JS_DIR / 'jquery.dataTables.min'}"
else:
return conf.datatables_url[:-3]

Expand Down
11 changes: 6 additions & 5 deletions astropy/table/setup_package.py

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think something in here broke "exotic archs", see #16940 (comment)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick guess: is this from an arch were setuptools 72.2.0 and newer aren't available yet ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that mean we need to revert this PR?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, I'm seeing version 68.1.2. Let me revert this bit !

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#16942 👀

Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst

import os

from pathlib import Path

from numpy import get_include as get_numpy_include
from setuptools import Extension

ROOT = os.path.relpath(os.path.dirname(__file__))
ROOT = Path(__file__).parent.relative_to(Path.cwd())


def get_extensions():
sources = ["_np_utils.pyx", "_column_mixins.pyx"]
sources = [ROOT / "_np_utils.pyx", ROOT / "_column_mixins.pyx"]
include_dirs = [get_numpy_include()]

exts = [
Extension(
name="astropy.table." + os.path.splitext(source)[0],
name=f"astropy.table.{source.stem}",
define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")],
sources=[os.path.join(ROOT, source)],
sources=sources,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it known that Extension can take a list of Path instead of a list of str? Does this code get tested when building/installing astropy in CI testing?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's been supported by setuptools since version 72.2.0, which is why I set an explicit minimum requirement.

include_dirs=include_dirs,
)
for source in sources
Expand Down
6 changes: 3 additions & 3 deletions astropy/table/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from collections import OrderedDict, defaultdict
from collections.abc import Mapping
from copy import deepcopy
from pathlib import Path

import numpy as np
from numpy import ma
Expand Down Expand Up @@ -1919,7 +1920,6 @@ def show_in_browser(
that if a column with this name already exists, this option will be
ignored. Defaults to "idx".
"""
import os
import tempfile
import webbrowser
from urllib.parse import urljoin
Expand All @@ -1933,9 +1933,9 @@ def show_in_browser(
# We can't use NamedTemporaryFile here because it gets deleted as
# soon as it gets garbage collected.
tmpdir = tempfile.mkdtemp()
path = os.path.join(tmpdir, "table.html")
path = Path(tmpdir, "table.html")

with open(path, "w") as tmp:
with path.open("w") as tmp:
if jsviewer:
if show_row_index:
display_table = self._make_index_row_display_table(show_row_index)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ volint = "astropy.io.votable.volint:main"
wcslint = "astropy.wcs.wcslint:main"

[build-system]
requires = ["setuptools",
requires = ["setuptools>=72.2.0",
"setuptools_scm>=6.2",
"cython>=3.0.0, <4",
"numpy>=2.0.0, <3",
Expand Down