pycall_thread 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb8af01c4091f60fbf0e3255b487817e6779b18d4f3dc1c449f303cea75094d4
4
- data.tar.gz: a8099eecf60897ccc436d5662be887f4ed4641fa1fa655af374b0d322cb64406
3
+ metadata.gz: de04a7790f025c9450436bf4258476136b2a9e55732fa0adcbfc9671ecdf2840
4
+ data.tar.gz: db51f2e173305c25bff70add0a291e442c3beb1eee425b5d0aeef1a74a522a5e
5
5
  SHA512:
6
- metadata.gz: 453798c6771820f009dfefb8ffde48039ca4924df3de24af4a6fffb0a07906cb253c4272006a31072b4e310dae0513a8ca60fd04760d2f8e93ac96480d9d80c5
7
- data.tar.gz: 708877b2fbdb55043ed13b84ecbd3ebe6b7c22b9b73b7f074a7435f3294e8762c626aef61695c912a79568672b016b1fa1e7679635db2233ee89b8bdebb45bb6
6
+ metadata.gz: 2aa5641cc051976e0cddd405bf98960881ab2ee698c1c35bdbf9fff6cf11bd57ed2cf6515ba140ffce0972e544d4eecce724fcd2a2db83491ec0424319d692c8
7
+ data.tar.gz: 4156c6dbaafbd74ccca113e44aff8fe4760336c12b0965c05b4e805031d0cb5b133a782c3ccd690e6d70a0b875f25bccb557eb8fbd1c751570073ab42beafadb
data/Gemfile CHANGED
@@ -5,11 +5,11 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in pycall_thread.gemspec
6
6
  gemspec
7
7
 
8
- gem "rake", "~> 13.0"
9
8
  gem "minitest", "~> 5.0"
9
+ gem "rake", "~> 13.0"
10
10
  gem "rubocop", "~> 1.21"
11
11
 
12
12
  # To use the local pycall, you must also run things with e.g.:
13
13
  # bundle exec ruby -I/Users/seth/src/pycall.rb/ext/pycall
14
- #
15
- # gem 'pycall', path: '/Users/seth/src/pycall.rb', require: false
14
+ #
15
+ # gem 'pycall', path: '/Users/seth/src/pycall.rb', require: false
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pycall_thread (0.1.1)
4
+ pycall_thread (0.1.3)
5
5
  pycall
6
6
 
7
7
  GEM
@@ -1,4 +1,4 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem 'pycall_thread'
4
- gem 'puma'
3
+ gem "puma", "~> 6.4.2"
4
+ gem "pycall_thread", "~> 0.1.3"
@@ -5,15 +5,15 @@ GEM
5
5
  puma (6.4.2)
6
6
  nio4r (~> 2.0)
7
7
  pycall (1.5.2)
8
- pycall_thread (0.1.0)
8
+ pycall_thread (0.1.2)
9
9
  pycall
10
10
 
11
11
  PLATFORMS
12
12
  arm64-darwin-23
13
13
 
14
14
  DEPENDENCIES
15
- puma
16
- pycall_thread
15
+ puma (~> 6.4.2)
16
+ pycall_thread (~> 0.1.2)
17
17
 
18
18
  BUNDLED WITH
19
19
  2.2.33
data/examples/puma/app.rb CHANGED
@@ -1,25 +1,27 @@
1
- require 'pycall_thread'
1
+ # require "pycall_thread"
2
+ require_relative "../../lib/pycall_thread"
2
3
 
3
4
  PyCallThread.init do
4
5
  # Setup our local venv (using pdm, in .venv)
5
- ENV['PYTHON'] = `pdm run which python`.strip
6
+ ENV["PYTHON"] = `pdm run which python`.strip
6
7
  site_dir = `pdm run python -c 'import site; print(site.getsitepackages()[0])'`.strip
7
8
 
8
- require 'pycall'
9
+ require "pycall"
9
10
 
10
11
  # This is to setup our local venv
11
- site = PyCall.import_module('site')
12
+ site = PyCall.import_module("site")
12
13
  site.addsitedir(site_dir)
13
14
  end
14
15
 
16
+ # Simple Puma App that demonstrates PyCallThread
15
17
  class App
16
- def call(env)
18
+ def call(_)
17
19
  winequality = PyCallThread.run do
18
- pandas = PyCall.import_module('pandas')
19
- data = pandas.read_csv('https://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-red.csv', sep: ';')
20
- data.to_json()
20
+ pandas = PyCall.import_module("pandas")
21
+ data = pandas.read_csv("https://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-red.csv", sep: ";")
22
+ data.to_html
21
23
  end
22
24
 
23
- [200, { 'Content-Type' => 'text/html' }, [winequality]]
25
+ [200, { "Content-Type" => "text/html" }, [winequality]]
24
26
  end
25
- end
27
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PycallThread
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.3"
5
5
  end
data/lib/pycall_thread.rb CHANGED
@@ -12,17 +12,16 @@ module PyCallThread
12
12
 
13
13
  # Start the thread we will use to run code invoked with PyCallThread.run
14
14
  @py_thread = Thread.new { pycall_thread_loop }
15
+ @initialized = true
15
16
 
16
17
  # If we've been passed a require_pycall_block, use that to require 'pycall'
17
18
  # instead of doing it directly.
18
19
  require_pycall(&require_pycall_block)
19
20
 
20
21
  at_exit { stop_pycall_thread }
21
-
22
- @initialized = true
23
22
  end
24
23
 
25
- def require_pycall(&require_pycall_block)
24
+ def self.require_pycall(&require_pycall_block)
26
25
  # Only safe to use PyCallThread if PyCall hasn't already been loaded
27
26
  raise "PyCall::LibPython already exists: PyCall can't have been initialized already" if defined?(PyCall::LibPython)
28
27
 
@@ -53,7 +52,7 @@ module PyCallThread
53
52
  run_result(result_queue.pop)
54
53
  end
55
54
 
56
- def self.run_result
55
+ def self.run_result(result)
57
56
  if result[:exception]
58
57
  raise result[:exception]
59
58
  elsif python_object?(result[:retval])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pycall_thread
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Nickell