Copilot commented on code in PR #743:
URL: https://github.com/apache/tsfile/pull/743#discussion_r2958855841
##########
python/tsfile/__init__.py:
##########
@@ -18,10 +18,16 @@
import ctypes
import os
-import platform
-system = platform.system()
-if system == "Windows":
- ctypes.WinDLL(os.path.join(os.path.dirname(__file__), "libtsfile.dll"),
winmode=0)
+import sys
+
+if sys.platform == "win32":
+ _pkg_dir = os.path.dirname(os.path.abspath(__file__))
+ os.add_dll_directory(_pkg_dir)
+ # Preload libtsfile.dll with absolute path to bypass DLL search issues.
+ # This ensures it's already in memory when .pyd extensions reference it.
+ _tsfile_dll = os.path.join(_pkg_dir, "libtsfile.dll")
+ if os.path.isfile(_tsfile_dll):
+ ctypes.CDLL(_tsfile_dll)
Review Comment:
On Windows, `os.add_dll_directory()` returns a handle object that must be
kept alive; if it gets garbage-collected, the directory is removed from the DLL
search path. Since the return value isn't stored, the added directory may be
immediately dropped, causing intermittent `ImportError` when the .pyd tries to
resolve `libtsfile.dll` (and its dependencies). Store the handle in a
module-level variable (or use a context manager that stays alive for the
process lifetime).
##########
.github/workflows/unit-test-cpp.yml:
##########
@@ -109,6 +109,12 @@ jobs:
shell: bash
run: |
if [[ "$RUNNER_OS" == "Linux" ]]; then
+ if command -v apt-get >/dev/null 2>&1; then
+ sudo apt-get update
+ sudo apt-get install -y uuid-dev
+ elif command -v yum >/dev/null 2>&1; then
+ sudo yum install -y libuuid-devel
+ fi
Review Comment:
This step now installs `uuid-dev`/`libuuid-devel` conditionally (apt/yum),
but the script later unconditionally runs `sudo apt-get install -y uuid-dev`
again. This duplicates work and can fail on non-apt images. Remove the later
`apt-get` install (or move the clang-format setup into the apt/yum branches so
uuid is installed exactly once).
##########
pom.xml:
##########
@@ -135,6 +135,8 @@
<exclude>**/tsfile.egg-info/**</exclude>
<!-- Exclude third_party-->
<exclude>**/third_party/**</exclude>
+ <exclude>**/.python-version</exclude>
+ <exclude>**/**venv-py**/**</exclude>
Review Comment:
The RAT exclude pattern `**/**venv-py**/**` is hard to reason about and may
not behave as intended with Ant-style patterns (where `**` is only special as a
full path segment). Consider simplifying it to an unambiguous pattern like
`**/venv-py*/**` to ensure virtualenv directories are consistently excluded.
##########
python/setup.py:
##########
@@ -19,151 +19,134 @@
import os
import platform
Review Comment:
`platform` is imported but no longer used in this script. Drop the import to
avoid confusion and keep `setup.py` minimal (especially since it executes
during builds).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]