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
25 changes: 21 additions & 4 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ jobs:
-Dspotless.check.skip=true -Dspotless.apply.skip=true
test -d cpp/target/build/lib
test -d cpp/target/build/include
cp /mingw64/bin/libstdc++-6.dll cpp/target/build/lib/
cp /mingw64/bin/libgcc_s_seh-1.dll cpp/target/build/lib/
cp /mingw64/bin/libwinpthread-1.dll cpp/target/build/lib/

- name: Upload C++ build output
uses: actions/upload-artifact@v7
Expand Down Expand Up @@ -257,13 +260,25 @@ jobs:
name: tsfile-cpp-windows
path: cpp/target/build/

- name: Verify C++ artifacts exist
shell: msys2 {0}
run: |
set -euxo pipefail
ls -laR cpp/target/build/lib/
ls -laR cpp/target/build/include/
test -f cpp/target/build/lib/libtsfile.dll
test -f cpp/target/build/lib/libtsfile.dll.a
test -f cpp/target/build/lib/libstdc++-6.dll
test -f cpp/target/build/lib/libgcc_s_seh-1.dll
test -f cpp/target/build/lib/libwinpthread-1.dll

- name: Build wheel
shell: msys2 {0}
run: |
set -euxo pipefail
export JAVA_HOME="$(cygpath "$JAVA_HOME")"
export PYTHON_HOME="$(cygpath "$pythonLocation")"
export PATH="$PYTHON_HOME:$PYTHON_HOME/Scripts:$JAVA_HOME/bin:$PATH"
export PATH="/mingw64/bin:$PYTHON_HOME:$PYTHON_HOME/Scripts:$JAVA_HOME/bin:$PATH"

# Build wheel via Maven (no clean — keep C++ artifacts from previous job)
chmod +x mvnw || true
Expand All @@ -272,14 +287,17 @@ jobs:
case "${{ matrix.python-version }}" in
3.9) BLACK_VER_PROP="-Dblack.version=25.11.0" ;;
esac
../mvnw package -DskipTests \
../mvnw package -DskipTests -Dmaven.test.skip=true \
-Dspotless.check.skip=true -Dspotless.apply.skip=true \
${BLACK_VER_PROP}
ls -la dist/

