trmnl_preview 0.8.9 → 0.8.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 04ad9007c6a3cc5b8d3c724ec349b204c977f861fc41cb637428fba48c715b89
4
- data.tar.gz: ebc4873c90c6effcfc356ff13e38eb9b63d7547af14b85dc62eb84bb48145893
3
+ metadata.gz: 3145b576605d810530928542bfd48de0c6c402fa2ab8dc0063144c7ec15d5dfc
4
+ data.tar.gz: 4138e9af75278586a63fd4a6f3ca3d51bb2dd9b73f01c8ce74745dd84d96b56e
5
5
  SHA512:
6
- metadata.gz: c43c02691942bcea76563ce97d2b7e55f3327d207747a930374f750ad4edd257f8ed5b5edb94424ec008c3d0047735df33cb51399d44023a28522169613c6148
7
- data.tar.gz: 125935ffec1af3606b4a1f6e0d7687137349f25f2da0da1f03e989ad598c25b34cf56f23964ab5d16f448632307b858744bd3d7547c5babda94bb8e1bb828ba7
6
+ metadata.gz: a292f2a442bc47bd4654649f86293ac3ae91d8b9b6a484fd210685efbcbdabfbbef80f72d7f9828d401e3dc1dc5b601491a4bf0f39ab801c76ae2e7b64d898d0
7
+ data.tar.gz: bf523d8eeea24970c1cd3eb64e43cef8c4d38ea3a0749b401ff5b0f5951650ec73ce9da521ca943de0d312b88d513902c72eb9254afc6dab34b03c1d6699dbb0
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
 
2
2
  # Changelog
3
3
 
4
+ ## 0.8.10
5
+
6
+ - Fixed Python serverless transforms failing on Windows. The local subprocess backend hardcoded `python3`, which the python.org Windows installer does not put on PATH (it installs `python` and the `py` launcher), so every Python transform raised "interpreter not available". The interpreter is now resolved from a per-language list of command candidates (`python3`, then `python`, then the `py` launcher) using a cross-platform PATH lookup, leaving POSIX behavior unchanged. (#116)
7
+
4
8
  ## 0.8.9
5
9
 
6
10
  - Fixed `trmnlp serve` binding to localhost under Podman, which left the dev server unreachable through published ports. Container detection only looked for `/.dockerenv`, which Docker writes but Podman does not, so `serve` fell back to `127.0.0.1`. It now also checks for `/run/.containerenv`, which Podman writes, so the automatic `0.0.0.0` bind works for both runtimes. (#112)
@@ -4,6 +4,7 @@ require 'open3'
4
4
  require 'tmpdir'
5
5
 
6
6
  require_relative '../transform_client'
7
+ require_relative 'which'
7
8
  require_relative 'wrapper'
8
9
 
9
10
  module TRMNLP
@@ -19,11 +20,16 @@ module TRMNLP
19
20
  # Seconds a TERM'd process is given to exit before escalating to KILL.
20
21
  GRACE_PERIOD = 0.1
21
22
 
23
+ # Candidate commands per language, highest priority first. Windows is
24
+ # why a language needs more than one: its python.org installer provides
25
+ # `python` and the `py` launcher but no `python3`. `py` ranks last yet
26
+ # is the surest Windows hit — it stays on PATH even when the installer's
27
+ # optional "Add to PATH" step is skipped.
22
28
  INTERPRETERS = {
23
- 'python' => { cmd: 'python3', ext: 'py' },
24
- 'ruby' => { cmd: 'ruby', ext: 'rb' },
25
- 'node' => { cmd: 'node', ext: 'js' },
26
- 'php' => { cmd: 'php', ext: 'php' }
29
+ 'python' => { cmds: %w[python3 python py], ext: 'py' },
30
+ 'ruby' => { cmds: %w[ruby], ext: 'rb' },
31
+ 'node' => { cmds: %w[node], ext: 'js' },
32
+ 'php' => { cmds: %w[php], ext: 'php' }
27
33
  }.freeze
28
34
 
29
35
  def execute(code:, language:, stdin: '', timeout_seconds: DEFAULT_TIMEOUT)
@@ -40,7 +46,7 @@ module TRMNLP
40
46
  output_path = File.join(dir, 'output.json')
41
47
  src_path = File.join(dir, "transform.#{spec[:ext]}")
42
48
  File.write(src_path, Wrapper.for(language, code, sink_for(language, output_path)))
43
- run_process(spec[:cmd], src_path, stdin, timeout_seconds, output_path)
49
+ run_process(Which.resolve(spec[:cmds]), src_path, stdin, timeout_seconds, output_path)
44
50
  end
45
51
  rescue Errno::ENOENT, Errno::EACCES => e
46
52
  failure("interpreter not available: #{e.message}")
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TRMNLP
4
+ module TransformBackend
5
+ # Resolves a command to the interpreter actually present on PATH, so one
6
+ # transform runs unchanged on platforms that name an interpreter
7
+ # differently — most pressingly Windows, which ships no `python3`.
8
+ module Which
9
+ module_function
10
+
11
+ # Falls back to the first candidate when none resolve, leaving the
12
+ # caller to surface the usual "interpreter not available" ENOENT.
13
+ def resolve(candidates, path: ENV.fetch('PATH', ''), pathext: ENV.fetch('PATHEXT', ''))
14
+ candidates.find { |cmd| locate(cmd, path: path, pathext: pathext) } || candidates.first
15
+ end
16
+
17
+ # Windows marks executables by extension, enumerated in PATHEXT
18
+ # (.EXE/.BAT/...); POSIX leaves PATHEXT unset and relies on the exec bit.
19
+ def locate(cmd, path: ENV.fetch('PATH', ''), pathext: ENV.fetch('PATHEXT', ''))
20
+ suffixes = pathext.split(File::PATH_SEPARATOR)
21
+ suffixes = [''] if suffixes.empty?
22
+ path.split(File::PATH_SEPARATOR)
23
+ .product(suffixes)
24
+ .map { |dir, suffix| File.join(dir, "#{cmd}#{suffix}") }
25
+ .find { |candidate| File.file?(candidate) && File.executable?(candidate) }
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TRMNLP
4
- VERSION = '0.8.9'
4
+ VERSION = '0.8.10'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trmnl_preview
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.9
4
+ version: 0.8.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rockwell Schrock
@@ -313,6 +313,7 @@ files:
313
313
  - lib/trmnlp/screenshot.rb
314
314
  - lib/trmnlp/transform_backend/http.rb
315
315
  - lib/trmnlp/transform_backend/subprocess.rb
316
+ - lib/trmnlp/transform_backend/which.rb
316
317
  - lib/trmnlp/transform_backend/wrapper.rb
317
318
  - lib/trmnlp/transform_client.rb
318
319
  - lib/trmnlp/transform_pipeline.rb