Skip to content

lang.python #

use virtual env

import freeflowuniverse.crystallib.lang.python
py:=python.new(name:'default')! //a python env with name default
py.update()!
py.pip('ipython')!

to activate an environment and use the installed python

source ~/hero/python/default/bin/activate

fn new #

fn new(args_ PythonEnvArgs) !PythonEnv

struct PythonEnv #

struct PythonEnv {
pub mut:
	name string
	path pathlib.Path
	// db   dbfs.DB
}

fn (PythonEnv) exec #

fn (py PythonEnv) exec(args PythonExecArgs) !string

fn (PythonEnv) freeze #

fn (mut py PythonEnv) freeze(name string) !

remember the requirements list for all pips

fn (PythonEnv) init_env #

fn (py PythonEnv) init_env() !

comma separated list of packages to install

fn (PythonEnv) pip #

fn (mut py PythonEnv) pip(packages string) !

comma separated list of packages to install

fn (PythonEnv) shell #

fn (py PythonEnv) shell(name_ string) !

fn (PythonEnv) update #

fn (py PythonEnv) update() !

comma separated list of packages to install

struct PythonEnvArgs #

@[params]
struct PythonEnvArgs {
pub mut:
	name  string = 'default'
	reset bool
}

struct PythonExecArgs #

@[params]
struct PythonExecArgs {
pub mut:
	cmd                string @[required]
	result_delimiter   string = '==RESULT=='
	ok_delimiter       string = '==OK=='
	python_script_name string // if used will put it in root of the sandbox under that name
	stdout             bool
}