Skip to content
This repository has been archived by the owner on Jun 7, 2023. It is now read-only.

Commit

Permalink
Added command line option to create Python virtual environments
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan Hernando Vieites committed Dec 5, 2018
1 parent c3be9a8 commit 078ed7f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion CMake/common
5 changes: 5 additions & 0 deletions app/rtneuron
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ def _get_corrected_frame_count(player, frames):
return maxFrames
return frames

if options.venv:
import venv
venv.create(options.venv, system_site_packages=True, with_pip=True)
exit()

if options.demo:
print("--demo option is deprecated, use --app instead")
options.app = options.demo
Expand Down
36 changes: 16 additions & 20 deletions rtneuron/python/rtneuron/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
_has_rest_support = True
except:
_has_rest_support = False
try:
import venv
_has_venv = True
except ImportError:
_has_venv = False

DEFAULT_BLUECONFIG="/nfs4/bbp.epfl.ch/visualization/Circuits/KaustCircuit/BlueConfig"
DEFAULT_APP='circuit_viewer'
Expand Down Expand Up @@ -446,11 +451,12 @@ def to_bool(x):
# Declares and parses the command line options
def command_line_options(argv):
args_parser = argparse.ArgumentParser(
usage="""rtneuron [-h] [-v] [--shell] [--app app_name]
[-c filename] [--target name [neuron_mode [color]]]
[-n gid [neuron_mode [color]]]
[--neurons start_gid end_gid [neuron_mode [color]]]
[options...]""",
usage=("rtneuron [-h] [-v] [--shell] " + (
"[--venv end_dir] " if _has_venv else "") + """[--app app_name]
[-c filename] [--target name [neuron_mode [color]]]
[-n gid [neuron_mode [color]]]
[--neurons start_gid end_gid [neuron_mode [color]]]
[options...]"""),
description="RTNeuron command line application",
epilog="For further help please check the user guide available at: https://bbp.epfl.ch/documentation/code/RTNeuron-${VERSION_MAJOR}.${VERSION_MINOR}/index.html",
formatter_class=HelpFormatter)
Expand Down Expand Up @@ -488,6 +494,11 @@ def command_line_options(argv):
help="Start an interactive IPython shell after initialization (or" \
" a regular console if IPython is not available).")

if _has_venv:
args_parser.add_argument(
"--venv", type=str, metavar="dirname",
help="Creates a virtual Python environment in a target directory")

# Data loading options
group = args_parser.add_argument_group("Data loading options")
group.add_argument(
Expand Down Expand Up @@ -1023,18 +1034,3 @@ def create_rtneuron_engine_attributes(options):
attr.profile.enable = True

return attr

# Per layer values for interneurons
# Layer 1 Layer 2 Layer 3 Layer 4 Layer 5 Layer 6
# NGC 7.15 NGC 7.61 NGC 7.61 NGC 7.61 NGC 7.61 NGC 7.61
# CRC 7.27
# BP 6.47 BP 6.47 BP 7.10 BP 7.10 BP 7.10
# ChC 8.04 ChC 8.01 ChC 7.97 ChC 8.04 ChC 7.98
# LBC 6.62 LBC 8.53 LBC 8.53 LBC 9.75 LBC 10.03 LBC 9.38
# NBC 7.48 NBC 8.75 NBC 8.87 NBC 8.20 NBC 7.80 NBC 8.75
# MC 9.85 MC 9.41 MC 9.32 MC 8.93 MC 9.48
# ADC 7.72
# AHC 7.53
# DBC 6.46 DBC 6.63 DBC 6.52 DBC 6.63 DBC 6.85
# SBC 6.55 SBC 7.02 SBC 7.19 SBC 9.00 SBC 7.76 SBC 7.79
# BTC 9.13 BTC 9.57 BTC 8.35 BTC 9.36 BTC 9.62

0 comments on commit 078ed7f

Please sign in to comment.