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

Commit 078ed7f

Browse files
author
Juan Hernando Vieites
committed
Added command line option to create Python virtual environments
1 parent c3be9a8 commit 078ed7f

File tree

3 files changed

+22
-21
lines changed

3 files changed

+22
-21
lines changed

app/rtneuron

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ def _get_corrected_frame_count(player, frames):
106106
return maxFrames
107107
return frames
108108

109+
if options.venv:
110+
import venv
111+
venv.create(options.venv, system_site_packages=True, with_pip=True)
112+
exit()
113+
109114
if options.demo:
110115
print("--demo option is deprecated, use --app instead")
111116
options.app = options.demo

rtneuron/python/rtneuron/options.py

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@
4343
_has_rest_support = True
4444
except:
4545
_has_rest_support = False
46+
try:
47+
import venv
48+
_has_venv = True
49+
except ImportError:
50+
_has_venv = False
4651

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

497+
if _has_venv:
498+
args_parser.add_argument(
499+
"--venv", type=str, metavar="dirname",
500+
help="Creates a virtual Python environment in a target directory")
501+
491502
# Data loading options
492503
group = args_parser.add_argument_group("Data loading options")
493504
group.add_argument(
@@ -1023,18 +1034,3 @@ def create_rtneuron_engine_attributes(options):
10231034
attr.profile.enable = True
10241035

10251036
return attr
1026-
1027-
# Per layer values for interneurons
1028-
# Layer 1 Layer 2 Layer 3 Layer 4 Layer 5 Layer 6
1029-
# NGC 7.15 NGC 7.61 NGC 7.61 NGC 7.61 NGC 7.61 NGC 7.61
1030-
# CRC 7.27
1031-
# BP 6.47 BP 6.47 BP 7.10 BP 7.10 BP 7.10
1032-
# ChC 8.04 ChC 8.01 ChC 7.97 ChC 8.04 ChC 7.98
1033-
# LBC 6.62 LBC 8.53 LBC 8.53 LBC 9.75 LBC 10.03 LBC 9.38
1034-
# NBC 7.48 NBC 8.75 NBC 8.87 NBC 8.20 NBC 7.80 NBC 8.75
1035-
# MC 9.85 MC 9.41 MC 9.32 MC 8.93 MC 9.48
1036-
# ADC 7.72
1037-
# AHC 7.53
1038-
# DBC 6.46 DBC 6.63 DBC 6.52 DBC 6.63 DBC 6.85
1039-
# SBC 6.55 SBC 7.02 SBC 7.19 SBC 9.00 SBC 7.76 SBC 7.79
1040-
# BTC 9.13 BTC 9.57 BTC 8.35 BTC 9.36 BTC 9.62

0 commit comments

Comments
 (0)