From 0fb0d419b97ae28e1ca1460472614240a3e2306a Mon Sep 17 00:00:00 2001 From: Noah Horton Date: Sat, 29 Jul 2023 19:40:51 +0000 Subject: [PATCH] Finally loading Python --- .gitpod.yml | 15 +++++++++++++++ .vscode/settings.json | 3 +++ Gemfile | 2 ++ README.md | 19 +++++++++++++++++-- lib/guidance.rb | 1 + lib/guidance/program.rb | 7 +++++++ requirements.txt | 1 + test/guidance/program_test.rb | 8 ++++++++ 8 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 .gitpod.yml create mode 100644 .vscode/settings.json create mode 100644 lib/guidance/program.rb create mode 100644 requirements.txt create mode 100644 test/guidance/program_test.rb diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 0000000..1991dde --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1,15 @@ +# This configuration file was automatically generated by Gitpod. +# Please adjust to your needs (see https://www.gitpod.io/docs/introduction/learn-gitpod/gitpod-yaml) +# and commit this file to your remote git repository to share the goodness with others. + +# Learn more from ready-to-use templates: https://www.gitpod.io/docs/introduction/getting-started/quickstart + +tasks: + - init: + - bin/setup + - pyenv uninstall 3.11.1 + - env PYTHON_CONFIGURE_OPTS='--enable-shared' pyenv install 3.10 + - pyenv global 3.10 + - pip install guidance + + diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..0a77011 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "editor.tabSize": 2 +} \ No newline at end of file diff --git a/Gemfile b/Gemfile index 45b5814..bec6dd7 100644 --- a/Gemfile +++ b/Gemfile @@ -9,3 +9,5 @@ gem "rubocop-minitest", "0.31.0" gem "rubocop-packaging", "0.5.2" gem "rubocop-performance", "1.18.0" gem "rubocop-rake", "0.6.0" + +gem "pycall", "~> 1.4" diff --git a/README.md b/README.md index 3919685..96910a9 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,9 @@ [![Gem Version](https://img.shields.io/gem/v/guidance)](https://rubygems.org/gems/guidance) [![Gem Downloads](https://img.shields.io/gem/dt/guidance)](https://www.ruby-toolbox.com/projects/guidance) [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/Unsupervisedcom/guideance-rails/ci.yml)](https://github.com/Unsupervisedcom/guideance-rails/actions/workflows/ci.yml) -[![Code Climate maintainability](https://img.shields.io/codeclimate/maintainability/Unsupervisedcom/guideance-rails)](https://codeclimate.com/github/Unsupervisedcom/guideance-rails) -TODO: Description of this gem goes here. +This Gem wraps https://github.com/microsoft/guidance for use in Ruby. +See documentation at in the Guidance repo for info on how to use it. --- @@ -16,7 +16,22 @@ TODO: Description of this gem goes here. - [Contribution guide](#contribution-guide) ## Quick start +This requires a version of python that includes the library version. +Development has been done using 3.10.9 which can be installed with the below. +You must also install Guidance. +``` +env PYTHON_CONFIGURE_OPTS='--enable-shared' pyenv install 3.10 +pyenv global 3.10 +pip install guidance +``` + +To install the gem using bundle: +``` +bundle add guidance +``` + +Via Ruby gems directly: ``` $ gem install guidance ``` diff --git a/lib/guidance.rb b/lib/guidance.rb index 042e3eb..82923f8 100644 --- a/lib/guidance.rb +++ b/lib/guidance.rb @@ -1,3 +1,4 @@ module Guidance autoload :VERSION, "guidance/version" + autoload :Program, "guidance/program" end diff --git a/lib/guidance/program.rb b/lib/guidance/program.rb new file mode 100644 index 0000000..1a712e3 --- /dev/null +++ b/lib/guidance/program.rb @@ -0,0 +1,7 @@ +require "pycall" + +class Guidance::Program + def initialize + @guidance_library = PyCall.import_module("math") + end +end diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..07d0c54 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +guidance \ No newline at end of file diff --git a/test/guidance/program_test.rb b/test/guidance/program_test.rb new file mode 100644 index 0000000..21d530f --- /dev/null +++ b/test/guidance/program_test.rb @@ -0,0 +1,8 @@ +require "test_helper" +require "guidance" + +class ProgramTest < Minitest::Test + def test_python_library_loads + Guidance::Program.new + end +end