hongzhi-gao commented on code in PR #743:
URL: https://github.com/apache/tsfile/pull/743#discussion_r2937893758
##########
python/setup.py:
##########
@@ -19,151 +19,134 @@
import os
import platform
import shutil
-
+import sys
import numpy as np
+
+from pathlib import Path
from Cython.Build import cythonize
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
+ROOT = Path(__file__).parent.resolve()
+PKG = ROOT / "tsfile"
+CPP_OUT = ROOT / ".." / "cpp" / "target" / "build"
+CPP_LIB = CPP_OUT / "lib"
+CPP_INC = CPP_OUT / "include"
+
version = "2.2.1.dev"
system = platform.system()
-
-def copy_tsfile_lib(source_dir, target_dir, suffix):
- lib_file_name = f"libtsfile.{suffix}"
- source = os.path.join(source_dir, lib_file_name)
- target = os.path.join(target_dir, lib_file_name)
-
- if os.path.exists(source):
- shutil.copyfile(source, target)
-
- if system == "Linux":
- link_name = os.path.join(target_dir, "libtsfile.so")
- if os.path.exists(link_name):
- os.remove(link_name)
- os.symlink(lib_file_name, link_name)
- elif system == "Darwin":
- link_name = os.path.join(target_dir, "libtsfile.dylib")
- if os.path.exists(link_name):
- os.remove(link_name)
- os.symlink(lib_file_name, link_name)
-
-
-project_dir = os.path.dirname(os.path.abspath(__file__))
-tsfile_py_include = os.path.join(project_dir, "tsfile", "include")
-
-if os.path.exists(tsfile_py_include):
- shutil.rmtree(tsfile_py_include)
-
-shutil.copytree(
- os.path.join(project_dir, "..", "cpp", "target", "build", "include"),
- os.path.join(tsfile_py_include, ""),
-)
-
-
-def copy_tsfile_header(source):
- for file in source:
- if os.path.exists(file):
- target = os.path.join(tsfile_py_include, os.path.basename(file))
- shutil.copyfile(file, target)
-
-
-## Copy C wrapper header.
-# tsfile/cpp/src/cwrapper/tsfile_cwrapper.h
-source_headers = [
- os.path.join(project_dir, "..", "cpp", "src", "cwrapper",
"tsfile_cwrapper.h"),
-]
-
-copy_tsfile_header(source_headers)
-
-## Copy shared library
-tsfile_shared_source_dir = os.path.join(project_dir, "..", "cpp", "target",
"build", "lib")
-tsfile_shared_dir = os.path.join(project_dir, "tsfile")
-
-if system == "Darwin":
- copy_tsfile_lib(tsfile_shared_source_dir, tsfile_shared_dir, version +
".dylib")
-elif system == "Linux":
- copy_tsfile_lib(tsfile_shared_source_dir, tsfile_shared_dir, "so." +
version)
+(PKG / "include").mkdir(exist_ok=True)
+if (PKG / "include").exists() and CPP_INC.exists():
+ shutil.rmtree(PKG / "include")
+ shutil.copytree(CPP_INC, PKG / "include")
Review Comment:
+1
--
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]