Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
update pymyinstall for the win setup
Browse files Browse the repository at this point in the history
  • Loading branch information
sdpython committed Jun 19, 2015
1 parent 67962a2 commit d209f23
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 43 deletions.
5 changes: 3 additions & 2 deletions build_win_setup.py
Expand Up @@ -16,6 +16,7 @@


if True:
win_python_setup(module_list=list_modules, verbose=True,
win_python_setup(module_list=list_modules, verbose=True,
download_only=False,
no_setup=True)
no_setup=True,
step_skip=None) #["julia_install", "julia_build", "r_install"])
12 changes: 12 additions & 0 deletions src/pymyinstall/packaged/packaged_config.py
Expand Up @@ -109,6 +109,11 @@ def small_installation():
ModuleInstall("sphinxjp.themes.revealjs", "pip"),
ModuleInstall("feedparser", "wheel"), # to parse RSS streams
ModuleInstall("python-jenkins", "pip", mname="jenkins"), # for Jenkins
#
# 2015-06-15
#
ModuleInstall('envoy', 'pip'),
ModuleInstall('Logbook', 'wheel', mname='logbook'),
]

if sys.platform.startswith("win"):
Expand Down Expand Up @@ -457,6 +462,13 @@ def extension_ensae():
# ModuleInstall("pyjsdl", "github", "jggatc"), # no setup.py
#
# twisted, scrapy, not ready yet on Python 3

#
#
#
ModuleInstall("zipline", "pip"), # finance
ModuleInstall("vincent", "pip"), # graph
ModuleInstall("pygal", "pip"), # graph

]
return mod
Expand Down
2 changes: 0 additions & 2 deletions src/pymyinstall/win_installer/Julia_install.jl
Expand Up @@ -23,7 +23,5 @@ Pkg.add("Gadfly")
Pkg.add("Distributions")
Pkg.add("Docile")
Pkg.add("Clustering")
Pkg.add("KUnet")
Pkg.add("Graphs")
Pkg.add("Winston")
Pkg.add("GeneticAlgorithm")
16 changes: 11 additions & 5 deletions src/pymyinstall/win_installer/win_setup_julia.py
Expand Up @@ -2,6 +2,8 @@
@file
@brief Functions to prepare a setup on Windows, R functions
"""
from __future__ import print_function

import os
from ..installhelper.install_cmd_helper import run_cmd

Expand Down Expand Up @@ -33,7 +35,7 @@ def julia_run_script(julia_path, python_path, script, verbose=False, fLOG=print)
"""
memo_path = os.environ["PATH"]
epath = memo_path + ";" + \
";".join(python_path, os.path.join(python_path, "Scripts"))
";".join([python_path, os.path.join(python_path, "Scripts")])
os.environ["PATH"] = epath

exe = os.path.join(julia_path, "bin", "julia.exe")
Expand All @@ -46,6 +48,8 @@ def julia_run_script(julia_path, python_path, script, verbose=False, fLOG=print)
os.environ["JULIA_PKGDIR"] = pkg
cmd = [exe, script, "--no_history-file"]
cmd = " ".join(cmd)
if verbose:
fLOG("set JULIA_PKGDIR=" + pkg)
out, err = run_cmd(cmd, wait=True)
if err is not None and len(err) > 0 and \
"err" in err.lower() or "warn" in err.lower():
Expand All @@ -66,16 +70,18 @@ def patch_julia03(julia_path, verbose=False, fLOG=print):
@param fLOG logging function
"""
pkg = os.path.join(julia_path, "pkg")
pkg_d = pkd.replace("\\", "\\\\")
pkg_d = pkg.replace("\\", "\\\\")
if verbose:
fLOG(" string to replace", pkg_d)
for root, dirs, files in os.walk(pkg):
for name in files:
if name.endswith("deps.jl"):
full = os.path.join(root, name)
with open(full, "r", encoding="utf8") as f:
content = f.read()
if pkg_d in content:
content = content.replace(pkd_d, "%JULIA_PKGDIR%")
content = content.replace(pkg_d, "%JULIA_PKGDIR%")
if verbose:
fLOG(" patch ", name)
with open(full, "w", enconding="utf8") as f:
fLOG(" patch ", full)
with open(full, "w", encoding="utf8") as f:
f.write(content)
91 changes: 57 additions & 34 deletions src/pymyinstall/win_installer/win_setup_main.py
Expand Up @@ -74,7 +74,8 @@ def win_python_setup(folder="dist/win_python_setup",
fLOG=print,
download_only=False,
no_setup=False,
notebooks=None
notebooks=None,
step_skip=None
):
"""
Prepares a Windows distribution of Python based on InnoSetup,
Expand All @@ -87,6 +88,9 @@ def win_python_setup(folder="dist/win_python_setup",
@param no_setup skip the building of the setup
@param verbose print more information
@param notebooks notebooks to copy to the workspace, list of ("subfolders", url)
@param step_skip to skip step if they already succeeded or if they were done anothr way,
if a step does not belong to the list, the function will raise an exception
and give the available list of steps
@return list of completed operations
The function first downloads everything.
Expand Down Expand Up @@ -129,12 +133,28 @@ def win_python_setup(folder="dist/win_python_setup",
This works only for Windows.
@endexample
@warning The Julia installation might be stuck after the installation or the build.
In that case, the script python should be stopped by stopping the Julia
process from the Task Manager
and started again. If it has completed, it will go to the
next step.
"""
if notebooks is None:
notebooks = _default_notebooks

def now():
return datetime.datetime.now()

if step_skip is None:
step_skip = []

# steps
available_steps = {"julia_install", "julia_build", "r_install"}
for a in step_skip:
if a not in available_steps:
raise ValueError("skipped step {0} not in list {1}".format(a, ", ".join(sorted(available_steps))))
# next

operations = []
operations.append(("time", now()))
Expand Down Expand Up @@ -255,39 +275,42 @@ def now():
operations.extend(op)
operations.append(("time", now()))

##########################
# install Julia packages
#########################
fLOG("--- install julia packages")
jl = os.path.join(folders["tools"], "Julia")
output = os.path.join(folders["logs"], "out.install.julia.txt")
out = julia_run_script(jl, _script_julia)
with open(os.path.join(folders["logs"], "out.install.julia.txt"), "w", encoding="utf8") as f:
f.write(out)
operations.append(("Julia", _script_julia))
operations.append(("time", now()))

#########################
# build Julia packages
#########################
fLOG("--- build julia packages")
jl = os.path.join(folders["tools"], "Julia")
output = os.path.join(folders["logs"], "out.build.julia.txt")
out = julia_run_script(jl, folders["python"], _script_julia_build)
with open(os.path.join(folders["logs"], "out.build.julia.txt"), "w", encoding="utf8") as f:
f.write(out)
operations.append(("Julia", _script_julia_build))
operations.append(("time", now()))

######################
# install R packages
######################
fLOG("--- install R packages")
r = os.path.join(folders["tools"], "R")
output = os.path.join(folders["logs"], "out.install.r.txt")
out = r_run_script(r, _script_r, output)
operations.append(("R", _script_r))
operations.append(("time", now()))
if "julia_install" not in step_skip:
##########################
# install Julia packages
#########################
fLOG("--- install julia packages")
jl = os.path.join(folders["tools"], "Julia")
output = os.path.join(folders["logs"], "out.install.julia.txt")
out = julia_run_script(jl, folders["python"], _script_julia, verbose=verbose, fLOG=fLOG)
with open(os.path.join(folders["logs"], "out.install.julia.txt"), "w", encoding="utf8") as f:
f.write(out)
operations.append(("Julia", _script_julia))
operations.append(("time", now()))

if "julia_build" not in step_skip:
#########################
# build Julia packages
#########################
fLOG("--- build julia packages")
jl = os.path.join(folders["tools"], "Julia")
output = os.path.join(folders["logs"], "out.build.julia.txt")
out = julia_run_script(jl, folders["python"], _script_julia_build, verbose=verbose, fLOG=fLOG)
with open(os.path.join(folders["logs"], "out.build.julia.txt"), "w", encoding="utf8") as f:
f.write(out)
operations.append(("Julia", _script_julia_build))
operations.append(("time", now()))

if "r_install" not in step_skip:
######################
# install R packages
######################
fLOG("--- install R packages")
r = os.path.join(folders["tools"], "R")
output = os.path.join(folders["logs"], "out.install.r.txt")
out = r_run_script(r, _script_r, output)
operations.append(("R", _script_r))
operations.append(("time", now()))

######################
# installation of packages
Expand Down

0 comments on commit d209f23

Please sign in to comment.