cmdstan 0.5.2 → 0.6.0
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 +5 -0
- data/lib/cmdstan/install.rb +31 -47
- data/lib/cmdstan/version.rb +1 -1
- data/lib/cmdstan.rb +3 -4
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e37a1b325115015777ec982a50254e5f3f8088548402684a3d53b4627d830247
|
|
4
|
+
data.tar.gz: c10323ae2cf6270b226d9aedc737be10b7dce205c1ed79525110a88492eb2e12
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4c0ae70d0483dcf9b7b4c0d2b65b2871a9242af5266cfe3e397e2e105bd3328c22e477ee70e96ddb7f9c58480411a6352e4a3928f3bfd8c6cc99ccfe63defb8b
|
|
7
|
+
data.tar.gz: 4c1bc9eb1e126b3886d1c4e1e3366a30bc505f3c86d40a4e77b058fc3c15f4e819cfee26babe20e7402850b1f5868f569a19ebda0975112e673e1b8add68409e
|
data/CHANGELOG.md
CHANGED
data/lib/cmdstan/install.rb
CHANGED
|
@@ -3,7 +3,7 @@ module CmdStan
|
|
|
3
3
|
include Utils
|
|
4
4
|
|
|
5
5
|
def cmdstan_version
|
|
6
|
-
"2.
|
|
6
|
+
"2.39.0"
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
def cmdstan_installed?
|
|
@@ -12,15 +12,20 @@ module CmdStan
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def install_cmdstan
|
|
15
|
+
require "digest"
|
|
16
|
+
require "fileutils"
|
|
17
|
+
require "open-uri"
|
|
18
|
+
require "tmpdir"
|
|
19
|
+
|
|
15
20
|
version = cmdstan_version
|
|
16
21
|
dir = CmdStan.path
|
|
17
22
|
|
|
18
23
|
# no stanc3 binary for Mac ARM
|
|
19
24
|
if RbConfig::CONFIG["host_os"] !~ /darwin/i && RbConfig::CONFIG["host_cpu"] =~ /arm|aarch64/i
|
|
20
|
-
checksum = "
|
|
25
|
+
checksum = "58f0366614120f0f7be56179bb8f89a350af05f037ab5db32f8042fc05b5a587"
|
|
21
26
|
url = "https://github.com/stan-dev/cmdstan/releases/download/v#{version}/cmdstan-#{version}-linux-arm64.tar.gz"
|
|
22
27
|
else
|
|
23
|
-
checksum = "
|
|
28
|
+
checksum = "ffe03c29c9f139d77deeb156a2a0911ebf0742ae38311c739f4fcea3bc4f8909"
|
|
24
29
|
url = "https://github.com/stan-dev/cmdstan/releases/download/v#{version}/cmdstan-#{version}.tar.gz"
|
|
25
30
|
end
|
|
26
31
|
|
|
@@ -36,18 +41,32 @@ module CmdStan
|
|
|
36
41
|
end
|
|
37
42
|
|
|
38
43
|
unless Dir.exist?(dir)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
puts "Downloading..."
|
|
45
|
+
URI.parse(url).open(max_redirects: 10) do |download|
|
|
46
|
+
digest =
|
|
47
|
+
if download.respond_to?(:path)
|
|
48
|
+
download.flush
|
|
49
|
+
Digest::SHA256.file(download.path).hexdigest
|
|
50
|
+
else
|
|
51
|
+
Digest::SHA256.hexdigest(download.string)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
if digest != checksum
|
|
55
|
+
raise Error, "Bad checksum: #{digest}"
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# should never happen
|
|
59
|
+
raise "Expected file" if !download.respond_to?(:path)
|
|
43
60
|
|
|
44
61
|
puts "Unpacking..."
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
62
|
+
Dir.mktmpdir do |tmpdir|
|
|
63
|
+
path = File.join(tmpdir, "cmdstan-#{version}")
|
|
64
|
+
FileUtils.mkdir_p(path)
|
|
65
|
+
tar_args = Gem.win_platform? ? ["--force-local"] : []
|
|
66
|
+
system "tar", "xzf", download.path, "-C", path, "--strip-components=1", *tar_args
|
|
49
67
|
|
|
50
|
-
|
|
68
|
+
FileUtils.mv(path, dir)
|
|
69
|
+
end
|
|
51
70
|
end
|
|
52
71
|
end
|
|
53
72
|
|
|
@@ -67,40 +86,5 @@ module CmdStan
|
|
|
67
86
|
|
|
68
87
|
true
|
|
69
88
|
end
|
|
70
|
-
|
|
71
|
-
private
|
|
72
|
-
|
|
73
|
-
def download_file(url, download_path, checksum, redirects = 0)
|
|
74
|
-
raise Error, "Too many redirects" if redirects > 10
|
|
75
|
-
|
|
76
|
-
uri = URI(url)
|
|
77
|
-
location = nil
|
|
78
|
-
|
|
79
|
-
Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
|
80
|
-
request = Net::HTTP::Get.new(uri)
|
|
81
|
-
http.request(request) do |response|
|
|
82
|
-
case response
|
|
83
|
-
when Net::HTTPRedirection
|
|
84
|
-
location = response["location"]
|
|
85
|
-
when Net::HTTPSuccess
|
|
86
|
-
digest = Digest::SHA2.new
|
|
87
|
-
|
|
88
|
-
File.open(download_path, "wb") do |f|
|
|
89
|
-
response.read_body do |chunk|
|
|
90
|
-
f.write(chunk)
|
|
91
|
-
digest.update(chunk)
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
raise Error, "Bad checksum: #{digest.hexdigest}" if digest.hexdigest != checksum
|
|
96
|
-
else
|
|
97
|
-
raise Error, "Bad response"
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
# outside of Net::HTTP block to close previous connection
|
|
103
|
-
download_file(location, download_path, checksum, redirects + 1) if location
|
|
104
|
-
end
|
|
105
89
|
end
|
|
106
90
|
end
|
data/lib/cmdstan/version.rb
CHANGED
data/lib/cmdstan.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cmdstan
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrew Kane
|
|
@@ -49,14 +49,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
49
49
|
requirements:
|
|
50
50
|
- - ">="
|
|
51
51
|
- !ruby/object:Gem::Version
|
|
52
|
-
version: '3.
|
|
52
|
+
version: '3.3'
|
|
53
53
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
54
54
|
requirements:
|
|
55
55
|
- - ">="
|
|
56
56
|
- !ruby/object:Gem::Version
|
|
57
57
|
version: '0'
|
|
58
58
|
requirements: []
|
|
59
|
-
rubygems_version: 4.0.
|
|
59
|
+
rubygems_version: 4.0.10
|
|
60
60
|
specification_version: 4
|
|
61
61
|
summary: Bayesian inference for Ruby, powered by CmdStan
|
|
62
62
|
test_files: []
|