From 34da30cae178c52ff5a0342b3b6bd75b7f22c35f Mon Sep 17 00:00:00 2001 From: fasiondog Date: Wed, 31 Jan 2024 00:27:50 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E5=A4=B4=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + hikyuu_cpp/hikyuu/xmake.lua | 6 +++ setup.py | 36 ++++++++++++++++- sub_setup.py | 78 ++++++++++++++++++++----------------- 4 files changed, 84 insertions(+), 37 deletions(-) diff --git a/.gitignore b/.gitignore index c9ed64969..2e54310d9 100644 --- a/.gitignore +++ b/.gitignore @@ -76,3 +76,4 @@ hikyuu/cpp/libhku_hdf5_hl.so.200 hikyuu/cpp/libhku_hdf5_hl.so.200.1.0 hikyuu/cpp/libhku_hdf5.so.200 hikyuu/cpp/libhku_hdf5.so.200.2.0 +hikyuu/include diff --git a/hikyuu_cpp/hikyuu/xmake.lua b/hikyuu_cpp/hikyuu/xmake.lua index d741a6aa0..6c8041457 100644 --- a/hikyuu_cpp/hikyuu/xmake.lua +++ b/hikyuu_cpp/hikyuu/xmake.lua @@ -126,4 +126,10 @@ target("hikyuu") end end) + after_install(function(target) + local dst_path = target:installdir() .. "/include/hikyuu/python/" + os.cp("$(projectdir)/hikyuu_pywrap/pybind_utils.h", dst_path) + os.cp("$(projectdir)/hikyuu_pywrap/pickle_support.h", dst_path) + end) + target_end() diff --git a/setup.py b/setup.py index d092a1111..98ea91d26 100644 --- a/setup.py +++ b/setup.py @@ -259,6 +259,34 @@ def uninstall(): print("Uninstall finished!") +def copy_include(install_dir): + src_path = 'hikyuu_cpp/hikyuu' + dst_path = f'{install_dir}/include' + + for root, dirs, files in os.walk(src_path): + for p in dirs: + dst_p = f'{dst_path}/{root[11:]}/{p}' + if not os.path.lexists(dst_p): + os.makedirs(dst_p) + shutil.copy('hikyuu/cpp/__init__.py', dst_p) + + for fname in files: + if len(fname) > 2 and fname[-2:] == ".h": + dst_p = f'{dst_path}/{root[11:]}' + if not os.path.lexists(dst_p): + os.makedirs(dst_p) + shutil.copy(f'{root}/{fname}', dst_p) + + dst_path = f'{install_dir}/include/hikyuu/python' + if not os.path.lexists(dst_path): + os.makedirs(dst_path) + shutil.copy('hikyuu_pywrap/pybind_utils.h', dst_path) + shutil.copy('hikyuu_pywrap/pickle_support.h', dst_path) + shutil.copy('hikyuu/cpp/__init__.py', dst_path) + shutil.copy('hikyuu/cpp/__init__.py', f'{install_dir}/include') + shutil.copy('hikyuu/cpp/__init__.py', f'{install_dir}/include/hikyuu') + + @click.option('-j', '--j', default=2, help="并行编译数量") @click.option('-o', '--o', help="指定的安装目录") @click.command() @@ -281,6 +309,8 @@ def install(j, o): shutil.copytree("./hikyuu", install_dir) + copy_include(install_dir) + @click.command() @click.option('-j', '--j', default=2, help="并行编译数量") @@ -292,11 +322,13 @@ def install(j, o): def wheel(feedback, j): """ 生成 python 的 wheel 安装包 """ # 清理之前遗留的打包产物 - clear_build() + # clear_build() # 尝试编译 start_build(False, 'release', feedback, j) + copy_include('hikyuu') + # 构建打包命令 print("start pacakaging bdist_wheel ...") current_plat = sys.platform @@ -330,6 +362,8 @@ def wheel(feedback, j): print(cmd) os.system(cmd) + shutil.rmtree('hikyuu/include', True) + @click.command() def upload(): diff --git a/sub_setup.py b/sub_setup.py index 314d75eac..60827bb28 100644 --- a/sub_setup.py +++ b/sub_setup.py @@ -2,6 +2,7 @@ # -*- coding:utf-8 -*- import platform +import os try: from setuptools import find_packages, setup except ImportError: @@ -52,41 +53,46 @@ def parse_requirements(filename): hku_data_files = [] -packages = [ - 'hikyuu', - 'hikyuu/admin', - 'hikyuu/admin/language', - 'hikyuu/analysis', - 'hikyuu/config', - 'hikyuu/config/block', - 'hikyuu/cpp', - 'hikyuu/data', - 'hikyuu/data/mysql_upgrade', - 'hikyuu/data/sqlite_upgrade', - 'hikyuu/data/sqlite_mem_sql', - 'hikyuu/data_driver', - 'hikyuu/examples', - 'hikyuu/examples/notebook', - 'hikyuu/examples/notebook/images', - 'hikyuu/examples/notebook/Demo', - 'hikyuu/flat', - 'hikyuu/fetcher', - 'hikyuu/fetcher/proxy', - 'hikyuu/fetcher/stock', - 'hikyuu/gui', - 'hikyuu/gui/data', - 'hikyuu/indicator', - 'hikyuu/draw', - 'hikyuu/draw/drawplot', - 'hikyuu/shell', - 'hikyuu/strategy', - 'hikyuu/strategy/demo', - 'hikyuu/test', - 'hikyuu/tools', - 'hikyuu/trade_manage', - 'hikyuu/trade_sys', - 'hikyuu/util', -] +# packages = [ +# 'hikyuu', +# 'hikyuu/analysis', +# 'hikyuu/config', +# 'hikyuu/config/block', +# 'hikyuu/cpp', +# 'hikyuu/data', +# 'hikyuu/data/mysql_upgrade', +# 'hikyuu/data/sqlite_upgrade', +# 'hikyuu/data/sqlite_mem_sql', +# 'hikyuu/data_driver', +# 'hikyuu/examples', +# 'hikyuu/examples/notebook', +# 'hikyuu/examples/notebook/images', +# 'hikyuu/examples/notebook/Demo', +# 'hikyuu/flat', +# 'hikyuu/fetcher', +# 'hikyuu/fetcher/proxy', +# 'hikyuu/fetcher/stock', +# 'hikyuu/gui', +# 'hikyuu/gui/data', +# 'hikyuu/indicator', +# 'hikyuu/draw', +# 'hikyuu/draw/drawplot', +# 'hikyuu/shell', +# 'hikyuu/strategy', +# 'hikyuu/strategy/demo', +# 'hikyuu/test', +# 'hikyuu/tools', +# 'hikyuu/trade_manage', +# 'hikyuu/trade_sys', +# 'hikyuu/util', +# 'hikyuu/include', +# ] + +packages = ['hikyuu'] +for root, dirs, files in os.walk('hikyuu'): + for p in dirs: + if p.find('__pycache__') < 0 and p.find('ipynb_checkpoints') < 0 and p.find('.virtual_documents') < 0: + packages.append(f'{root}/{p}') setup( name=hku_name, @@ -106,7 +112,7 @@ def parse_requirements(filename): package_data={ '': [ '*.rst', '*.pyd', '*.png', '*.md', '*.ipynb', '*.ini', '*.sql', '*.properties', '*.xml', - 'LICENSE.txt', '*.dll', '*.exe', '*.ico', '*.so', '*.dylib', + 'LICENSE.txt', '*.dll', '*.exe', '*.ico', '*.so', '*.dylib', '*.h', '*.so.*', '*.qm', 'libboost_serialization*', 'libboost_python{}*'.format(py_version) ], From 9d08eae012e9140f80c3a8eeaed3f8a3f71cecf6 Mon Sep 17 00:00:00 2001 From: fasiondog Date: Wed, 31 Jan 2024 01:00:27 +0800 Subject: [PATCH 2/2] update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 98ea91d26..a10763443 100644 --- a/setup.py +++ b/setup.py @@ -322,7 +322,7 @@ def install(j, o): def wheel(feedback, j): """ 生成 python 的 wheel 安装包 """ # 清理之前遗留的打包产物 - # clear_build() + clear_build() # 尝试编译 start_build(False, 'release', feedback, j)