Skip to content

Virtual Environments Linux/Windows #108

@rburghol

Description

@rburghol

(See previous: #101 and #55 )

Linux

Get venv going on linux:

# install the venv package sitewide
sudo python3.9 -m pip install virtualenv
# create a 
cd /usr/local/share/
mkdir venv
sudo chgrp allmodelers venv
sudo chmod g+w venv
cd venv/
# create the python 3.10 env (actually ended up being 3.9+ but ok)
python3.9 -m virtualenv hsp2dev_py10
# As of Ubuntu 24 with python 3.12 use venv
python3.12 -m venv hsp2dev_py13
chgrp allmodelers hsp2dev_py10 -Rf
chmod g+w hsp2dev_py10/* -Rf
cd /opt/model/HSPsquared/
source /usr/local/share/venv/hsp2dev_py10/bin/activate
# 2 ways to use pip:
# called as direct pip install
pip3.9 install .
# or called as python module
python3 -m pip install .

# then run as per normal
rm PL3_5250_0001.h5
hsp2 import_uci PL3_5250_0001.uci PL3_5250_0001.h5
hsp2 run PL3_5250_0001.h5

Add a shortcut to activate env

  • This is in linux, the path is long
  • Create file in a local path exec dir like /home/rob/.local/bin/py312 with contents:
    • #!/bin/bash
    • source /usr/local/share/venv/hsp2dev_py10/bin/activate
  • Activate with . py312 (must precede script name with period to get loaded into current shell)
  • Note: install ruff and pre-commit to insure compatibility with changes from respec team Install ruff & pre-commit #118

New environments need new package installs

  • When you first activate a new environment with a new python, you will need to install all your libs
python -m pip install numba
python -m pip install typed
python -m pip install numpy

Windows

  • Must have C++ tools installed, and after update to VScode reinstall from Extensions:
    • Note the base C/C++ extension had to be installed on VPN (maybe just coincidence?)
Image
  • Set up python 13 venv
    • note: set a custom default-timeout parameter due to network latency
    • done with powershell this time
# install the necessary virtual environment modules
C:\Users\faw18626\AppData\Local\Programs\Python\Python313\python.exe  -m pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --user virtualenv --default-timeout=100

# create the virtual environment
cd "C:\Users\faw18626\virtualenvs"
C:\Users\faw18626\AppData\Local\Programs\Python\Python313\python.exe -m virtualenv hsp2dev_py313

# Activate the new env
./hsp2dev_py313/Scripts/activate 
# in bash use: 
source hsp2dev_py313/Scripts/activate

# install hsp2
cd C:\usr\local\home\git\HSPsquared
# in bash use: 
cd /c/usr/local/home/git/HSPsquared
python -m pip install . --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --default-timeout=100

Activate Existing Env in GitBash

# Activate the new env
source /c/Users/faw18626/virtualenvs/hsp2dev_py313/Scripts/activate

Run without numba (for debugging)

  • NUMBA_DISABLE_JIT=1 hsp2 run test10specl.h5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions