Skip to content

Commit c35ed08

Browse files
committed
additional packages
1 parent 7712091 commit c35ed08

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

src/compas_blender/install_windows.py

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def unregister():
3030
"""
3131

3232

33-
def install_windows(blender_path, version=None, force_reinstall=False, no_deps=False):
33+
def install_windows(blender_path, version=None, packages=None, force_reinstall=False, no_deps=False):
3434
"""Install COMPAS for Blender on Windows.
3535
3636
Parameters
@@ -42,6 +42,13 @@ def install_windows(blender_path, version=None, force_reinstall=False, no_deps=F
4242
version : {'2.83', '2.93', '3.1'}, optional
4343
The version number of Blender.
4444
Default is ``'2.93'``.
45+
packages : list[str], optional
46+
Additional packages to install.
47+
Note that the packages should be available on the Python Package Index (PyPI).
48+
force_reinstall : bool, optional
49+
Force existing packages to be reinstalled.
50+
no_deps : bool, optional
51+
Ignore requirements of the specified packages during installation.
4552
4653
Examples
4754
--------
@@ -124,35 +131,38 @@ def install_windows(blender_path, version=None, force_reinstall=False, no_deps=F
124131

125132
try:
126133
args = [blenderpython, "-m", "pip", "install", "compas"]
134+
if packages:
135+
args += packages
127136
if force_reinstall:
128137
args.append("--force-reinstall")
129138
if no_deps:
130139
args.append("--no-deps")
131140

132141
subprocess.run(args, check=True)
133142
except subprocess.CalledProcessError:
134-
print("Could not install compas")
143+
print("Could not install compas or some of the requested additional packages.")
135144
sys.exit(-1)
136145

137-
# Take either the CONDA environment directory or the current Python executable's directory
138-
python_directory = os.environ.get("CONDA_PREFIX", None) or os.path.dirname(
139-
sys.executable
140-
)
141-
environment_name = os.environ.get("CONDA_DEFAULT_ENV", "")
146+
# # Take either the CONDA environment directory or the current Python executable's directory
147+
# python_directory = os.environ.get("CONDA_PREFIX", None) or os.path.dirname(
148+
# sys.executable
149+
# )
150+
# environment_name = os.environ.get("CONDA_DEFAULT_ENV", "")
142151

143152
# Get current sys.version value, we will override it inside Blender
144153
# because it seems Blender overrides it as well, but doing so breaks many things after having replaced the Python interpreter
145154

146-
_handle, bootstrapper_temp_path = tempfile.mkstemp(suffix=".py", text=True)
155+
# _handle, bootstrapper_temp_path = tempfile.mkstemp(suffix=".py", text=True)
147156

148-
with open(bootstrapper_temp_path, "w") as f:
149-
f.write(BOOTSTRAPPER_TEMPLATE.format(environment_name, python_directory))
157+
# with open(bootstrapper_temp_path, "w") as f:
158+
# f.write(BOOTSTRAPPER_TEMPLATE.format(environment_name, python_directory))
150159

151-
print(" Creating bootstrap script: {}".format(compas_bootstrapper))
152-
copy(bootstrapper_temp_path, compas_bootstrapper)
160+
# print(" Creating bootstrap script: {}".format(compas_bootstrapper))
161+
# copy(bootstrapper_temp_path, compas_bootstrapper)
153162

154163
print()
155-
print("COMPAS for Blender {} has been installed.".format(version))
164+
print("COMPAS for Blender {} has been installed via pip.".format(version))
165+
print("Note that functionaliy of conda-only packages has to be run via the command server (RPC).")
156166

157167

158168
# ==============================================================================
@@ -176,6 +186,7 @@ def install_windows(blender_path, version=None, force_reinstall=False, no_deps=F
176186
choices=["2.83", "2.93", "3.1"],
177187
help="The version of Blender to install COMPAS in.",
178188
)
189+
parser.add_argument('-p', '--packages', nargs='+', help="The packages to install.")
179190
parser.add_argument("--force-reinstall", dest="force_reinstall", default=False, action="store_true")
180191
parser.add_argument("--no-deps", dest="no_deps", default=False, action="store_true")
181192

@@ -184,6 +195,7 @@ def install_windows(blender_path, version=None, force_reinstall=False, no_deps=F
184195
install_windows(
185196
args.blenderpath,
186197
version=args.version,
198+
packages=args.packages,
187199
force_reinstall=args.force_reinstall,
188200
no_deps=args.no_deps
189201
)

0 commit comments

Comments
 (0)