Skip to content

Commit

Permalink
Remove cxx, statically link perspective-server in `perspective-py…
Browse files Browse the repository at this point in the history
…thon`

Signed-off-by: Andrew Stein <[email protected]>
  • Loading branch information
texodus committed Sep 2, 2024
1 parent 434eb3e commit b0d5674
Show file tree
Hide file tree
Showing 30 changed files with 398 additions and 624 deletions.
75 changes: 74 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,65 @@ jobs:
name: perspective-python-dist-${{ matrix.arch}}-${{ matrix.os }}-${{ matrix.python-version }}
path: rust/target/wheels/*.whl

# ,-,---. . . . ,--,--' .
# '|___/ . . . | ,-| ,-. ,-. ,-| `- | ,-. ,-. |-
# ,| \ | | | | | | ,-| | | | | , | |-' `-. |
# `-^---' `-^ ' `' `-^ `-^ ' ' `-^ `-' `-' `-' `'
#
# .-,--. .
# `|__/ . . ,-. |-
# )| \ | | `-. |
# `' ` `-^ `-' `'
#
build_and_test_rust:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-22.04
arch:
- x86_64
node-version: [20.x]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Config
id: config-step
uses: ./.github/actions/config

- name: Initialize Build
id: init-step
uses: ./.github/actions/install-deps
with:
javascript: "false"
arch: ${{ matrix.arch }}
manylinux: "false"
skip_cache: ${{ steps.config-step.outputs.SKIP_CACHE }}

# - name: Rust Build
# run: pnpm run build
# env:
# PACKAGE: "perspective-rs"
# PSP_ROOT_DIR: ${{ github.workspace }}

- name: Rust Test
run: pnpm run test
env:
PACKAGE: "perspective-rs"
PSP_ROOT_DIR: ${{ github.workspace }}

- name: Package
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: cargo package --allow-dirty -p perspective -p perspective-viewer -p perspective-js -p perspective-client -p perspective-server -p perspective-python

- uses: actions/upload-artifact@v4
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
with:
name: perspective-rust
path: rust/target/package/*.crate

# ,-,---. . . .-,--. . .
# '|___/ . . . | ,-| '|__/ . . ,-. ,-| . ,-| ,-.
# ,| \ | | | | | | .| | | | | | | | | | |-'
Expand All @@ -231,6 +290,7 @@ jobs:
# `-'
build_emscripten_wheel:
runs-on: ${{ matrix.os }}
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -534,7 +594,15 @@ jobs:
# `' `-^ ^-' `' ' `-' ' '
#
publish:
needs: [build_and_test_juptyerlab, test_python, test_js, benchmark_js]
needs:
[
build_and_test_juptyerlab,
test_python,
test_js,
benchmark_js,
build_emscripten_wheel,
build_and_test_rust,
]
if: startsWith(github.ref, 'refs/tags/v')
strategy:
matrix:
Expand Down Expand Up @@ -589,6 +657,10 @@ jobs:
with:
name: perspective-js-benchmarks

- uses: actions/download-artifact@v4
with:
name: perspective-rust

# - uses: actions/download-artifact@v4
# with:
# name: perspective-python-benchmarks
Expand Down Expand Up @@ -633,5 +705,6 @@ jobs:
*.tar.gz
*.tgz
*.arrow
*.crate
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5 changes: 2 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions cpp/perspective/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -676,12 +676,10 @@ elseif(PSP_CPP_BUILD OR PSP_PYTHON_BUILD)
if(PSP_WASM_BUILD)
set(CMAKE_EXECUTABLE_SUFFIX ".wasm")
set(CMAKE_EXE_LINKER_FLAGS "${PSP_WASM_LINKER_FLAGS} --pre-js \"${PSP_CPP_SRC}/env.js\" ")
add_library(psp ${PYTHON_SOURCE_FILES})
add_executable(psppy ${PSP_CPP_SRC}/src/cpp/binding_api.cpp)
target_compile_definitions(psppy PRIVATE PSP_ENABLE_PYTHON=1 PSP_ENABLE_WASM=1)
target_link_libraries(psppy PRIVATE psp protos)
add_library(psp STATIC ${PYTHON_SOURCE_FILES})
target_compile_definitions(psp PRIVATE PSP_ENABLE_PYTHON=1 PSP_ENABLE_WASM=1)
else()
add_library(psp SHARED ${PYTHON_SOURCE_FILES})
add_library(psp STATIC ${PYTHON_SOURCE_FILES})
target_compile_definitions(psp PRIVATE PSP_ENABLE_PYTHON=1 PSP_PARALLEL_FOR=1)
endif()
# add_library(psppy SHARED ${PYTHON_BINDING_SOURCE_FILES})
Expand Down
3 changes: 1 addition & 2 deletions cpp/perspective/src/cpp/pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ t_pool::t_pool() : m_sleep(0) { m_run.clear(); }
t_pool::t_pool() :
// : m_update_delegate(empty_callback())
#ifdef PSP_PARALLEL_FOR
m_lock(new std::shared_mutex())
m_lock(new std::shared_mutex()),
#endif
,
m_sleep(0) {
m_run.clear();
}
Expand Down
1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ packages:
- "packages/perspective-jupyterlab"
- "packages/perspective-webpack-plugin"
- "packages/perspective-cli"
- "rust/perspective"
- "rust/perspective-js"
- "rust/perspective-viewer"
- "rust/perspective-python"
Expand Down
15 changes: 7 additions & 8 deletions rust/perspective-python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,32 @@ license = "Apache-2.0"
homepage = "https://perspective.finos.org"
authors = ["Andrew Stein <[email protected]>"]
keywords = []
build = "build/main.rs"
build = "build.rs"
include = [
"bench/**/*.py",
"build/**/*",
"build.rs",
"./Cargo.toml",
"./package.json",
"perspective/**/*.py",
"./pyproject.toml",
"src/**/*.rs",
"docs/**/*",
"cpp/**/*",
"cmake/**/*",
]

