Skip to content

Commit 2d0f8f9

Browse files
committed
Rename libbinding to libpsppy, fix JS tests, merge gha scripts
1 parent ac28753 commit 2d0f8f9

File tree

20 files changed

+177
-432
lines changed

20 files changed

+177
-432
lines changed

.github/workflows/build.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,56 @@ jobs:
10331033
path: python/perspective/dist/*.tar.gz
10341034
if: ${{ matrix.os == 'macos-11' }}
10351035

1036+
build-pyodide:
1037+
runs-on: ubuntu-22.04
1038+
needs: [initialize]
1039+
env:
1040+
PYODIDE_VERSION: 0.23.2
1041+
# PYTHON_VERSION and EMSCRIPTEN_VERSION are determined by PYODIDE_VERSION.
1042+
# The appropriate versions can be found in the Pyodide repodata.json
1043+
# "info" field, or in Makefile.envs:
1044+
# https://github.com/pyodide/pyodide/blob/main/Makefile.envs#L2
1045+
PYTHON_VERSION: 3.11.2
1046+
EMSCRIPTEN_VERSION: 3.1.32
1047+
steps:
1048+
- name: Checkout perspective
1049+
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
1050+
1051+
- name: set up python
1052+
id: setup-python
1053+
uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b # v4.6.0
1054+
with:
1055+
python-version: ${{ env.PYTHON_VERSION }}
1056+
1057+
- uses: mymindstorm/setup-emsdk@ab889da2abbcbb280f91ec4c215d3bb4f3a8f775 # v12
1058+
with:
1059+
version: ${{ env.EMSCRIPTEN_VERSION }}
1060+
actions-cache-folder: emsdk-cache
1061+
1062+
- name: copy files
1063+
run: |
1064+
npm install -g yarn
1065+
yarn --frozen-lockfile
1066+
yarn build_python --setup-only
1067+
1068+
- name: Linux init steps
1069+
run: sudo node scripts/install_tools.js
1070+
1071+
- name: Install pyodide-build
1072+
run: pip install pyodide-build==$PYODIDE_VERSION
1073+
1074+
- name: Build
1075+
# Without --exports=pyinit, pyodide-build tries to export all symbols from every .o,
1076+
# which causes the em++ linker command line invocation to be so long
1077+
# that the command fails.
1078+
run: pyodide build python/perspective --exports=pyinit
1079+
1080+
- name: Upload pyodide wheel
1081+
uses: actions/upload-artifact@v3
1082+
with:
1083+
name: perspective-python-dist-pyodide
1084+
path: dist/*.whl
1085+
10361086
##########################################################################################################################
10371087
##########################################################################################################################
10381088

.github/workflows/pyodide.yml

Lines changed: 0 additions & 67 deletions
This file was deleted.

cpp/perspective/CMakeLists.txt

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,6 @@ set(PSP_WASM_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} \
541541
-s EXPORT_NAME=\"load_perspective\" \
542542
-s MAXIMUM_MEMORY=4gb \
543543
-s ERROR_ON_UNDEFINED_SYMBOLS=1 \
544-
-s ENVIRONMENT=worker \
545544
")
546545

547546
if(PSP_WASM_BUILD)
@@ -592,51 +591,50 @@ elseif(PSP_CPP_BUILD OR PSP_PYTHON_BUILD)
592591
# Python extra targets #
593592
# #######################
594593
add_library(psp STATIC ${PYTHON_SOURCE_FILES})
595-
add_library(binding SHARED ${PYTHON_BINDING_SOURCE_FILES})
594+
add_library(psppy SHARED ${PYTHON_BINDING_SOURCE_FILES})
596595
if(PSP_PYODIDE)
597-
set(CMAKE_EXE_LINKER_FLAGS "${PSP_WASM_LINKER_FLAGS}")
598596
set(PSP_PYTHON_DEFS PSP_ENABLE_WASM=1)
599597
else()
600598
set(PSP_PYTHON_DEFS PSP_ENABLE_PYTHON_THREADING=1)
601599
endif()
602600
target_compile_definitions(psp PRIVATE ${PSP_PYTHON_DEFS})
603-
target_compile_definitions(binding PRIVATE ${PSP_PYTHON_DEFS})
601+
target_compile_definitions(psppy PRIVATE ${PSP_PYTHON_DEFS})
604602

605603
include_directories(${PSP_PYTHON_SRC}/include)
606604

607605
target_compile_definitions(psp PRIVATE PSP_ENABLE_PYTHON=1)
608-
target_compile_definitions(binding PRIVATE PSP_ENABLE_PYTHON=1)
606+
target_compile_definitions(psppy PRIVATE PSP_ENABLE_PYTHON=1)
609607

610608
if(WIN32)
611-
target_compile_definitions(binding PRIVATE WIN32=1)
612-
target_compile_definitions(binding PRIVATE _WIN32=1)
609+
target_compile_definitions(psppy PRIVATE WIN32=1)
610+
target_compile_definitions(psppy PRIVATE _WIN32=1)
613611

614612
# .dll not importable
615-
set_property(TARGET binding PROPERTY SUFFIX .pyd)
613+
set_property(TARGET psppy PROPERTY SUFFIX .pyd)
616614
elseif(PSP_PYODIDE)
617615
target_compile_options(psp PRIVATE -fvisibility=hidden)
618-
target_compile_options(binding PRIVATE -fvisibility=hidden)
616+
target_compile_options(psppy PRIVATE -fvisibility=hidden)
619617
elseif(MACOS OR NOT MANYLINUX)
620-
target_compile_options(binding PRIVATE -Wdeprecated-declarations)
618+
target_compile_options(psppy PRIVATE -Wdeprecated-declarations)
621619
set_property(TARGET psp PROPERTY INSTALL_RPATH ${CMAKE_INSTALL_RPATH} ${module_origin_path})
622-
set_property(TARGET binding PROPERTY INSTALL_RPATH ${CMAKE_INSTALL_RPATH} ${module_origin_path})
620+
set_property(TARGET psppy PROPERTY INSTALL_RPATH ${CMAKE_INSTALL_RPATH} ${module_origin_path})
623621

624622
target_compile_options(psp PRIVATE -fvisibility=hidden)
625-
target_compile_options(binding PRIVATE -fvisibility=hidden)
623+
target_compile_options(psppy PRIVATE -fvisibility=hidden)
626624
else()
627-
target_compile_options(binding PRIVATE -Wdeprecated-declarations)
625+
target_compile_options(psppy PRIVATE -Wdeprecated-declarations)
628626
endif()
629627

630628
# Link against minimal arrow static library
631629
target_link_libraries(psp arrow re2)
632-
target_link_libraries(binding psp)
630+
target_link_libraries(psppy psp)
633631

634632
# The compiled libraries will be put in CMAKE_LIBRARY_OUTPUT_DIRECTORY by default. In the
635633
# setup.py file, we designate this to be in the build/lib.<platform> directory. However,
636634
# since we want to be able to test perspective in-source, we also copy the libraries into
637635
# the source folder. These two commands do that.
638636
add_custom_command(TARGET psp POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:psp> ${PSP_PYTHON_SRC}/table/)
639-
add_custom_command(TARGET binding POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:binding> ${PSP_PYTHON_SRC}/table/)
637+
add_custom_command(TARGET psppy POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:psppy> ${PSP_PYTHON_SRC}/table/)
640638

641639
# #######################
642640
else()
@@ -649,7 +647,7 @@ elseif(PSP_CPP_BUILD OR PSP_PYTHON_BUILD)
649647
target_compile_options(psp PRIVATE $<$<CONFIG:DEBUG>:-fPIC -O0>)
650648

651649
if(PSP_PYTHON_BUILD AND NOT PSP_PYODIDE)
652-
target_compile_options(binding PRIVATE $<$<CONFIG:DEBUG>:-fPIC -O0>)
650+
target_compile_options(psppy PRIVATE $<$<CONFIG:DEBUG>:-fPIC -O0>)
653651
endif()
654652
elseif(WIN32)
655653
target_compile_definitions(psp PRIVATE PERSPECTIVE_EXPORTS=1)

cpp/perspective/src/cpp/computed_function.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2023,7 +2023,7 @@ namespace computed_function {
20232023
number = val.to_double();
20242024
}
20252025

2026-
#if defined(PSP_ENABLE_WASM) && defined(PSP_ENABLE_PYTHON)
2026+
#if defined(PSP_ENABLE_WASM) && !defined(PSP_ENABLE_PYTHON)
20272027
// check for overflow
20282028
if (number > std::numeric_limits<std::int32_t>::max()
20292029
|| number < std::numeric_limits<std::int32_t>::min()) {

packages/perspective/src/js/api/server.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -371,13 +371,18 @@ export class Server {
371371
}
372372

373373
/**
374-
* Send an error to the client.
374+
* Send an error to the client. If this method fails, we need to consume it
375+
* as this method is frequently called itself from a `catch` block.
375376
*/
376377
process_error(msg, error) {
377-
this.post({
378-
id: msg.id,
379-
error: error_to_json(error),
380-
});
378+
try {
379+
this.post({
380+
id: msg.id,
381+
error: error_to_json(error),
382+
});
383+
} catch (e) {
384+
console.error("Error handler failed: {}", error);
385+
}
381386
}
382387

