From 7b7eacd70067de8d1d5662fb4a77b36e506edc07 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Sun, 22 Oct 2023 12:20:16 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20parameterize=20.spec=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.sh | 13 +++--- continue_server.m1.spec | 85 ---------------------------------- continue_server.spec | 83 ++++++++++++++++++++++++--------- extensions/vscode/.gitignore | 3 +- extensions/vscode/package.json | 5 ++ 5 files changed, 74 insertions(+), 115 deletions(-) delete mode 100644 continue_server.m1.spec diff --git a/build.sh b/build.sh index 927d22d80..98c5131c0 100755 --- a/build.sh +++ b/build.sh @@ -15,27 +15,26 @@ pip install -r server/requirements.txt pip install pyinstaller # 4. Detect M1 architecture or allow manual override +USE_ARCH="intel" if [ "$1" = "m1" ]; then echo "Building for M1 architecture" - SPEC_FILE="continue_server.m1.spec" + USE_ARCH="m1" elif [ "$1" = "regular" ]; then echo "Building for regular architecture" - SPEC_FILE="continue_server.spec" + USE_ARCH="intel" else ARCH=$(uname -m) if [ "$ARCH" = "arm64" ]; then echo "$ARCH architecture detected, using M1 spec file" - SPEC_FILE="continue_server.m1.spec" + USE_ARCH="m1" else echo "$ARCH architecture detected, using regular spec file" - SPEC_FILE="continue_server.spec" + USE_ARCH="intel" fi fi -echo "Using $SPEC_FILE" - # 5. Call PyInstaller from within the virtual environment -env/bin/pyinstaller $SPEC_FILE +env/bin/pyinstaller continue_server.spec -- --arch $USE_ARCH # 6. Deactivate the virtual environment deactivate diff --git a/continue_server.m1.spec b/continue_server.m1.spec deleted file mode 100644 index 643d3adf0..000000000 --- a/continue_server.m1.spec +++ /dev/null @@ -1,85 +0,0 @@ -# -*- mode: python ; coding: utf-8 -*- -import certifi -import os -import sys -from PyInstaller.utils.hooks import copy_metadata - -block_cipher = None - -import subprocess -def find_package_location(package_name): - try: - # Run the 'pip show' command and capture its output - result = subprocess.run(['pip', 'show', package_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, check=True) - output = result.stdout - - # Split the output into lines and find the 'Location' field - for line in output.splitlines(): - if line.startswith('Location:'): - # Extract the path after the 'Location:' prefix - location = line.split(':', 1)[1].strip() - return location - - except subprocess.CalledProcessError as e: - print(f"Error: {e.stderr}") - - return None - -chroma_path = find_package_location('chromadb') -chroma_toc = list(map(lambda x: (x[1], os.path.dirname(x[0])), Tree(f'{chroma_path}/chromadb/migrations', prefix="chromadb/migrations"))) - -tsl_path = find_package_location('tree_sitter_languages') -tsl_filename = "languages.dll" if sys.platform == "win32" else "languages.so" - -a = Analysis( - ['continue_server.py'], - pathex=[], - binaries=[(os.path.join(tsl_path, 'tree_sitter_languages', tsl_filename), "tree_sitter_languages")], - datas=[ - ('server/continuedev', 'continuedev'), - (certifi.where(), 'ca_bundle'), - ('.tiktoken_cache', 'tiktoken_cache'), - ] + copy_metadata('replicate') + chroma_toc, - hiddenimports=[ - 'anthropic', 'github', 'ripgrepy', 'bs4', 'redbaron', 'tree_sitter', 'tree_sitter_languages', - 'chromadb', 'onnxruntime', - 'chromadb.telemetry.posthog', - 'chromadb.api.segment', 'chromadb.db.impl', - 'chromadb.db.impl.sqlite', 'chromadb.migrations', - 'chromadb.migrations.embeddings_queue', 'chromadb.migrations.sysdb', - 'chromadb.migrations.metadb', 'chromadb.segment.impl', - 'chromadb.segment.impl.manager', 'chromadb.segment.impl.manager.local', - 'chromadb.segment.impl.metadata', 'chromadb.segment.impl.metadata.sqlite' - ], - hookspath=[], - hooksconfig={}, - runtime_hooks=[], - excludes=[], - win_no_prefer_redirects=False, - win_private_assemblies=False, - cipher=block_cipher, - noarchive=False, -) -pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) - -exe = EXE( - pyz, - a.scripts, - a.binaries, - a.zipfiles, - a.datas, - [], - name='continue_server', - debug=False, - bootloader_ignore_signals=False, - strip=False, - upx=True, - upx_exclude=[], - runtime_tmpdir=None, - console=True, - disable_windowed_traceback=False, - argv_emulation=False, - target_arch="arm64", - codesign_identity=None, - entitlements_file=None, -) diff --git a/continue_server.spec b/continue_server.spec index 1e1359e9d..f160f131e 100644 --- a/continue_server.spec +++ b/continue_server.spec @@ -3,10 +3,15 @@ import certifi import os import sys from PyInstaller.utils.hooks import copy_metadata +import argparse + +parser = argparse.ArgumentParser() +parser.add_argument("--arch", type=str) +parser.add_argument("--dir", type=bool, default=False) +options = parser.parse_args() block_cipher = None - import subprocess def find_package_location(package_name): try: @@ -63,24 +68,58 @@ a = Analysis( ) pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) -exe = EXE( - pyz, - a.scripts, - a.binaries, - a.zipfiles, - a.datas, - [], - name='continue_server', - debug=False, - bootloader_ignore_signals=False, - strip=False, - upx=True, - upx_exclude=[], - runtime_tmpdir=None, - console=True, - disable_windowed_traceback=False, - argv_emulation=False, - target_arch=None, - codesign_identity=None, - entitlements_file=None, -) + +target_arch = "arm64" if options.arch == "m1" else None +print("Using target arch", target_arch) + +if options.dir: + print("Using directory") + exe = EXE( + pyz, + a.scripts, + exclude_binaries=True, + name='continue_server', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=True, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch=target_arch, + codesign_identity=None, + entitlements_file=None, + ) + + coll = COLLECT( + exe, + a.binaries, + a.datas, + name='continue_server', + ) + +else: + print("Using one file") + exe = EXE( + pyz, + a.scripts, + a.binaries, + a.zipfiles, + a.datas, + [], + name='continue_server', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=True, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None, + ) \ No newline at end of file diff --git a/extensions/vscode/.gitignore b/extensions/vscode/.gitignore index 9ab2f4956..45d3b3d67 100644 --- a/extensions/vscode/.gitignore +++ b/extensions/vscode/.gitignore @@ -6,4 +6,5 @@ data/ src/client .continue -gui \ No newline at end of file +gui +exe \ No newline at end of file diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 157499ed2..04714e594 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -66,6 +66,11 @@ "type": "boolean", "default": true, "description": "Continue collects anonymous usage data, cleaned of PII, to help us improve the product for our users. Read more at https://continue.dev/docs/telemetry." + }, + "continue.showInlineTip": { + "type": "boolean", + "default": true, + "description": "Show inline suggestion to use the Continue keyboard shortcuts." } } },