vscode-offline 0.1.6__py3-none-any.whl → 0.1.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,9 @@
1
+ from vscode_offline._version import __commit_id__, __version__, __version_tuple__
1
2
  from vscode_offline.app import main
2
3
 
3
- __all__ = ("main",)
4
+ __all__ = (
5
+ "__commit_id__",
6
+ "__version__",
7
+ "__version_tuple__",
8
+ "main",
9
+ )
@@ -0,0 +1,34 @@
1
+ # file generated by setuptools-scm
2
+ # don't change, don't track in version control
3
+
4
+ __all__ = [
5
+ "__version__",
6
+ "__version_tuple__",
7
+ "version",
8
+ "version_tuple",
9
+ "__commit_id__",
10
+ "commit_id",
11
+ ]
12
+
13
+ TYPE_CHECKING = False
14
+ if TYPE_CHECKING:
15
+ from typing import Tuple
16
+ from typing import Union
17
+
18
+ VERSION_TUPLE = Tuple[Union[int, str], ...]
19
+ COMMIT_ID = Union[str, None]
20
+ else:
21
+ VERSION_TUPLE = object
22
+ COMMIT_ID = object
23
+
24
+ version: str
25
+ __version__: str
26
+ __version_tuple__: VERSION_TUPLE
27
+ version_tuple: VERSION_TUPLE
28
+ commit_id: COMMIT_ID
29
+ __commit_id__: COMMIT_ID
30
+
31
+ __version__ = version = '0.1.7'
32
+ __version_tuple__ = version_tuple = (0, 1, 7)
33
+
34
+ __commit_id__ = commit_id = None
vscode_offline/app.py CHANGED
@@ -4,6 +4,7 @@ import logging
4
4
  from argparse import ArgumentParser, Namespace
5
5
  from pathlib import Path
6
6
 
