File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change 1+ PROJECT_NAME = "OctoBot-Pro"
2+ AUTHOR = "Drakkar-Software"
3+ VERSION = "0.0.1" # major.minor.revision
4+
5+
16def _use_module_local_tentacles ():
27 import sys
38 import os
9+ import appdirs
410 if os .getenv ("USE_CUSTOM_TENTACLES" , "" ).lower () == "true" :
511 # do not use octobot_pro/imports tentacles
612 # WARNING: in this case, all the required tentacles imports still have to work
713 # and therefore be bound to another tentacles folder
814 return
9- # import tentacles from octobot_pro/imports directory
10- internal_import_path = os .path .join (os .path .dirname (os .path .abspath (__file__ )), "imports" )
15+ # import tentacles from user-appdirs/imports directory
16+ dirs = appdirs .AppDirs (PROJECT_NAME , AUTHOR , VERSION )
17+ internal_import_path = os .path .join (dirs .user_data_dir , "imports" )
1118 sys .path .insert (0 , internal_import_path )
1219
1320
@@ -33,6 +40,3 @@ def _use_module_local_tentacles():
3340from octobot_pro .constants import *
3441from octobot_pro .api import *
3542from octobot_pro .model import *
36-
37- PROJECT_NAME = "OctoBot-Pro"
38- VERSION = "0.0.1" # major.minor.revision
Original file line number Diff line number Diff line change 2525import octobot_tentacles_manager .api as api
2626
2727
28- async def _install_all_tentacles (quite_mode ) -> int :
28+ async def install_all_tentacles (quite_mode ) -> int :
2929 octobot_pro_logging .enable_base_logger ()
3030 error_count = 0
3131 logger = commons_logging .get_logger (f"{ op .PROJECT_NAME } -CLI" )
32- install_path = octobot_mocks .get_module_install_path ()
32+ install_path = octobot_mocks .get_module_appdir_path ()
3333 tentacles_path = octobot_mocks .get_tentacles_path ()
3434 tentacles_urls = octobot_mocks .get_public_tentacles_urls ()
3535 async with aiohttp .ClientSession () as aiohttp_session :
@@ -52,7 +52,7 @@ def handle_octobot_pro_command(starting_args) -> int:
5252 print (f"{ op .PROJECT_NAME } version { op .VERSION } " )
5353 return 0
5454 if starting_args .install_tentacles :
55- return asyncio .run (_install_all_tentacles (starting_args .quite ))
55+ return asyncio .run (install_all_tentacles (starting_args .quite ))
5656 print (f"No provided command. See --help to get more details on how to use { op .PROJECT_NAME } -CLI" , file = sys .stderr )
5757 return - 1
5858
Original file line number Diff line number Diff line change 11import os
22import json
3+ import appdirs
34
5+ import octobot_pro
46import octobot_pro .constants as constants
57import octobot_tentacles_manager .api as octobot_tentacles_manager_api
68import octobot_tentacles_manager .constants as octobot_tentacles_manager_constants
@@ -26,19 +28,24 @@ def get_module_config_path(file_name):
2628 return os .path .join (get_module_install_path (), constants .CONFIG_PATH , file_name )
2729
2830
29- def get_internal_import_path ():
30- return os .path .join (get_module_install_path (), constants .ADDITIONAL_IMPORT_PATH )
31+ def get_module_appdir_path ():
32+ dirs = appdirs .AppDirs (octobot_pro .PROJECT_NAME , octobot_pro .AUTHOR , octobot_pro .VERSION )
33+ return dirs .user_data_dir
3134
3235
33- def get_imported_tentacles_path ():
34- import tentacles
35- return os .path .dirname (os .path .abspath (tentacles .__file__ ))
36+ def get_internal_import_path ():
37+ return os .path .join (get_module_appdir_path (), constants .ADDITIONAL_IMPORT_PATH )
3638
3739
3840def get_tentacles_path ():
3941 return os .path .join (get_internal_import_path (), octobot_tentacles_manager_constants .TENTACLES_PATH )
4042
4143
44+ def get_imported_tentacles_path ():
45+ import tentacles
46+ return os .path .dirname (os .path .abspath (tentacles .__file__ ))
47+
48+
4249def get_public_tentacles_urls ():
4350 return [
4451 octobot_configuration_manager .get_default_tentacles_url ()
Original file line number Diff line number Diff line change 11# Drakkar-Software requirements
22OctoBot == 0.4.27
3+
4+ # manage tentacles install path
5+ appdirs == 1.4.4
Original file line number Diff line number Diff line change 1+ import asyncio
2+
13from setuptools import find_packages
24from setuptools import setup
5+ from distutils .command .install import install
6+
37
48# from octobot_pro import PROJECT_NAME, VERSION
59# todo figure out how not to import octobot_pro.__init__.py here
610PROJECT_NAME = "OctoBot-Pro"
711VERSION = "0.0.1" # major.minor.revision
812
913
14+ def _post_install ():
15+ import octobot_pro .cli
16+ asyncio .run (octobot_pro .cli .install_all_tentacles (True ))
17+
18+
19+ class InstallWithPostInstallAction (install ):
20+ def run (self ):
21+ install .run (self )
22+ self .execute (_post_install , (), msg = "Installing OctoBot-Pro tentacles" )
23+
24+
1025PACKAGES = find_packages (
1126 exclude = [
1227 "tests" ,
3146 author_email = 'drakkar-software@protonmail.com' ,
3247 description = 'Backtesting framework of the OctoBot Ecosystem' ,
3348 packages = PACKAGES ,
34- include_package_data = True ,
49+ cmdclass = { 'install' : InstallWithPostInstallAction } ,
3550 long_description = DESCRIPTION ,
3651 long_description_content_type = 'text/markdown' ,
3752 tests_require = ["pytest" ],
You can’t perform that action at this time.
0 commit comments