Skip to content

Commit 5136195

Browse files
committed
Refactoring installation dependencies
1 parent 68fea3a commit 5136195

1 file changed

Lines changed: 12 additions & 38 deletions

File tree

sconstruct

Lines changed: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -72,48 +72,22 @@ env.Append(
7272
symbolDictionaries=buildVars.symbolDictionaries,
7373
)
7474

75-
76-
# Custom builder function to download dependencies for specific platform and Python version
77-
def InstallDependencies(target, source, env):
78-
"""
79-
Install required dependencies for Windows platform using pip download
80-
"""
81-
cmd = [
82-
"pip",
83-
"install",
84-
"--no-deps",
85-
"--no-compile",
86-
"-r",
87-
REQUIREMENTS_FILE,
88-
"-t",
89-
LIB_DIR,
90-
"--platform",
91-
WHEEL_PLATFORM,
92-
"--python-version",
93-
NVDA_PYTHON_VERSION,
94-
]
95-
subprocess.run(cmd, check=True)
96-
return target, source
97-
98-
99-
# Add custom builders to environment
100-
env.Append(BUILDERS={"InstallDeps": env.Builder(action=InstallDependencies),})
101-
102-
# Define targets and dependencies
103-
deps_target = env.InstallDeps(LIB_DIR, REQUIREMENTS_FILE)
75+
# Ensure parent directory exists
76+
env.Command("addon/globalPlugins", [], Mkdir("$TARGET"))
10477

10578
# Copy plugin source directory to target directory
106-
copy_action = env.Command(PLUGIN_TARGET_DIR, PLUGIN_SOURCE_DIR, Copy("$TARGET", "$SOURCE"))
79+
copyAddon = env.Command(PLUGIN_TARGET_DIR, PLUGIN_SOURCE_DIR, Copy("$TARGET", "$SOURCE"))
10780

108-
# Ensure parent directory exists
109-
env.Command("addon/globalPlugins", [], Mkdir("$TARGET"))
81+
# Install required dependencies for Windows platform using pip download
82+
installDependencies = env.Command(
83+
LIB_DIR,
84+
REQUIREMENTS_FILE,
85+
f"pip install --no-deps --no-compile -r $SOURCE -t $TARGET --platform {WHEEL_PLATFORM} --python-version {NVDA_PYTHON_VERSION}",
86+
)
11087

11188
# Set proper dependencies between actions
112-
env.Depends(copy_action, "addon/globalPlugins")
113-
env.Depends(deps_target, copy_action)
114-
115-
# Create alias for the preparation process
116-
prepareAddon= env.Alias("prepare_addon", [deps_target, copy_action])
89+
env.Requires(copyAddon, "addon/globalPlugins")
90+
env.Depends(installDependencies, copyAddon)
11791

11892

11993
if env["dev"]:
@@ -199,7 +173,7 @@ manifest = env.NVDAManifest(env.File(addonDir/"manifest.ini"), "manifest.ini.tpl
199173
# Ensure manifest is rebuilt if buildVars is updated.
200174
env.Depends(manifest, "buildVars.py")
201175

202-
env.Depends(addon, prepareAddon)
176+
env.Depends(addon, installDependencies)
203177
env.Depends(addon, manifest)
204178
env.Default(addon)
205179
env.Clean(addon, [".sconsign.dblite", "addon/doc/" + buildVars.baseLanguage + "/"])

0 commit comments

Comments
 (0)