7
+ from vscode_offline._version import __version__
7
8
  from vscode_offline.download import (
8
9
  download_vscode_client,
9
10
  download_vscode_extensions,
@@ -15,10 +16,14 @@ from vscode_offline.install import (
15
16
  install_vscode_server,
16
17
  )
17
18
  from vscode_offline.utils import (
19
+ get_client_platform,
18
20
  get_default_code_version,
21
+ get_extension_platform,
19
22
  get_host_platform,
23
+ get_server_platform,
20
24
  get_vscode_extensions_config,
21
25
  get_vscode_version_from_server_installer,
26
+ validate_platform,
22
27
  )
23
28
 
24
29
 
@@ -33,12 +38,14 @@ def cmd_download_server(args: Namespace) -> None:
33
38
  download_vscode_server(
34
39
  args.code_version,
35
40
  output=args.installer / f"server-{args.code_version.replace(':', '-')}",
36
- platform=args.platform,
41
+ platform=get_server_platform(args.platform),
37
42
  )
38
43
  extensions_config = Path(args.extensions_config).expanduser()
39
44
  download_vscode_extensions(
40
45
  extensions_config,
41
- target_platforms=[args.platform],
46
+ target_platforms={
47
+ get_extension_platform(args.platform),
48
+ },
42
49
  output=args.installer / "extensions",
43
50
  )
44
51
 
@@ -57,12 +64,12 @@ def cmd_install_server(args: Namespace) -> None:
57
64
 
58
65
  vscode_server_home = install_vscode_server(
59
66
  server_installer=args.installer / f"server-{args.code_version}",
60
- platform=host_platform,
67
+ platform=get_server_platform(host_platform),
61
68
  )
62
69
  install_vscode_extensions(
63
70
  Path(vscode_server_home) / "bin/code-server",
64
71
  vsix_dir=args.installer / "extensions",
65
- platform=host_platform,
72
+ platform=get_extension_platform(host_platform),
66
73
  exclude=SERVER_EXCLUDE_EXTENSIONS,
67
74
  )
68
75
 
@@ -71,7 +78,9 @@ def cmd_download_extensions(args: Namespace) -> None:
71
78
  extensions_config = Path(args.extensions_config).expanduser()
72
79
  download_vscode_extensions(
73
80
  extensions_config,
74
- target_platforms=[args.platform],
81
+ target_platforms={
82
+ get_extension_platform(args.platform),
83
+ },
75
84
  output=args.installer / "extensions",
76
85
  )
77
86
 
@@ -81,7 +90,7 @@ def cmd_install_extensions(args: Namespace) -> None:
81
90
  install_vscode_extensions(
82
91
  args.code,
83
92
  vsix_dir=args.installer / "extensions",
84
- platform=host_platform,
93
+ platform=get_extension_platform(host_platform),
85
94
  )
86
95
 
87
96
 
@@ -96,12 +105,14 @@ def cmd_download_client(args: Namespace) -> None:
96
105
  download_vscode_client(
97
106
  args.code_version,
98
107
  output=args.installer / f"client-{args.code_version.replace(':', '-')}",
99
- platform=args.platform,
108
+ platform=get_client_platform(args.platform),
100
109
  )
101
110
  extensions_config = Path(args.extensions_config).expanduser()
102
111
  download_vscode_extensions(
103
112
  extensions_config,
104
- target_platforms=[args.platform],
113
+ target_platforms={
114
+ get_extension_platform(args.platform),
115
+ },
105
116
  output=args.installer / "extensions",
106
117
  )
107
118
 
@@ -117,21 +128,29 @@ def cmd_download_all(args: Namespace) -> None:
117
128
  download_vscode_server(
118
129
  args.code_version,
119
130
  output=args.installer / f"server-{args.code_version.replace(':', '-')}",
120
- platform=args.server_platform,
131
+ platform=get_server_platform(args.server_platform),
121
132
  )
122
133
  download_vscode_client(
123
134
  args.code_version,
124
135
  output=args.installer / f"client-{args.code_version.replace(':', '-')}",
125
- platform=args.client_platform,
136
+ platform=get_client_platform(args.client_platform),
126
137
  )
127
138
  extensions_config = Path(args.extensions_config).expanduser()
128
139
  download_vscode_extensions(
129
140
  extensions_config,
130
- target_platforms=[args.server_platform, args.client_platform],
141
+ target_platforms={
142
+ get_extension_platform(args.server_platform),
143
+ get_extension_platform(args.client_platform),
144
+ },
131
145
  output=args.installer / "extensions",
132
146
  )
133
147
 
134
148
 
149
+ def cmd_version(args: Namespace) -> None:
150
+ # print version instead of logging
151
+ print(__version__)
152
+
153
+
135
154
  def make_argparser() -> ArgumentParser:
136
155
  parent_parser = ArgumentParser(add_help=False)
137
156
 
@@ -145,6 +164,12 @@ def make_argparser() -> ArgumentParser:
145
164
  parser = ArgumentParser()
146
165
  subparsers = parser.add_subparsers(required=True)
147
166
 
167
+ version_parser = subparsers.add_parser(
168
+ "version",
169
+ help="Show version information",
170
+ )
171
+ version_parser.set_defaults(func=cmd_version)
172
+
148
173
  download_server_parser = subparsers.add_parser(
149
174
  "download-server",
150
175
  help="Download VS Code Server and extensions",
@@ -158,7 +183,7 @@ def make_argparser() -> ArgumentParser:
158
183
  )
159
184
  download_server_parser.add_argument(
160
185
  "--platform",
161
- type=str,
186
+ type=validate_platform,
162
187
  required=True,
163
188
  help="The target platform of the VS Code Server to download.",
164
189
  )
@@ -189,7 +214,7 @@ def make_argparser() -> ArgumentParser:
189
214
  download_extensions_parser.set_defaults(func=cmd_download_extensions)
190
215
  download_extensions_parser.add_argument(
191
216
  "--platform",
192
- type=str,
217
+ type=validate_platform,
193
218
  required=True,
194
219
  help="The target platform of the VS Code extensions to download.",
195
220
  )
@@ -226,7 +251,7 @@ def make_argparser() -> ArgumentParser:
226
251
  )
227
252
  download_client_parser.add_argument(
228
253
  "--platform",
229
- type=str,
254
+ type=validate_platform,
230
255
  required=True,
231
256
  help="The target platform of the VS Code to download.",
232
257
  )
@@ -250,14 +275,14 @@ def make_argparser() -> ArgumentParser:
250
275
  )
251
276
  download_all_parser.add_argument(
252
277
  "--server-platform",
253
- type=str,
254
- default="linux-x64",
278
+ type=validate_platform,
279
+ required=True,
255
280
  help="The target platform of the VS Code Server to download, defaults to linux-x64.",
256
281
  )
257
282
  download_all_parser.add_argument(
258
283
  "--client-platform",
259
- type=str,
260
- default="win32-x64",
284
+ type=validate_platform,
285
+ required=True,
261
286
  help="The target platform of the VS Code to download, defaults to win32-x64.",
262
287
  )