383388
/**

python/perspective/perspective/include/perspective/python.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ namespace binding {}
5050
*/
5151
using namespace perspective::binding;
5252

53-
PYBIND11_MODULE(libbinding, m) {
53+
PYBIND11_MODULE(libpsppy, m) {
5454
/******************************************************************************
5555
*
5656
* PerspectiveCppError

python/perspective/perspective/libpsp.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@
1111

1212

1313
def is_libpsp():
14-
"""Was libbinding successfully loaded in this module?"""
14+
"""Was libpsppy successfully loaded in this module?"""
1515
return __is_libpsp__
1616

1717

1818
__is_libpsp__ = True
1919

2020
try:
21-
# Load all `libbinding` depending modules in one go, otherwise nothing
22-
# dependent on `libbinding` is exposed.
21+
# Load all `libpsppy` depending modules in one go, otherwise nothing
22+
# dependent on `libpsppy` is exposed.
2323
from .table import *
2424
from .manager import *
2525
from .viewer import *
26-
from .table.libbinding import (
26+
from .table.libpsppy import (
2727
init_expression_parser,
2828
)
2929

python/perspective/perspective/table/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88

99
from .table import Table
1010
from .view import View
11-
from .libbinding import PerspectiveCppError
11+
from .libpsppy import PerspectiveCppError
1212

1313
__all__ = ["Table", "View", "PerspectiveCppError"]

python/perspective/perspective/table/_accessor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from ..core.data.pd import _parse_datetime_index
1717
from ..core.exception import PerspectiveError
1818
from ._date_validator import _PerspectiveDateValidator
19-
from .libbinding import t_dtype
19+
from .libpsppy import t_dtype
2020

2121

2222
def _flatten_structure(array):
@@ -189,7 +189,7 @@ def marshal(self, cidx, ridx, dtype):
189189
Args:
190190
cidx (:obj:`int`)
191191
ridx (:obj:`int`)
192-
dtype (:obj:`.libbinding.t_dtype`)
192+
dtype (:obj:`.libpsppy.t_dtype`)
193193
194194
Returns:
195195
object or None

python/perspective/perspective/table/_data_formatter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import numpy as np
1010
from math import floor, ceil, trunc
1111
from ._constants import COLUMN_SEPARATOR_STRING
12-
from .libbinding import (
12+
from .libpsppy import (
1313
get_data_slice_unit,
1414
get_data_slice_zero,
1515
get_data_slice_one,

0 commit comments

Comments
 (0)