Skip to content

Commit 38d111d

Browse files
committed
windows self installer
1 parent 23de5cc commit 38d111d

File tree

5 files changed

+128
-0
lines changed

5 files changed

+128
-0
lines changed

conda/web-installer/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# ignore files generated from templates
2+
construct.yaml
3+
post-install.bat
4+
build/

conda/web-installer/Readme.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Readme
2+
3+
This is a script for generating a self installer for cadquery using conda constructor
4+
5+
* https://github.com/conda/constructor
6+
7+
The installer
8+
9+
* Installs an instance of miniconda
10+
* Adds cadquery / conda-forge to the default channels
11+
* Runs a post install script to download install cadquery.
12+
13+
We need to install cadquery post install due to the file sizes involved with the install of opencascade (around 2Gb)
14+
This installer will not add the installed directory to the Path or try to override the default python (with the default options selected).
15+
16+
To run
17+
```
18+
build.py <installer version> <github tag version>
19+
```

conda/web-installer/build.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import sys
2+
import os
3+
import subprocess
4+
from jinja2 import Environment, select_autoescape, FileSystemLoader
5+
6+
7+
def usage():
8+
print('Web installer build script')
9+
print('build.py <installer version> <tag version>')
10+
print('The installer verison is the version number used within the conda constructor script')
11+
print('The tag verison is the version of cadquery that will be pulled from github')
12+
13+
def write_file(destpath, contents):
14+
with open(destpath, "w") as destfile:
15+
destfile.write(contents)
16+
17+
def run_cmd(cmdarray, workingdir, captureout=False):
18+
stdout = stderr = None
19+
if captureout:
20+
stdout = stderr = subprocess.PIPE
21+
proc = subprocess.Popen(cmdarray, cwd=workingdir, stdout=stdout, stderr=stderr, universal_newlines=True)
22+
proc_out, proc_err = proc.communicate()
23+
if proc.returncode != 0:
24+
raise RuntimeError('Failure to run command')
25+
return stdout, stderr
26+
27+
def generate_templates(installer_version, tag_version):
28+
print('Generating Scripts')
29+
env = Environment(
30+
loader=FileSystemLoader("."),
31+
autoescape=select_autoescape()
32+
)
33+
34+
template = env.get_template("construct.yaml.jinja2")
35+
output = template.render(installer_version=installer_version)
36+
write_file('construct.yaml', output)
37+
38+
template = env.get_template("post-install.bat.jinja2")
39+
output = template.render(tag_version=tag_version)
40+
write_file('post-install.bat', output)
41+
42+
# TODO
43+
#template = env.get_template("post-install.sh.jinja2")
44+
#output = template.render(tag_version=tag_version)
45+
#write_file('post-install.sh', output)
46+
47+
48+
def run_constructor():
49+
print('Running constructor')
50+
scriptdir = os.path.dirname(os.path.realpath(__file__))
51+
builddir = os.path.join(scriptdir, 'build')
52+
if not os.path.exists(builddir):
53+
os.makedirs(builddir)
54+
run_cmd(['constructor', scriptdir], builddir)
55+
56+
# TODO
57+
58+
def main():
59+
if len(sys.argv) < 2:
60+
usage()
61+
return
62+
installer_version = sys.argv[1]
63+
tag_version = sys.argv[2]
64+
generate_templates(installer_version, tag_version)
65+
run_constructor()
66+
67+
main()
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: cadquery
2+
version: {{ installer_version }}
3+
installer_type: all
4+
5+
license_file: ../../LICENSE
6+
7+
# Don't add to the system Path
8+
initialize_by_default: false
9+
# Don't set as the default python
10+
register_python_default: false
11+
12+
channels:
13+
- http://repo.anaconda.com/pkgs/main/
14+
- conda-forge
15+
- cadquery
16+
17+
write_condarc: true
18+
conda_default_channels:
19+
- conda-forge
20+
- cadquery
21+
22+
specs:
23+
- python 3.10*
24+
- conda
25+
# Occt is to o big to bundle so install during post_install instead
26+
# - cadquery
27+
28+
post_install: post-install.sh # [unix]
29+
post_install: post-install.bat # [win]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
echo Entering Conda Environment
2+
call %PREFIX%\condabin\activate.bat
3+
4+
echo Installing CadQuery
5+
call conda install -y cadquery={{ tag_version }}
6+
7+
echo Cleaning Packages
8+
call conda clean -a -y
9+
call conda deactivate

0 commit comments

Comments
 (0)