Skip to content

Commit 5f86685

Browse files
author
deathaxe
authored
Install Package Control 4.0 from github (#225)
* Install Package Control 4.0 from github * Update Package Control Install Helper * CI: Disable coverage Coverage 7.x has changed data formats and thus needs separate fixing beyond this PR.
1 parent 5924ce1 commit 5f86685

9 files changed

+98
-124
lines changed

.github/workflows/test.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ jobs:
3434
install-unittesting: false
3535
- uses: "./actions/run-tests"
3636
with:
37-
coverage: true
38-
- uses: codecov/codecov-action@v4
39-
with:
40-
token: ${{secrets.CODECOV_TOKEN}}
37+
coverage: false
38+
# - uses: codecov/codecov-action@v4
39+
# with:
40+
# token: ${{secrets.CODECOV_TOKEN}}
4141

4242
test-actions: # with latest released unittesting
4343
strategy:

actions/setup/action.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,6 @@ runs:
189189
if [ "${{ inputs.install-unittesting }}" = "true" ]; then
190190
InstallPackage "UnitTesting" "https://github.com/SublimeText/UnitTesting" "${{ inputs.unittesting-version }}"
191191
fi
192-
if [ "${{ inputs.install-coverage }}" = "true" ]; then
193-
InstallPackage "coverage" "https://github.com/codexns/sublime-coverage" "${{ inputs.coverage-version }}"
194-
fi
195192
196193
while read -r x; do
197194
if [[ "$x" =~ ^(.*):(.*)/([^@]*)@?(.*)$ ]]; then

sbin/install_package_control.ps1

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ try{
99
New-Item -itemtype directory $STIP -force >$null
1010

1111
$PC_PATH = "$STIP\Package Control.sublime-package"
12-
$PC_URL = "https://packagecontrol.io/Package Control.sublime-package"
12+
$PC_URL = "https://github.com/wbond/package_control/releases/latest/download/Package.Control.sublime-package"
1313
(New-Object System.Net.WebClient).DownloadFile($PC_URL, $PC_PATH)
1414

1515
$PC_SETTINGS = "C:\st\Data\Packages\User\Package Control.sublime-settings"
@@ -24,6 +24,7 @@ try{
2424

2525
$BASE = Split-Path -parent $PSCommandPath
2626
Copy-Item "$BASE\pc_helper.py" "$PCH_PATH\pc_helper.py"
27+
Copy-Item "$BASE\.python-version" "$PCH_PATH\.python-version"
2728

2829
for ($i=1; $i -le 3; $i++) {
2930

sbin/install_package_control.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fi
4343

4444
PC_PATH="$STIP/Package Control.sublime-package"
4545
if [ ! -f "$PC_PATH" ]; then
46-
PC_URL="https://packagecontrol.io/Package%20Control.sublime-package"
46+
PC_URL="https://github.com/wbond/package_control/releases/latest/download/Package.Control.sublime-package"
4747
curl -s -L "$PC_URL" -o "$PC_PATH"
4848
fi
4949

@@ -58,11 +58,13 @@ PCH_PATH="$STP/0_install_package_control_helper"
5858
if [ ! -d "$PCH_PATH" ]; then
5959
mkdir -p "$PCH_PATH"
6060
BASE=`dirname "$0"`
61-
cp "$BASE"/pc_helper.py "$PCH_PATH"/pc_helper.py
61+
cp "$BASE/pc_helper.py" "$PCH_PATH/pc_helper.py"
62+
cp "$BASE/.python-version" "$PCH_PATH/.python-version"
6263
fi
6364

6465

6566
# launch sublime text in background
67+
echo Starting Sublime Text
6668
for i in {1..3}; do
6769
subl &
6870

sbin/pc_helper.py

+39-55
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,73 @@
1+
import os
12
import sublime
2-
import sys
33
import subprocess
4-
import os
4+
import sys
55

66

77
def plugin_loaded():
8-
9-
pc_settings = sublime.load_settings("Package Control.sublime-settings")
10-
118
logfile = os.path.join(
12-
sublime.packages_path(),
13-
"0_install_package_control_helper",
14-
"log")
9+
sublime.packages_path(), "0_install_package_control_helper", "log"
10+
)
1511

1612
def kill_subl(restart=False):
1713
if sublime.platform() == "osx":
1814
cmd = "sleep 1; pkill [Ss]ubl; pkill plugin_host; sleep 1; "
1915
if restart:
20-
cmd = cmd + "osascript -e 'tell application \"Sublime Text\" to activate'"
16+
cmd = (
17+
cmd + "osascript -e 'tell application \"Sublime Text\" to activate'"
18+
)
2119
elif sublime.platform() == "linux":
2220
cmd = "sleep 1; pkill [Ss]ubl; pkill plugin_host; sleep 1; "
2321
if restart:
2422
cmd = cmd + "subl"
2523
elif sublime.platform() == "windows":
2624
cmd = "sleep 1 & taskkill /F /im sublime_text.exe & sleep 1 "
2725
if restart:
28-
cmd = cmd + "& \"{}\"".format(sublime.executable_path())
26+
cmd = cmd + '& "{}"'.format(sublime.executable_path())
27+
else:
28+
return
2929

3030
subprocess.Popen(cmd, shell=True)
3131

3232
def touch(file_name):
3333
f = os.path.join(
34-
sublime.packages_path(),
35-
"0_install_package_control_helper",
36-
file_name)
37-
open(f, 'a').close()
34+
sublime.packages_path(), "0_install_package_control_helper", file_name
35+
)
36+
open(f, "a").close()
3837

39-
def check_bootstrap():
40-
if pc_settings.get("bootstrapped", False):
41-
touch("bootstrapped")
42-
kill_subl(True)
38+
def satisfy_libraries():
39+
if "Package Control" in sys.modules:
40+
package_control = sys.modules["Package Control"].package_control
4341
else:
44-
sublime.set_timeout(check_bootstrap, 5000)
45-
46-
def check_dependencies():
47-
if 'Package Control' in sys.modules:
48-
package_control = sys.modules['Package Control'].package_control
49-
else:
50-
sublime.set_timeout(check_dependencies, 5000)
42+
sublime.set_timeout(satisfy_libraries, 5000)
5143
return
5244

5345
manager = package_control.package_manager.PackageManager()
54-
required_dependencies = set(manager.find_required_dependencies())
55-
56-
class myPackageCleanup(package_control.package_cleanup.PackageCleanup):
57-
58-
def finish(self, installed_packages, found_packages, found_dependencies):
59-
missing_dependencies = required_dependencies - set(found_dependencies)
6046

61-
if len(missing_dependencies) == 0:
62-
touch("success")
63-
kill_subl()
64-
else:
65-
with open(logfile, "a") as f:
66-
f.write("missing dependencies:" + "\n")
67-
f.write(" ".join(missing_dependencies) + "\n")
68-
sublime.set_timeout(_check_dependencies, 5000)
47+
# query and install missing libraries
48+
required_libraries = manager.find_required_libraries()
49+
if required_libraries:
50+
manager.install_libraries(required_libraries, fail_early=False)
6951

70-
def _check_dependencies():
71-
myPackageCleanup().run()
52+
# re-query missing libraries
53+
missing_libraries = manager.find_missing_libraries(
54+
required_libraries=required_libraries
55+
)
56+
if missing_libraries:
57+
with open(logfile, "a") as f:
58+
f.write("missing dependencies:" + "\n")
59+
f.write(" ".join(sorted(missing_libraries)) + "\n")
60+
else:
61+
touch("success")
7262

73-
_check_dependencies()
63+
kill_subl()
7464

75-
if not os.path.exists(os.path.join(
76-
sublime.packages_path(),
77-
"0_install_package_control_helper",
78-
"bootstrapped")):
79-
check_bootstrap()
80-
else:
81-
# restart sublime when `sublime.error_message` is run
82-
def error_message(message):
83-
with open(logfile, "a") as f:
84-
f.write(message + "\n")
65+
# restart sublime when `sublime.error_message` is run
66+
def error_message(message):
67+
with open(logfile, "a") as f:
68+
f.write(message + "\n")
8569

86-
kill_subl(True)
70+
kill_subl(True)
8771

88-
sublime.error_message = error_message
89-
check_dependencies()
72+
sublime.error_message = error_message
73+
sublime.set_timeout(satisfy_libraries, 10000)

scripts/.python-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.8

scripts/install_package_control.ps1

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ New-Item -itemtype directory $STPU -force >$null
1414

1515
$PC_PATH = "$STIP\Package Control.sublime-package"
1616
if (-not (test-path $PC_PATH)) {
17-
$PC_URL = "https://packagecontrol.io/Package Control.sublime-package"
17+
$PC_URL = "https://github.com/wbond/package_control/releases/latest/download/Package.Control.sublime-package"
1818
(New-Object System.Net.WebClient).DownloadFile($PC_URL, $PC_PATH)
1919
}
2020

@@ -30,6 +30,7 @@ New-Item -itemtype directory $PCH_PATH -force >$null
3030

3131
$BASE = Split-Path -parent $PSCommandPath
3232
Copy-Item "$BASE\install_package_control_helper.py" "$PCH_PATH\install_package_control_helper.py"
33+
Copy-Item "$BASE\.python-version" "$PCH_PATH\.python-version"
3334

3435
for ($i=1; $i -le 3; $i++) {
3536

scripts/install_package_control.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fi
4343

4444
PC_PATH="$STIP/Package Control.sublime-package"
4545
if [ ! -f "$PC_PATH" ]; then
46-
PC_URL="https://packagecontrol.io/Package%20Control.sublime-package"
46+
PC_URL="https://github.com/wbond/package_control/releases/latest/download/Package.Control.sublime-package"
4747
curl -s -L "$PC_URL" -o "$PC_PATH"
4848
fi
4949

@@ -59,11 +59,13 @@ PCH_PATH="$STP/0_install_package_control_helper"
5959
if [ ! -d "$PCH_PATH" ]; then
6060
mkdir -p "$PCH_PATH"
6161
BASE=`dirname "$0"`
62-
cp "$BASE"/install_package_control_helper.py "$PCH_PATH"/install_package_control_helper.py
62+
cp "$BASE/install_package_control_helper.py" "$PCH_PATH/install_package_control_helper.py"
63+
cp "$BASE/.python-version" "$PCH_PATH/.python-version"
6364
fi
6465

6566

6667
# launch sublime text in background
68+
echo Starting Sublime Text
6769
for i in {1..3}; do
6870
subl &
6971

+42-56
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,75 @@
1+
import os
12
import sublime
2-
import sys
33
import subprocess
4-
import os
4+
import sys
55

66

77
def plugin_loaded():
8+
logfile = os.path.join(
9+
sublime.packages_path(), "0_install_package_control_helper", "log"
10+
)
811

9-
pc_settings = sublime.load_settings("Package Control.sublime-settings")
12+
log = open(logfile, "a", encoding="utf-8")
1013

11-
logfile = os.path.join(
12-
sublime.packages_path(),
13-
"0_install_package_control_helper",
14-
"log")
14+
sys.stdout = log
15+
sys.stderr = log
1516

1617
def kill_subl(restart=False):
1718
if sublime.platform() == "osx":
1819
cmd = "sleep 1; pkill [Ss]ubl; pkill plugin_host; sleep 1; "
1920
if restart:
20-
cmd = cmd + "osascript -e 'tell application \"Sublime Text\" to activate'"
21+
cmd = (
22+
cmd + "osascript -e 'tell application \"Sublime Text\" to activate'"
23+
)
2124
elif sublime.platform() == "linux":
2225
cmd = "sleep 1; pkill [Ss]ubl; pkill plugin_host; sleep 1; "
2326
if restart:
2427
cmd = cmd + "subl"
2528
elif sublime.platform() == "windows":
2629
cmd = "sleep 1 & taskkill /F /im sublime_text.exe & sleep 1 "
2730
if restart:
28-
cmd = cmd + "& \"{}\"".format(sublime.executable_path())
31+
cmd = cmd + '& "{}"'.format(sublime.executable_path())
32+
else:
33+
return
2934

3035
subprocess.Popen(cmd, shell=True)
3136

3237
def touch(file_name):
3338
f = os.path.join(
34-
sublime.packages_path(),
35-
"0_install_package_control_helper",
36-
file_name)
37-
open(f, 'a').close()
39+
sublime.packages_path(), "0_install_package_control_helper", file_name
40+
)
41+
open(f, "a").close()
3842

39-
def check_bootstrap():
40-
if pc_settings.get("bootstrapped", False):
41-
touch("bootstrapped")
42-
kill_subl(True)
43+
def satisfy_libraries():
44+
if "Package Control" in sys.modules:
45+
package_control = sys.modules["Package Control"].package_control
4346
else:
44-
sublime.set_timeout(check_bootstrap, 5000)
45-
46-
def check_dependencies():
47-
if 'Package Control' in sys.modules:
48-
package_control = sys.modules['Package Control'].package_control
49-
else:
50-
sublime.set_timeout(check_dependencies, 5000)
47+
sublime.set_timeout(satisfy_libraries, 5000)
5148
return
5249

5350
manager = package_control.package_manager.PackageManager()
54-
required_dependencies = set(manager.find_required_dependencies())
55-
56-
class myPackageCleanup(package_control.package_cleanup.PackageCleanup):
57-
58-
def finish(self, installed_packages, found_packages, found_dependencies):
59-
missing_dependencies = required_dependencies - set(found_dependencies)
6051

61-
if len(missing_dependencies) == 0:
62-
touch("success")
63-
kill_subl()
64-
else:
65-
with open(logfile, "a") as f:
66-
f.write("missing dependencies:" + "\n")
67-
f.write(" ".join(missing_dependencies) + "\n")
68-
sublime.set_timeout(_check_dependencies, 5000)
69-
70-
def _check_dependencies():
71-
myPackageCleanup().run()
72-
73-
_check_dependencies()
52+
# query and install missing libraries
53+
required_libraries = manager.find_required_libraries()
54+
if required_libraries:
55+
manager.install_libraries(required_libraries, fail_early=False)
56+
57+
# re-query missing libraries
58+
missing_libraries = manager.find_missing_libraries(
59+
required_libraries=required_libraries
60+
)
61+
if missing_libraries:
62+
log.write("missing dependencies:" + "\n")
63+
log.write(" ".join(sorted(missing_libraries)) + "\n")
64+
else:
65+
touch("success")
7466

75-
if not os.path.exists(os.path.join(
76-
sublime.packages_path(),
77-
"0_install_package_control_helper",
78-
"bootstrapped")):
79-
check_bootstrap()
80-
else:
81-
# restart sublime when `sublime.error_message` is run
82-
def error_message(message):
83-
with open(logfile, "a") as f:
84-
f.write(message + "\n")
67+
kill_subl()
8568

86-
kill_subl(True)
69+
# restart sublime when `sublime.error_message` is run
70+
def error_message(message):
71+
# log.write(message + "\n")
72+
kill_subl(True)
8773

88-
sublime.error_message = error_message
89-
check_dependencies()
74+
sublime.error_message = error_message
75+
sublime.set_timeout(satisfy_libraries, 5000)

0 commit comments

Comments
 (0)