Skip to content

Commit

Permalink
Fix python sdist
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Stein <[email protected]>
  • Loading branch information
texodus committed Sep 21, 2024
1 parent d1378b2 commit 5067d1b
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 33 deletions.
11 changes: 8 additions & 3 deletions cmake/modules/FindInstallDependency.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,16 @@ function(psp_build_dep name cmake_file)
set(ARROW_LZ4 ON)
set(ARROW_WITH_ZSTD ON)
set(ARROW_WITH_LZ4 ON)
set(ARROW_ENABLE_THREADING OFF)
set(ARROW_NO_EXPORT ON)
if(WIN32 AND NOT PSP_BUILD_WASM)
set(ARROW_DEPENDENCY_SOURCE "BUNDLED")
if(PSP_WASM_BUILD)
set(ARROW_ENABLE_THREADING OFF)
else()
set(ARROW_ENABLE_THREADING ON)
if(WIN32)
set(ARROW_DEPENDENCY_SOURCE "BUNDLED")
endif()
endif()

include_directories(SYSTEM ${CMAKE_BINARY_DIR}/${name}-build/src)
add_subdirectory(${CMAKE_BINARY_DIR}/${name}-src/cpp/
${CMAKE_BINARY_DIR}/${name}-build
Expand Down
11 changes: 5 additions & 6 deletions cpp/perspective/src/cpp/arrow_csv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,12 +609,11 @@ csvToTable(
auto read_options = arrow::csv::ReadOptions::Defaults();
auto parse_options = arrow::csv::ParseOptions::Defaults();
auto convert_options = arrow::csv::ConvertOptions::Defaults();
// #ifdef PSP_PARALLEL_FOR
// read_options.use_threads = true;
// #else
// read_options.use_threads = false;
// #endif
read_options.use_threads = false;
#ifdef PSP_PARALLEL_FOR
read_options.use_threads = true;
#else
read_options.use_threads = false;
#endif
parse_options.newlines_in_values = true;

if (is_update) {
Expand Down
12 changes: 6 additions & 6 deletions cpp/perspective/src/cpp/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1211,12 +1211,12 @@ View<CTX_T>::data_slice_to_arrow(
options.codec = std::move(codec).ValueUnsafe();
}

// #ifdef PSP_PARALLEL_FOR
// options.use_threads = false;
// #else
// options.use_threads = false;
// #endif
options.use_threads = false;
#ifdef PSP_PARALLEL_FOR
options.use_threads = true;
#else
options.use_threads = false;
#endif

auto res = arrow::ipc::MakeStreamWriter(&sink, arrow_schema, options);
std::shared_ptr<arrow::ipc::RecordBatchWriter> writer = *res;
PSP_CHECK_ARROW_STATUS(writer->WriteRecordBatch(*batches));
Expand Down
1 change: 1 addition & 0 deletions examples/python-tornado/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import tornado.ioloop

import perspective
import perspective.handlers.tornado

here = os.path.abspath(os.path.dirname(__file__))
file_path = os.path.join(
Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

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

11 changes: 11 additions & 0 deletions rust/perspective-python/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import * as fs from "node:fs";
import sh from "../../tools/perspective-scripts/sh.mjs";
import * as url from "url";
import * as TOML from "@iarna/toml";

const __dirname = url.fileURLToPath(new URL(".", import.meta.url)).slice(0, -1);
const pkg = JSON.parse(
Expand Down Expand Up @@ -89,7 +90,13 @@ if (build_wheel) {
cmd.sh(`maturin build ${flags} --features=external-cpp ${target}`);
}

const old = fs.readFileSync("./pyproject.toml");

if (build_sdist) {
const toml = TOML.parse(old);
console.log(toml);
delete toml.tool.maturin["data"];
fs.writeFileSync("./pyproject.toml", TOML.stringify(toml));
cmd.sh(`maturin sdist`);
}

Expand All @@ -98,3 +105,7 @@ if (!build_wheel && !build_sdist) {
}

cmd.runSync();

if (build_sdist) {
fs.writeFileSync("./pyproject.toml", old);
}
1 change: 1 addition & 0 deletions rust/perspective-python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
},
"devDependencies": {
"@finos/perspective-scripts": "workspace:*",
"@iarna/toml": "^1.0.0-rc.1",
"cpy": "^9.0.1"
},
"dependencies": {
Expand Down
15 changes: 0 additions & 15 deletions rust/perspective-python/perspective/handlers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,3 @@
# ┃ This file is part of the Perspective library, distributed under the terms ┃
# ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
# ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

try:
from .aiohttp import PerspectiveAIOHTTPHandler # noqa: F401
except ImportError:
...

try:
from .starlette import PerspectiveStarletteHandler # noqa: F401
except ImportError:
...

try:
from .tornado import PerspectiveTornadoHandler # noqa: F401
except ImportError:
...
5 changes: 4 additions & 1 deletion rust/perspective-python/perspective/tests/core/test_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ def _syncify():
class TestAsync(object):
@classmethod
def setup_class(cls):
cls.loop = tornado.ioloop.IOLoop()
import asyncio

asyncio.set_event_loop(asyncio.new_event_loop())
cls.loop = tornado.ioloop.IOLoop.current()
cls.thread = threading.Thread(target=cls.loop.start)
cls.thread.daemon = True
cls.thread.start()
Expand Down
1 change: 1 addition & 0 deletions rust/perspective-python/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pandas==2.2.2
pyarrow==16.1.0
psutil==6.0.0
pytest==8.2.2
pytest-sugar==1.0.0
ruff==0.5.0
tornado==6.4.1
traitlets==5.14.3
Expand Down
2 changes: 1 addition & 1 deletion rust/perspective-python/test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ if (process.env.PSP_PYODIDE) {
execOpts
);
} else {
execFileSync("pytest", ["perspective/tests"], execOpts);
execFileSync("pytest", ["perspective/tests", "-W error"], execOpts);
}
1 change: 1 addition & 0 deletions rust/perspective-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ mod local_client;
mod local_session;
mod server;

pub use local_client::LocalClient;
pub use local_session::LocalSession;
pub use server::{Server, ServerError, SessionHandler};
2 changes: 1 addition & 1 deletion rust/perspective/tests/concurrent_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
use std::error::Error;
use std::sync::Arc;

use perspective::LocalClient;
use perspective_client::{OnUpdateOptions, TableInitOptions, UpdateData, UpdateOptions};
use perspective_server::LocalClient;
use tokio::sync::Mutex;

#[tokio::test]
Expand Down

0 comments on commit 5067d1b

Please sign in to comment.