- name: Verify wheel
shell: bash
shell: msys2 {0}
run: |
set -euxo pipefail
export PYTHON_HOME="$(cygpath "$pythonLocation")"
export PATH="$PYTHON_HOME:$PYTHON_HOME/Scripts:$PATH"
python -m pip install python/dist/*.whl
python -c "import tsfile, tsfile.tsfile_reader as r; print('import-ok')"

Expand All @@ -288,4 +306,3 @@ jobs:
with:
name: tsfile-wheels-windows-py${{ matrix.python-version }}
path: python/dist/*.whl

2 changes: 1 addition & 1 deletion cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ endif ()
if (POLICY CMP0079)
cmake_policy(SET CMP0079 NEW)
endif ()
set(TsFile_CPP_VERSION 2.2.1.dev)
set(TsFile_CPP_VERSION 2.3.1)

if (MSVC)
# MSVC does not provide a /std:c++11 flag; C++11 is its implicit baseline.
Expand Down
10 changes: 4 additions & 6 deletions cpp/src/reader/filter/and_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,20 @@ class AndFilter : public BinaryFilter {
~AndFilter() {}
AndFilter(Filter* left, Filter* right) : BinaryFilter(left, right) {}

FORCE_INLINE bool satisfy(Statistic* statistic) {
bool satisfy(Statistic* statistic) {
return left_->satisfy(statistic) && right_->satisfy(statistic);
}

FORCE_INLINE bool satisfy(int64_t time, int64_t value) {
bool satisfy(int64_t time, int64_t value) {
return left_->satisfy(time, value) && right_->satisfy(time, value);
}

FORCE_INLINE bool satisfy_start_end_time(int64_t start_time,
int64_t end_time) {
bool satisfy_start_end_time(int64_t start_time, int64_t end_time) {
return left_->satisfy_start_end_time(start_time, end_time) &&
right_->satisfy_start_end_time(start_time, end_time);
}

FORCE_INLINE bool contain_start_end_time(int64_t start_time,
int64_t end_time) {
bool contain_start_end_time(int64_t start_time, int64_t end_time) {
return left_->contain_start_end_time(start_time, end_time) &&
right_->contain_start_end_time(start_time, end_time);
}
Expand Down
10 changes: 4 additions & 6 deletions cpp/src/reader/filter/or_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,20 @@ class OrFilter : public BinaryFilter {
OrFilter(Filter* left, Filter* right) : BinaryFilter(left, right) {}
~OrFilter() {}

FORCE_INLINE bool satisfy(Statistic* statistic) {
bool satisfy(Statistic* statistic) {
return left_->satisfy(statistic) || right_->satisfy(statistic);
}

FORCE_INLINE bool satisfy(int64_t time, int64_t value) {
bool satisfy(int64_t time, int64_t value) {
return left_->satisfy(time, value) || right_->satisfy(time, value);
}

FORCE_INLINE bool satisfy_start_end_time(int64_t start_time,
int64_t end_time) {
bool satisfy_start_end_time(int64_t start_time, int64_t end_time) {
return left_->satisfy_start_end_time(start_time, end_time) ||
right_->satisfy_start_end_time(start_time, end_time);
}

FORCE_INLINE bool contain_start_end_time(int64_t start_time,
int64_t end_time) {
bool contain_start_end_time(int64_t start_time, int64_t end_time) {
return left_->contain_start_end_time(start_time, end_time) ||
right_->contain_start_end_time(start_time, end_time);
}
Expand Down
2 changes: 2 additions & 0 deletions python/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
<goal>exec</goal>
</goals>
<configuration>
<skip>${skipTests:-false}</skip>
<executable>${python.venv.bin}${python.exe.bin}</executable>
<arguments>
<argument>-m</argument>
Expand All @@ -158,6 +159,7 @@
<goal>exec</goal>
</goals>
<configuration>
<skip>${skipTests:-false}</skip>
<executable>${python.venv.bin}pytest</executable>
<arguments>
<argument>${project.basedir}/tests</argument>
Expand Down
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "tsfile"
version = "2.2.1.dev"
version = "2.3.1"
requires-python = ">=3.9"
description = "TsFile Python"
readme = {file = "README.md", content-type = "text/markdown"}
Expand Down
35 changes: 30 additions & 5 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
ROOT = Path(__file__).parent.resolve()
PKG = ROOT / "tsfile"

version = "2.2.1.dev"
version = "2.3.1"


def _find_cpp_build():
Expand Down Expand Up @@ -151,19 +151,40 @@ def _find_lib(root, patterns):
# Copy MinGW runtime DLLs next to tsfile.dll so Python can find them.
# Python 3.8+ does not search PATH for DLLs; they must sit in the
# same directory as the .pyd extensions (os.add_dll_directory).
# Prefer runtime DLLs captured from the same MSYS2 environment that
# built libtsfile.dll. Mixing MinGW runtime DLLs from a different
# install can load successfully but fail later with WinError 127 when
# libtsfile.dll imports a newer runtime symbol.
_mingw_search_dirs = [CPP_LIB]
for _dir in os.environ.get("PATH", "").split(os.pathsep):
if _dir:
_mingw_search_dirs.append(Path(_dir))
_msys_prefix = os.environ.get("MSYSTEM_PREFIX")
if _msys_prefix:
_mingw_search_dirs.append(Path(_msys_prefix) / "bin")
for _extra in (
Path("C:/msys64/mingw64/bin"),
Path("C:/ProgramData/mingw64/mingw64/bin"),
):
if _extra.is_dir():
_mingw_search_dirs.append(_extra)

for _mingw_dll in (
"libstdc++-6.dll",
"libgcc_s_seh-1.dll",
"libwinpthread-1.dll",
):
for _dir in os.environ.get("PATH", "").split(os.pathsep):
_src = Path(_dir) / _mingw_dll
for _dir in _mingw_search_dirs:
_src = _dir / _mingw_dll
if _src.is_file():
shutil.copy2(_src, PKG / _mingw_dll)
print(f"setup.py: copied {_mingw_dll} from {_src}")
break
else:
print(f"setup.py: WARNING - {_mingw_dll} not found on PATH")
raise FileNotFoundError(
f"setup.py: MinGW runtime DLL {_mingw_dll} not found; "
"ensure mingw-w64-x86_64-gcc is on PATH or MSYSTEM_PREFIX is set"
)
else:
raise RuntimeError(f"Unsupported platform: {sys.platform}")

Expand Down Expand Up @@ -197,8 +218,11 @@ def finalize_options(self):
extra_compile_args += ["-O3", "-std=c++11", "-fvisibility=hidden", "-fPIC"]
extra_link_args += ["-Wl,-rpath,@loader_path", "-stdlib=libc++"]
elif sys.platform == "win32":
libraries = ["tsfile"]
if win_toolchain == "mingw":
# Resolve EH/runtime symbols from MinGW runtimes before libtsfile.dll.a.
# Otherwise _Unwind_Resume is recorded against libtsfile.dll and loading
# the .pyd fails with WinError 127 on Windows.
libraries = ["gcc_s", "stdc++", "tsfile"]
extra_compile_args += [
"-O2",
"-std=c++11",
Expand All @@ -208,6 +232,7 @@ def finalize_options(self):
"-D_WIN64",
]
else: # msvc
libraries = ["tsfile"]
# cl.exe rejects the GCC-style flags above. Mirror the options the
# C++ module itself is built with (see cpp/CMakeLists.txt). C++17 is
# required because Cython 3 emits inline variables (error C7525); the
Expand Down
23 changes: 20 additions & 3 deletions python/tsfile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,32 @@

_pkg_dir = os.path.dirname(os.path.abspath(__file__))


def _preload_dll(path):
if not os.path.isfile(path):
return
try:
ctypes.CDLL(path)
except OSError:
pass


if sys.platform == "win32":
# Keep the handle alive for the lifetime of this module. CPython's reference
# counting frees the object immediately if not stored, which calls
# RemoveDllDirectory and undoes the registration before any .pyd is loaded.
_dll_dir = os.add_dll_directory(_pkg_dir)
# Preload the tsfile DLL so Windows finds it by base-name when loading the
# Cython extensions. Store the handle to prevent the DLL from being
# unloaded prematurely.
# Preload MinGW runtime DLLs before libtsfile.dll. Python 3.8+ does not
# search PATH for DLL dependencies; they must live next to the extensions.
for _mingw_dll in (
"libwinpthread-1.dll",
"libgcc_s_seh-1.dll",
"libstdc++-6.dll",
):
_preload_dll(os.path.join(_pkg_dir, _mingw_dll))
# Preload the tsfile DLL so Windows finds it when loading Cython extensions.
# MSVC builds produce "tsfile.dll"; MinGW builds produce "libtsfile.dll".
_tsfile_cdll = None
for _dll_name in ("tsfile.dll", "libtsfile.dll"):
_tsfile_dll = os.path.join(_pkg_dir, _dll_name)
if os.path.isfile(_tsfile_dll):
Expand Down
Loading