trmnl_preview 0.8.8 → 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 +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +2 -1
- data/lib/trmnlp/cli.rb +5 -1
- data/lib/trmnlp/transform_backend/subprocess.rb +11 -5
- data/lib/trmnlp/transform_backend/which.rb +29 -0
- data/lib/trmnlp/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3145b576605d810530928542bfd48de0c6c402fa2ab8dc0063144c7ec15d5dfc
|
|
4
|
+
data.tar.gz: 4138e9af75278586a63fd4a6f3ca3d51bb2dd9b73f01c8ce74745dd84d96b56e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a292f2a442bc47bd4654649f86293ac3ae91d8b9b6a484fd210685efbcbdabfbbef80f72d7f9828d401e3dc1dc5b601491a4bf0f39ab801c76ae2e7b64d898d0
|
|
7
|
+
data.tar.gz: bf523d8eeea24970c1cd3eb64e43cef8c4d38ea3a0749b401ff5b0f5951650ec73ce9da521ca943de0d312b88d513902c72eb9254afc6dab34b03c1d6699dbb0
|
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
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
|
+
|
|
8
|
+
## 0.8.9
|
|
9
|
+
|
|
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)
|
|
11
|
+
|
|
4
12
|
## 0.8.8
|
|
5
13
|
|
|
6
14
|
- Added a `--server` flag to `trmnlp login` so commands like `trmnlp push` can target a self-hosted (BYOS) server. The chosen URL is saved as `base_url`, and the `user_` API key prefix is only required for trmnl.com; BYOS servers accept their own token formats. A scheme-less `--server` value (such as `localhost:3000`) no longer crashes the host check. (#113)
|
data/README.md
CHANGED
|
@@ -206,7 +206,8 @@ docker run \
|
|
|
206
206
|
--pull always \
|
|
207
207
|
--publish 4567:4567 \
|
|
208
208
|
--volume "$(pwd):/plugin" \
|
|
209
|
-
trmnl/trmnlp serve
|
|
209
|
+
trmnl/trmnlp serve \
|
|
210
|
+
--bind 0.0.0.0
|
|
210
211
|
```
|
|
211
212
|
|
|
212
213
|
`--pull always` checks the registry on every run and pulls a newer image if one exists, so you don't have to remember to `docker pull` after each release.
|
data/lib/trmnlp/cli.rb
CHANGED
|
@@ -16,7 +16,11 @@ module TRMNLP
|
|
|
16
16
|
|
|
17
17
|
def self.exit_on_failure? = true
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
# Docker writes /.dockerenv; Podman writes /run/.containerenv. Either means we're
|
|
20
|
+
# in a container, where binding to localhost makes the dev server unreachable via
|
|
21
|
+
# published ports, so we bind to all interfaces instead.
|
|
22
|
+
def self.in_container? = File.exist?('/.dockerenv') || File.exist?('/run/.containerenv')
|
|
23
|
+
def self.default_bind = in_container? ? '0.0.0.0' : '127.0.0.1'
|
|
20
24
|
|
|
21
25
|
desc 'build', 'Generate static HTML files'
|
|
22
26
|
method_option :png, type: :boolean, default: false, desc: 'Also render a PNG per view'
|
|
@@ -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' => {
|
|
24
|
-
'ruby' => {
|
|
25
|
-
'node' => {
|
|
26
|
-
'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[:
|
|
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
|
data/lib/trmnlp/version.rb
CHANGED
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.
|
|
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
|