Module: Legion::Python
- Defined in:
- lib/legion/python.rb
Constant Summary collapse
- VENV_DIR =
(ENV['LEGION_PYTHON_VENV'] || File.('~/.legionio/python')).freeze
- MARKER =
File.('~/.legionio/.python-venv').freeze
- PACKAGES =
%w[ python-pptx python-docx openpyxl pandas pillow requests lxml PyYAML tabulate markdown ].freeze
- SYSTEM_CANDIDATES =
%w[ /opt/homebrew/bin/python3 /usr/local/bin/python3 /usr/bin/python3 ].freeze
Class Method Summary collapse
- .find_system_python3 ⇒ Object
- .interpreter ⇒ Object
- .pip ⇒ Object
- .venv_exists? ⇒ Boolean
- .venv_pip ⇒ Object
- .venv_pip_exists? ⇒ Boolean
- .venv_python ⇒ Object
- .venv_python_exists? ⇒ Boolean
Class Method Details
.find_system_python3 ⇒ Object
61 62 63 64 65 66 |
# File 'lib/legion/python.rb', line 61 def find_system_python3 path_python = `command -v python3 2>/dev/null`.strip candidates = SYSTEM_CANDIDATES.dup candidates.unshift(path_python) unless path_python.empty? candidates.uniq.find { |p| File.executable?(p) } end |
.interpreter ⇒ Object
49 50 51 52 53 |
# File 'lib/legion/python.rb', line 49 def interpreter return venv_python if venv_python_exists? find_system_python3 || 'python3' end |
.pip ⇒ Object
55 56 57 58 59 |
# File 'lib/legion/python.rb', line 55 def pip return venv_pip if venv_pip_exists? 'pip3' end |
.venv_exists? ⇒ Boolean
29 30 31 |
# File 'lib/legion/python.rb', line 29 def venv_exists? File.exist?("#{VENV_DIR}/pyvenv.cfg") end |
.venv_pip ⇒ Object
37 38 39 |
# File 'lib/legion/python.rb', line 37 def venv_pip "#{VENV_DIR}/bin/pip" end |
.venv_pip_exists? ⇒ Boolean
45 46 47 |
# File 'lib/legion/python.rb', line 45 def venv_pip_exists? File.executable?(venv_pip) end |
.venv_python ⇒ Object
33 34 35 |
# File 'lib/legion/python.rb', line 33 def venv_python "#{VENV_DIR}/bin/python3" end |
.venv_python_exists? ⇒ Boolean
41 42 43 |
# File 'lib/legion/python.rb', line 41 def venv_python_exists? File.executable?(venv_python) end |