Skip to content

Commit c57b849

Browse files
authored
Merge pull request #1000 from Hecatron-Forks/master
Web installer for Windows / Linux
2 parents c32c08e + db45761 commit c57b849

File tree

6 files changed

+166
-0
lines changed

6 files changed

+166
-0
lines changed

conda/web-installer/.gitignore

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

conda/web-installer/Readme.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
## Running the constructor
17+
18+
To run
19+
```
20+
conda install jinja2 constructor
21+
python build.py <installer version> <github tag version>
22+
```
23+
24+
For Example
25+
```
26+
build.py 2.2 master
27+
```
28+
29+
## Activation
30+
31+
To Activate the environment
32+
```
33+
# Under Windows
34+
condabin\activate.bat
35+
36+
# Under Linux / MacOS
37+
source ~/cadquery/bin/activate
38+
```
39+

conda/web-installer/build.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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(
11+
"The installer verison is the version number used within the conda constructor script"
12+
)
13+
print("The tag verison is the version of cadquery that will be pulled from github")
14+
15+
16+
def write_file(destpath, contents):
17+
with open(destpath, "w") as destfile:
18+
destfile.write(contents)
19+
20+
21+
def run_cmd(cmdarray, workingdir, captureout=False):
22+
stdout = stderr = None
23+
if captureout:
24+
stdout = stderr = subprocess.PIPE
25+
proc = subprocess.Popen(
26+
cmdarray, cwd=workingdir, stdout=stdout, stderr=stderr, universal_newlines=True
27+
)
28+
proc_out, proc_err = proc.communicate()
29+
if proc.returncode != 0:
30+
raise RuntimeError("Failure to run command")
31+
return stdout, stderr
32+
33+
34+
def generate_templates(installer_version, tag_version):
35+
print("Generating Scripts")
36+
env = Environment(loader=FileSystemLoader("."), autoescape=select_autoescape())
37+
38+
template = env.get_template("construct.yaml.jinja2")
39+
output = template.render(installer_version=installer_version)
40+
write_file("construct.yaml", output)
41+
42+
template = env.get_template("post-install.bat.jinja2")
43+
output = template.render(tag_version=tag_version)
44+
write_file("post-install.bat", output)
45+
46+
template = env.get_template("post-install.sh.jinja2")
47+
output = template.render(tag_version=tag_version)
48+
write_file("post-install.sh", output)
49+
50+
51+
def run_constructor():
52+
print("Running constructor")
53+
scriptdir = os.path.dirname(os.path.realpath(__file__))
54+
builddir = os.path.join(scriptdir, "build")
55+
if not os.path.exists(builddir):
56+
os.makedirs(builddir)
57+
run_cmd(["constructor", scriptdir], builddir)
58+
59+
60+
def main():
61+
if len(sys.argv) < 2:
62+
usage()
63+
return
64+
installer_version = sys.argv[1]
65+
tag_version = sys.argv[2]
66+
generate_templates(installer_version, tag_version)
67+
run_constructor()
68+
69+
70+
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 too 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 -c conda-forge -c cadquery -y cadquery={{ tag_version }}
6+
7+
echo Cleaning Packages
8+
call conda clean -a -y
9+
call conda deactivate
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
echo Entering Conda Environment
4+
source $PREFIX/bin/activate
5+
6+
echo Installing CadQuery
7+
conda install -c conda-forge -c cadquery -y cadquery={{ tag_version }}
8+
9+
echo Cleaning Packages
10+
conda clean -a -y
11+
12+
echo To activate run
13+
echo source ~/cadquery/bin/activate

0 commit comments

Comments
 (0)