[package.metadata.docs.rs]
rustdoc-args = ["--html-in-header", "docs/index.html"]

[features]
default = []
sdist = []
external-cpp = ["perspective-client/external-proto"]
external-cpp = [
"perspective-client/external-proto",
"perspective-server/external-cpp",
]

[lib]
crate-type = ["cdylib"]

[build-dependencies]
cxx-build = "1.0.115"
cmake = "0.1.50"
num_cpus = "^1.16.0"
pyo3-build-config = "0.20.2"
Expand All @@ -55,7 +54,7 @@ python-config-rs = "0.1.2"
[dependencies]
async-lock = "2.5.0"
perspective-client = { version = "3.0.2", path = "../perspective-client" }
# perspective-server = { version = "3.0.2", path = "../perspective-server" }
perspective-server = { version = "3.0.2", path = "../perspective-server" }
pollster = "0.3.0"
extend = "1.1.2"
futures = "0.3.28"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,22 @@
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

#pragma once
use std::error::Error;

#include "perspective/proto_api.h"
#include <memory>
#include "rust/cxx.h"
fn main() -> Result<(), Box<dyn Error>> {
pyo3_build_config::add_extension_module_link_args();

struct ResponseBatch;
// Pass the `perspective_client` links metadata flag so that the `inherit_docs`
// macro can find the path to the docs.
println!(
"cargo:rustc-env=PERSPECTIVE_CLIENT_DOCS_PATH={}",
std::env::var("DEP_PERSPECTIVE_CLIENT_DOCS_PATH").unwrap()
);

std::unique_ptr<ProtoApiServer> new_proto_server();
if std::option_env!("PSP_DISABLE_CPP").is_some() {
return Ok(());
}

std::uint32_t new_session(const ProtoApiServer& self);
void close_session(const ProtoApiServer& server, std::uint32_t client_id);

rust::Box<ResponseBatch> handle_request(
const ProtoApiServer& self,
std::uint32_t client_id,
rust::Slice<const std::uint8_t> message
);

rust::Box<ResponseBatch> poll(const ProtoApiServer& self);
std::env::set_var("CARGO_FEATURE_PYTHON", "1");
Ok(())
}
85 changes: 0 additions & 85 deletions rust/perspective-python/build/main.rs

This file was deleted.

Loading

0 comments on commit b0d5674

Please sign in to comment.