Skip to content

Commit

Permalink
Merge pull request #156 from fasiondog/feature/hub
Browse files Browse the repository at this point in the history
Feature/hub 优化安装setup.py拷贝cpp头文件
  • Loading branch information
fasiondog authored Jan 30, 2024
2 parents 8aafe89 + 9d08eae commit d20aa62
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 36 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions hikyuu_cpp/hikyuu/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
34 changes: 34 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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="并行编译数量")
Expand All @@ -297,6 +327,8 @@ def wheel(feedback, j):
# 尝试编译
start_build(False, 'release', feedback, j)
copy_include('hikyuu')
# 构建打包命令
print("start pacakaging bdist_wheel ...")
current_plat = sys.platform
Expand Down Expand Up @@ -330,6 +362,8 @@ def wheel(feedback, j):
print(cmd)
os.system(cmd)
shutil.rmtree('hikyuu/include', True)
@click.command()
def upload():
Expand Down
78 changes: 42 additions & 36 deletions sub_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# -*- coding:utf-8 -*-

import platform
import os
try:
from setuptools import find_packages, setup
except ImportError:
Expand Down Expand Up @@ -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,
Expand All @@ -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)
],
Expand Down

0 comments on commit d20aa62

Please sign in to comment.