263
288
  download_all_parser.add_argument(
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  import json
4
4
  import os
5
- from collections.abc import Sequence
5
+ from collections.abc import Set as AbstractSet
6
6
  from gzip import GzipFile
7
7
  from io import DEFAULT_BUFFER_SIZE
8
8
  from pathlib import Path
@@ -10,10 +10,10 @@ from urllib.error import HTTPError
10
10
  from urllib.request import urlopen
11
11
 
12
12
  from vscode_offline.loggers import logger
13
- from vscode_offline.utils import get_cli_platform, get_filename_from_headers
13
+ from vscode_offline.utils import extract_filename_from_headers, get_cli_platform
14
14
 
15
15
 
16
- def _download_file(
16
+ def _download_file_once(
17
17
  url: str,
18
18
  directory: str | os.PathLike[str],
19
19
  filename: str | None = None,
@@ -31,12 +31,12 @@ def _download_file(
31
31
  if filename:
32
32
  file_path = Path(directory).joinpath(filename)
33
33
  else:
34
- filename = get_filename_from_headers(resp.headers)
34
+ filename = extract_filename_from_headers(resp.headers)
35
35
  if not filename:
36
36
  raise ValueError(
37
- "Cannot get filename from HTTP headers, please specify argument `filename`."
37
+ "Cannot extract filename from HTTP headers, please specify argument `filename`."
38
38
  )
39
- logger.info(f"Get filename `{filename}` from HTTP headers.")
39
+ logger.info(f"Extracted filename {filename} from HTTP headers.")
40
40
  file_path = Path(directory).joinpath(filename)
41
41
  if file_path.exists():
42
42
  logger.info(f"File {file_path} already exists, skipping download.")
@@ -58,7 +58,7 @@ def _download_file(
58
58
  return file_path
59
59
 
60
60
 
61
- def download_file(
61
+ def _download_file(
62
62
  url: str,
63
63
  directory: str | os.PathLike[str],
64
64
  filename: str | None = None,
@@ -70,35 +70,47 @@ def download_file(
70
70
  return
71
71
 
72
72
  logger.info(f"Downloading {url} ...")
73
- for i in range(3):
73
+ attempt_num = 0
74
+ while True:
74
75
  try:
75
- _download_file(url, directory, filename)
76
+ _download_file_once(url, directory, filename)
76
77
  break
77
78
  except Exception as e:
78
79
  if isinstance(e, HTTPError) and e.code == 404:
79
80
  raise
80
- logger.info(f"Attempt {i + 1} times failed: {e}")
81
+ attempt_num += 1
82
+ if attempt_num >= 3:
83
+ raise
84
+ logger.info(f"Attempt {attempt_num} times failed: {e}")
81
85
 
82
86
 
83
- def download_extension(
87
+ def _download_extension(
84
88
  publisher: str,
85
89
  name: str,
86
90
  version: str,
87
91
  platform: str | None = None,
88
- output: str = ".",
92
+ output: str | os.PathLike[str] = ".",
89
93
  ) -> None:
90
94
  url = f"https://marketplace.visualstudio.com/_apis/public/gallery/publishers/{publisher}/vsextensions/{name}/{version}/vspackage"
91
95
  if platform:
92
96
  url = f"{url}?targetPlatform={platform}"
93
97
  filename = f"{publisher}.{name}-{version}{f'@{platform}' if platform else ''}.vsix"
94
- download_file(url, output, filename)
98
+ _download_file(url, output, filename)
95
99
 
96
100
 
97
101
  def download_vscode_extensions(
98
102
  extensions_config: os.PathLike[str],
99
- target_platforms: Sequence[str],
100
- output: str = ".",
103
+ target_platforms: AbstractSet[str],
104
+ output: str | os.PathLike[str] = ".",
101
105
  ) -> None:
106
+ """Download VS Code extensions listed in the given extensions config file.
107
+
108
+ Args:
109
+ extensions_config: Path to the extensions config file, which is a JSON file
110
+ containing a list of extensions with their publisher, name, and version.
111
+ target_platforms: List of target platforms for which to download the extensions.
112
+ output: Directory to save the downloaded extensions.
113
+ """
102
114
  logger.info(f"Reading extensions config from {extensions_config}")
103
115
  with open(extensions_config) as fp:
104
116
  data = json.loads(fp.read())
@@ -112,7 +124,7 @@ def download_vscode_extensions(
112
124
  requires_fallback_download = False
113
125
  for target_platform in target_platforms:
114
126
  try:
115
- download_extension(
127
+ _download_extension(
116
128
  publisher, name, version, target_platform, output=output
117
129
  )
118
130
  except HTTPError as e:
@@ -121,7 +133,7 @@ def download_vscode_extensions(
121
133
  continue
122
134
  raise
123
135
  if requires_fallback_download:
124
- download_extension(publisher, name, version, output=output)
136
+ _download_extension(publisher, name, version, output=output)
125
137
 
126
138
 
127
139
  def _download_vscode(
@@ -135,7 +147,7 @@ def _download_vscode(
135
147
  # "VS CodeSetup-x64-1.104.3.exe" for windows VS Code,
136
148
  # "vscode-server-linux-x64.tar.gz" for linux VS Code Server,
137
149
  # "vscode_cli_alpine_x64_cli.tar.gz" for linux VS Code CLI.
138
- download_file(
150
+ _download_file(
139
151
  f"https://update.code.visualstudio.com/{version}/{platform}/stable", output
140
152
  )
141
153
 
File without changes
vscode_offline/utils.py CHANGED
@@ -4,9 +4,12 @@ import os
4
4
  import shutil
5
5
  import subprocess
6
6
  import sys
7
+ from argparse import ArgumentTypeError
7
8
  from collections.abc import Mapping
9
+ from collections.abc import Set as AbstractSet
8
10
  from email.parser import HeaderParser
9
11
  from pathlib import Path
12
+ from typing import Final
10
13
 
11
14
  from vscode_offline.loggers import logger
12
15
 
@@ -80,20 +83,151 @@ def get_default_code_version() -> str | None:
80
83
  return version
81
84
 
82
85
 
83
- # Mapping from target platform to CLI OS and architecture used in download URLs
84
- _cli_platform_mapping = {
86
+ # Mapping from other platforms to VS Code client platform used in download URLs
87
+ _client_platform_mapping: Final[Mapping[str, str]] = {
88
+ "linux-x64": "linux-x64",
89
+ "alpine-x64": "linux-x64",
90
+ "linux-deb-x64": "linux-deb-x64",
91
+ "linux-rpm-x64": "linux-rpm-x64",
92
+ "linux-arm64": "linux-arm64",
93
+ "alpine-arm64": "linux-arm64",
94
+ "linux-deb-arm64": "linux-deb-arm64",
95
+ "linux-rpm-arm64": "linux-rpm-arm64",
96
+ "linux-armhf": "linux-armhf",
97
+ "linux-deb-armhf": "linux-deb-armhf",
98
+ "linux-rpm-armhf": "linux-rpm-armhf",
99
+ "win32-x64": "win32-x64",
100
+ "win32-x64-user": "win32-x64-user",
101
+ "win32-x64-archive": "win32-x64-archive",
102
+ "win32-arm64": "win32-arm64",
103
+ "win32-arm64-user": "win32-arm64-user",
104
+ "win32-arm64-archive": "win32-arm64-archive",
105
+ "darwin": "darwin",
106
+ "darwin-x64": "darwin",
107
+ "darwin-arm64": "darwin-arm64",
108
+ }
109
+
110
+ # Mapping from other platforms to VS Code server platform used in download URLs
111
+ _server_platform_mapping: Final[Mapping[str, str]] = {
112
+ "linux-x64": "linux-x64",
113
+ "alpine-x64": "linux-x64",
114
+ "linux-deb-x64": "linux-x64",
115
+ "linux-rpm-x64": "linux-x64",
116
+ "linux-arm64": "linux-arm64",
117
+ "alpine-arm64": "linux-arm64",
118
+ "linux-deb-arm64": "linux-arm64",
119
+ "linux-rpm-arm64": "linux-arm64",
120
+ "linux-armhf": "linux-armhf",
121
+ "linux-deb-armhf": "linux-armhf",
122
+ "linux-rpm-armhf": "linux-armhf",
123
+ "win32-x64": "win32-x64",
124
+ "win32-x64-user": "win32-x64",
125
+ "win32-x64-archive": "win32-x64",
126
+ "win32-arm64": "win32-arm64",
127
+ "win32-arm64-user": "win32-arm64",
128
+ "win32-arm64-archive": "win32-arm64",
129
+ "darwin": "darwin",
130
+ "darwin-x64": "darwin",
131
+ "darwin-arm64": "darwin-arm64",
132
+ }
133
+
134
+
135
+ # Mapping from other platforms to VS Code CLI platform used in download URLs
136
+ _cli_platform_mapping: Final[Mapping[str, str]] = {
85
137
  "linux-x64": "alpine-x64",
138
+ "alpine-x64": "alpine-x64",
139
+ "linux-deb-x64": "alpine-x64",
140
+ "linux-rpm-x64": "alpine-x64",
86
141
  "linux-arm64": "alpine-arm64",
87
- "linux-armhf": "linux-arm64",
142
+ "alpine-arm64": "alpine-arm64",
143
+ "linux-deb-arm64": "alpine-arm64",
144
+ "linux-rpm-arm64": "alpine-arm64",
145
+ "linux-armhf": "linux-armhf",
146
+ "linux-deb-armhf": "linux-armhf",
147
+ "linux-rpm-armhf": "linux-armhf",
148
+ "win32-x64": "win32-x64",
149
+ "win32-x64-user": "win32-x64",
150
+ "win32-x64-archive": "win32-x64",
151
+ "win32-arm64": "win32-arm64",
152
+ "win32-arm64-user": "win32-arm64",
153
+ "win32-arm64-archive": "win32-arm64",
154
+ "darwin": "darwin-x64",
155
+ "darwin-x64": "darwin-x64",
156
+ "darwin-arm64": "darwin-arm64",
157
+ }
158
+
159
+
160
+ # Mapping from other platforms to extension target platform used in download URLs
161
+ _extension_platform_mapping: Final[Mapping[str, str]] = {
162
+ "linux-x64": "linux-x64",
163
+ "alpine-x64": "linux-x64",
164
+ "linux-deb-x64": "linux-x64",
165
+ "linux-rpm-x64": "linux-x64",
166
+ "linux-arm64": "linux-arm64",
167
+ "alpine-arm64": "linux-arm64",
168
+ "linux-deb-arm64": "linux-arm64",
169
+ "linux-rpm-arm64": "linux-arm64",
170
+ "linux-armhf": "linux-armhf",
171
+ "linux-deb-armhf": "linux-armhf",
172
+ "linux-rpm-armhf": "linux-armhf",
88
173
  "win32-x64": "win32-x64",
174
+ "win32-x64-user": "win32-x64",
175
+ "win32-x64-archive": "win32-x64",
176
+ "win32-arm64": "win32-arm64",
177
+ "win32-arm64-user": "win32-arm64",
178
+ "win32-arm64-archive": "win32-arm64",
179
+ "darwin": "darwin-x64",
180
+ "darwin-x64": "darwin-x64",
181
+ "darwin-arm64": "darwin-arm64",
89
182
  }
90
183
 
91
184
 
185
+ def get_client_platform(platform: str) -> str:
186
+ """Get the VS Code platform for the given platform."""
187
+ return _client_platform_mapping.get(platform, platform)
188
+
189
+
190
+ def get_server_platform(platform: str) -> str:
191
+ """Get the VS Code server platform for the given platform."""
192
+ return _server_platform_mapping.get(platform, platform)
193
+
194
+
92
195
  def get_cli_platform(platform: str) -> str:
93
- """Get the CLI OS and architecture for the given target platform."""
94
- if platform not in _cli_platform_mapping:
95
- raise ValueError(f"Unsupported target platform: {platform}")
96
- return _cli_platform_mapping[platform]
196
+ """Get the VS Code CLI platform for the given platform."""
197
+ return _cli_platform_mapping.get(platform, platform)
198
+
199
+
200
+ def get_extension_platform(platform: str) -> str:
201
+ """Get the VS Code extension target platform for the given platform."""
202
+ return _extension_platform_mapping.get(platform, platform)
203
+
204
+
205
+ _all_platforms: Final[AbstractSet[str]] = {
206
+ *_client_platform_mapping.keys(),
207
+ *_client_platform_mapping.values(),
208
+ *_server_platform_mapping.keys(),
209
+ *_server_platform_mapping.values(),
210
+ *_cli_platform_mapping.keys(),
211
+ *_cli_platform_mapping.values(),
212
+ *_extension_platform_mapping.keys(),
213
+ *_extension_platform_mapping.values(),
214
+ }
215
+
216
+
217
+ assert (
218
+ _client_platform_mapping.keys()
219
+ == _server_platform_mapping.keys()
220
+ == _cli_platform_mapping.keys()
221
+ == _extension_platform_mapping.keys()
222
+ == _all_platforms
223
+ )
224
+
225
+
226
+ def validate_platform(platform: str) -> str:
227
+ """Check if the given platform is a valid VS Code platform."""
228
+ if platform in _all_platforms:
229
+ return platform
230
+ raise ArgumentTypeError(f"Unsupported platform: {platform!r}")
97
231
 
98
232
 
99
233
  def get_host_platform() -> str:
@@ -110,10 +244,12 @@ def get_host_platform() -> str:
110
244
  return "linux-x64"
111
245
  elif machine in ("aarch64", "arm64"):
112
246
  return "linux-arm64"
247
+ elif machine in ("armv7l", "armhf"):
248
+ return "linux-armhf"
113
249
  raise ValueError(f"Unsupported host platform: {osname}-{machine}")
114
250
 
115
251
 
116
- def get_filename_from_headers(headers: Mapping[str, str]) -> str | None:
252
+ def extract_filename_from_headers(headers: Mapping[str, str]) -> str | None:
117
253
  """Get the filename from HTTP headers.
118
254
 
119
255
  Args:
@@ -0,0 +1,137 @@
1
+ Metadata-Version: 2.4
2
+ Name: vscode-offline
3
+ Version: 0.1.7
4
+ Summary: Download and install VS Code for offline environments
5
+ Project-URL: Homepage, https://github.com/fanck0605/vscode-offline
6
+ Author-email: Chuck Fan <fanck0605@qq.com>
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: Microsoft :: Windows
13
+ Classifier: Operating System :: POSIX :: Linux
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Utilities
21
+ Requires-Python: >=3.9
22
+ Description-Content-Type: text/markdown
23
+
24
+ # vscode-offline
25
+
26
+ [![Build Status](https://github.com/fanck0605/vscode-offline/workflows/Build/badge.svg)](https://github.com/fanck0605/vscode-offline/actions/workflows/build.yml)
27
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
28
+ [![PyPI Version](https://img.shields.io/pypi/v/vscode-offline)](https://pypi.org/project/vscode-offline/)
29
+ [![License](https://img.shields.io/github/license/fanck0605/vscode-offline)](https://github.com/fanck0605/vscode-offline/blob/master/LICENSE)
30
+
31
+ **vscode-offline** 主要用于在无网环境下安装 VS Code 和 VS Code Server,方便使用 [Remote - SSH](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-ssh) 插件进行远程开发。
32
+
33
+ ## 安装
34
+
35
+ ```shell
36
+ pip install -U vscode-offline
37
+ ```
38
+
39
+ ## 优势
40
+
41
+ 1. 自动识别并下载所有 `.vsix` 文件(包括间接依赖)
42
+ 2. 一键安装 VS Code Server 以及其所有插件
43
+
44
+ ## VS Code 离线安装
45
+
46
+ (1)在联网环境安装好 VS Code 和你需要的插件,如 [Remote - SSH](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-ssh), [Python](https://marketplace.visualstudio.com/items?itemName=ms-python.python) 等。
47
+
48
+ (2)执行如下命令,下载 VS Code 安装包,和目前安装的所有的插件
49
+
50
+ ```shell
51
+ vscode-offline download-all --client-platform win32-x64 --server-platform linux-x64
52
+ ```
53
+
54
+ (3)复制 `./vscode-offline-installer` 到内网 Windows 机器,安装 `client-<version>` 下的 VS Code,然后执行如下命令安装所有插件
55
+
56
+ ```shell
57
+ vscode-offline install-extensions --installer ./vscode-offline-installer
58
+ ```
59
+
60
+ (4)复制 `./vscode-offline-installer` 到内网 Linux 服务器,执行如下命令安装 VS Code Server 和所有插件
61
+
62
+ ```shell
63
+ vscode-offline install-server --installer ./vscode-offline-installer
64
+ ```
65
+
66
+ ## 指定 VS Code 版本号
67
+
68
+ 如果你想下载或安装指定版本的 VS Code,可以先通过 `code --version` 获取当前版本,然后通过 --code-version 参数指定版本号,例如:
69
+
70
+ ```shell
71
+ vscode-offline download-all --code-version 1.104.3
72
+ ```
73
+
74
+ 也支持使用 commit hash 作为版本号,例如:
75
+
76
+ ```shell
77
+ vscode-offline download-all --code-version commit:385651c938df8a906869babee516bffd0ddb9829
78
+ ```
79
+
80
+
81
+ ## 文件下载地址
82
+
83
+ 如果你不想使用 `vscode-offline`,也可以手动下载对应的文件。
84
+
85
+ VS Code / VS Code Server / VS Code CLI 下载地址格式:
86
+
87
+ ```shell
88
+ curl -O https://update.code.visualstudio.com/<version>/<platform>/stable
89
+ curl -O https://update.code.visualstudio.com/commit:<commit>/<platform>/stable
90
+
91
+ # 比如
92
+ curl -O https://update.code.visualstudio.com/1.104.3/cli-alpine-x64/stable
93
+ curl -O https://update.code.visualstudio.com/commit:385651c938df8a906869babee516bffd0ddb9829/win32-x64/stable
94
+ ```
95
+
96
+
97
+ VS Code Extension 下载地址格式:
98
+
99
+ ```shell
100
+ curl -O https://marketplace.visualstudio.com/_apis/public/gallery/publishers/<publisher>/vsextensions/<extension>/<version>/vspackage?targetPlatform=<platform>
101
+
102
+ # 比如
103
+ curl -O https://marketplace.visualstudio.com/_apis/public/gallery/publishers/ms-python/vsextensions/python/2025.14.0/vspackage?targetPlatform=linux-x64
104
+ ```
105
+
106
+ Platform 映射关系:
107
+
108
+ | VS Code | VS Code Server | VS Code CLI | VS Code Extension |
109
+ | ------------------- | ------------------- | ---------------- | ----------------- |
110
+ | win32-x64 | server-win32-x64 | cli-win32-x64 | win32-x64 |
111
+ | win32-x64-user | server-win32-x64 | cli-win32-x64 | win32-x64 |
112
+ | win32-x64-archive | server-win32-x64 | cli-win32-x64 | win32-x64 |
113
+ | win32-arm64 | server-win32-arm64 | cli-win32-arm64 | win32-arm64 |
114
+ | win32-arm64-user | server-win32-arm64 | cli-win32-arm64 | win32-arm64 |
115
+ | win32-arm64-archive | server-win32-arm64 | cli-win32-arm64 | win32-arm64 |
116
+ | linux-x64 | server-linux-x64 | cli-alpine-x64 | linux-x64 |
117
+ | linux-deb-x64 | server-linux-x64 | cli-alpine-x64 | linux-x64 |
118
+ | linux-rpm-x64 | server-linux-x64 | cli-alpine-x64 | linux-x64 |
119
+ | linux-arm64 | server-linux-arm64 | cli-alpine-arm64 | linux-arm64 |
120
+ | linux-deb-arm64 | server-linux-arm64 | cli-alpine-arm64 | linux-arm64 |
121
+ | linux-rpm-arm64 | server-linux-arm64 | cli-alpine-arm64 | linux-arm64 |
122
+ | linux-armhf | server-linux-armhf | cli-linux-armhf | linux-armhf |
123
+ | linux-deb-armhf | server-linux-armhf | cli-linux-armhf | linux-armhf |
124
+ | linux-rpm-armhf | server-linux-armhf | cli-linux-armhf | linux-armhf |
125
+ | darwin | server-darwin | cli-darwin-x64 | darwin-x64 |
126
+ | darwin-arm64 | server-darwin-arm64 | cli-darwin-arm64 | darwin-arm64 |
127
+
128
+
129
+ ## 贡献
130
+
131
+ 欢迎提交 Issue 和 PR 改进本项目。
132
+
133
+ ## License
134
+
135
+ Copyright (c) 2025 Chuck Fan.
136
+
137
+ Distributed under the terms of the [MIT License](https://github.com/fanck0605/vscode-offline/blob/master/LICENSE).
@@ -0,0 +1,13 @@
1
+ vscode_offline/__init__.py,sha256=-TweZdViMkxGYKEAvUN-6g0oUKnKapeC8ytTsWgxjRk,210
2
+ vscode_offline/_version.py,sha256=szvPIs2C82UunpzuvVg3MbF4QhzbBYTsVJ8DmPfq6_E,704
3
+ vscode_offline/app.py,sha256=yI8yXURX99etpXTvvMvTElIq60VDoZPfqKd99UMEpJ8,9993
4
+ vscode_offline/download.py,sha256=CSFeNP8Ql7bdDqJ4neXvuzq3719UmxipLB9DJUIaz30,6045
5
+ vscode_offline/install.py,sha256=plZxKrlwy5FgyEAtDWRt0ZfvPWTB2tMRf54_kzVK5h0,4320
6
+ vscode_offline/loggers.py,sha256=vX91NMtNo1xfxq5y4BCtm_uhCTKtCODqBJHNvcT7JdQ,104
7
+ vscode_offline/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ vscode_offline/utils.py,sha256=YxOy5y_HqFkTI6IRe2kPrIOLh9Dg2G0SV3XalbkK83Y,8590
9
+ vscode_offline-0.1.7.dist-info/METADATA,sha256=F9rqNxLwq3CQ4w33Qtp42Jg9WHqRRt6gHyW_N78l4dw,6030
10
+ vscode_offline-0.1.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
11
+ vscode_offline-0.1.7.dist-info/entry_points.txt,sha256=XyuZLe7bgm2RmZp9oh9qCxcrAwHypD8XrTnm4G0_CzM,55
12
+ vscode_offline-0.1.7.dist-info/licenses/LICENSE,sha256=pUIXFkLeTS986b7dopOVLyuw72fJsUxhl8H3rEMIycA,1053
13
+ vscode_offline-0.1.7.dist-info/RECORD,,
@@ -1,83 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: vscode-offline
3
- Version: 0.1.6
4
- Summary: Download and install VS Code Server for offline environments
5
- Project-URL: Homepage, https://github.com/fanck0605/vscode-offline
6
- Author-email: Chuck Fan <fanck0605@qq.com>
7
- License-Expression: MIT
8
- License-File: LICENSE
9
- Classifier: Development Status :: 4 - Beta
10
- Classifier: Intended Audience :: Developers
11
- Classifier: License :: OSI Approved :: MIT License
12
- Classifier: Operating System :: Microsoft :: Windows
13
- Classifier: Operating System :: POSIX :: Linux
14
- Classifier: Programming Language :: Python :: 3 :: Only
15
- Classifier: Programming Language :: Python :: 3.9
16
- Classifier: Programming Language :: Python :: 3.10
17
- Classifier: Programming Language :: Python :: 3.11
18
- Classifier: Programming Language :: Python :: 3.12
19
- Classifier: Programming Language :: Python :: 3.13
20
- Classifier: Topic :: Utilities
21
- Requires-Python: >=3.9
22
- Description-Content-Type: text/markdown
23
-
24
- # vscode-offline
25
-
26
- vscode-offline 主要用于在无网环境下安装 VS Code Server,方便使用 *Remote - SSH* 插件进行远程开发。
27
-
28
- ## 安装
29
-
30
- ```shell
31
- pip install -U vscode-offline
32
- ```
33
-
34
- ## 优势
35
-
36
- 1. 自动识别并下载所有 `.vsix` 文件(包括间接依赖)
37
- 2. 一键安装 VS Code Server 以及所有插件
38
-
39
- ## VS Code 离线安装
40
-
41
- (1)在联网环境安装好 VS Code 和你需要的插件,如 [Remote - SSH](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-ssh), [Python](https://marketplace.visualstudio.com/items?itemName=ms-python.python) 等。
42
-
43
- (2)执行如下命令,下载 VS Code 安装包,和目前安装的所有的插件
44
-
45
- ```shell
46
- vscode-offline download-all --installer ./vscode-offline-installer
47
- ```
48
-
49
- (3)复制 `./vscode-offline-installer` 到内网 Windows 机器,安装 `client-<version>` 下的 VS Code,然后执行如下命令安装所有插件
50
-
51
- ```shell
52
- vscode-offline install-extensions --installer ./vscode-offline-installer
53
- ```
54
-
55
- (4)复制 `./vscode-offline-installer` 到内网 Linux 服务器,执行如下命令安装 VS Code Server 和所有插件
56
-
57
- ```shell
58
- vscode-offline install-server --installer ./vscode-offline-installer
59
- ```
60
-
61
- ## 指定 VS Code 版本号
62
-
63
- 如果你想下载或安装指定版本的 VS Code,可以先通过 `code --version` 获取当前版本,然后通过 --code-version 参数指定版本号,例如:
64
-
65
- ```shell
66
- vscode-offline download-all --code-version 1.104.3
67
- ```
68
-
69
- 也支持使用 commit hash 作为版本号,例如:
70
-
71
- ```shell
72
- vscode-offline download-all --code-version commit:385651c938df8a906869babee516bffd0ddb9829
73
- ```
74
-
75
- ## 贡献
76
-
77
- 欢迎提交 Issue 和 PR 改进本项目。
78
-
79
- ## License
80
-
81
- Copyright (c) 2025 Chuck Fan.
82
-
83
- Distributed under the terms of the [MIT License](https://github.com/fanck0605/vscode-offline/blob/master/LICENSE).
@@ -1,11 +0,0 @@
1
- vscode_offline/__init__.py,sha256=dr6Jtj0XT9eQEC4fzNigEYsAIEfCsaom3HDbUsS-2O4,57
2
- vscode_offline/app.py,sha256=Rm-uSkJrRmJVmyjiubPpRQTofttQdTADsGyEeZDSeY0,9142
3
- vscode_offline/download.py,sha256=blu2WjG8zhuBrHrrV-v-FUf2fXbIt7fVSX8DoUX_Ikk,5442
4
- vscode_offline/install.py,sha256=plZxKrlwy5FgyEAtDWRt0ZfvPWTB2tMRf54_kzVK5h0,4320
5
- vscode_offline/loggers.py,sha256=vX91NMtNo1xfxq5y4BCtm_uhCTKtCODqBJHNvcT7JdQ,104
6
- vscode_offline/utils.py,sha256=vpVSmE4JN0O-ezpzNJo9R9Y3YjzmzslhRVTG5H_-We0,4038
7
- vscode_offline-0.1.6.dist-info/METADATA,sha256=UPt5DA0VlejIxNXCWUCztcKc36pacYF6I_mN6SnW98s,2803
8
- vscode_offline-0.1.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
- vscode_offline-0.1.6.dist-info/entry_points.txt,sha256=XyuZLe7bgm2RmZp9oh9qCxcrAwHypD8XrTnm4G0_CzM,55
10
- vscode_offline-0.1.6.dist-info/licenses/LICENSE,sha256=pUIXFkLeTS986b7dopOVLyuw72fJsUxhl8H3rEMIycA,1053
11
- vscode_offline-0.1.6.dist-info/RECORD,,