rapydscript-ng 0.7.24 → 0.8.1

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.
Files changed (132) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +80 -26
  3. package/bin/build.ts +117 -0
  4. package/bin/package.json +1 -0
  5. package/bin/rapydscript +65 -62
  6. package/build_wheels.py +133 -0
  7. package/editor-plugins/README.md +80 -0
  8. package/editor-plugins/nvim.lua +321 -0
  9. package/local-agent.md +28 -0
  10. package/package.json +4 -5
  11. package/publish.py +27 -17
  12. package/release/baselib-plain-pretty.js +448 -326
  13. package/release/baselib-plain-ugly.js +3 -3
  14. package/release/compiler.js +9027 -8139
  15. package/release/signatures.json +27 -27
  16. package/release/stdlib_modules.json +1 -0
  17. package/src/ast.pyj +428 -280
  18. package/src/baselib-builtins.pyj +49 -28
  19. package/src/baselib-containers.pyj +241 -226
  20. package/src/baselib-errors.pyj +8 -1
  21. package/src/baselib-internal.pyj +38 -23
  22. package/src/baselib-itertools.pyj +13 -7
  23. package/src/baselib-str.pyj +59 -84
  24. package/src/compiler.pyj +4 -4
  25. package/src/errors.pyj +3 -4
  26. package/src/lib/aes.pyj +46 -32
  27. package/src/lib/elementmaker.pyj +11 -9
  28. package/src/lib/encodings.pyj +15 -5
  29. package/src/lib/gettext.pyj +9 -4
  30. package/src/lib/math.pyj +106 -45
  31. package/src/lib/operator.pyj +10 -10
  32. package/src/lib/pythonize.pyj +2 -1
  33. package/src/lib/random.pyj +28 -21
  34. package/src/lib/re.pyj +492 -19
  35. package/src/lib/traceback.pyj +171 -29
  36. package/src/lib/uuid.pyj +2 -2
  37. package/src/output/classes.pyj +28 -27
  38. package/src/output/codegen.pyj +87 -83
  39. package/src/output/comments.pyj +8 -8
  40. package/src/output/exceptions.pyj +20 -21
  41. package/src/output/functions.pyj +66 -64
  42. package/src/output/literals.pyj +24 -23
  43. package/src/output/loops.pyj +84 -142
  44. package/src/output/modules.pyj +55 -68
  45. package/src/output/operators.pyj +40 -29
  46. package/src/output/statements.pyj +21 -15
  47. package/src/output/stream.pyj +82 -56
  48. package/src/output/utils.pyj +12 -8
  49. package/src/parse.pyj +971 -620
  50. package/src/string_interpolation.pyj +5 -3
  51. package/src/tokenizer.pyj +188 -148
  52. package/src/utils.pyj +32 -15
  53. package/test/_treeshake_mod.pyj +30 -0
  54. package/test/_treeshake_side_effect.pyj +9 -0
  55. package/test/ast_serialization.pyj +392 -0
  56. package/test/async.pyj +95 -0
  57. package/test/baselib.pyj +1 -2
  58. package/test/embedded_compiler.pyj +57 -0
  59. package/test/fmt.pyj +291 -0
  60. package/test/generic.pyj +16 -3
  61. package/test/imports.pyj +8 -6
  62. package/test/internationalization.pyj +38 -37
  63. package/test/lint.pyj +120 -117
  64. package/test/lsp.pyj +257 -0
  65. package/test/repl.pyj +70 -65
  66. package/test/sourcemaps.pyj +315 -0
  67. package/test/starargs.pyj +46 -39
  68. package/test/str.pyj +8 -0
  69. package/test/traceback.pyj +263 -0
  70. package/test/treeshaking.pyj +181 -0
  71. package/test/web_repl_export.pyj +88 -0
  72. package/tools/ast_serialize.mjs +557 -0
  73. package/tools/cli.mjs +531 -0
  74. package/tools/compile.mjs +205 -0
  75. package/tools/compiler.mjs +159 -0
  76. package/tools/{completer.js → completer.mjs} +6 -6
  77. package/tools/{embedded_compiler.js → embedded_compiler.mjs} +17 -13
  78. package/tools/export.js +109 -56
  79. package/tools/fmt.mjs +975 -0
  80. package/tools/{gettext.js → gettext.mjs} +46 -53
  81. package/tools/ini.mjs +175 -0
  82. package/tools/{lint.js → lint.mjs} +78 -55
  83. package/tools/lsp.mjs +964 -0
  84. package/tools/lsp_protocol.mjs +259 -0
  85. package/tools/lsp_symbols.mjs +418 -0
  86. package/tools/{msgfmt.js → msgfmt.mjs} +18 -18
  87. package/tools/{repl.js → repl.mjs} +56 -42
  88. package/tools/{self.js → self.mjs} +71 -46
  89. package/tools/sourcemap.mjs +123 -0
  90. package/tools/test.mjs +252 -0
  91. package/tools/treeshake.mjs +400 -0
  92. package/tools/{utils.js → utils.mjs} +26 -23
  93. package/tools/{web_repl.js → web_repl.mjs} +15 -13
  94. package/tools/web_repl_export.mjs +97 -0
  95. package/tree-sitter/README.md +101 -0
  96. package/tree-sitter/grammar.js +992 -0
  97. package/tree-sitter/package.json +43 -0
  98. package/tree-sitter/queries/highlights.scm +232 -0
  99. package/tree-sitter/queries/indents.scm +64 -0
  100. package/tree-sitter/queries/injections.scm +14 -0
  101. package/tree-sitter/queries/locals.scm +108 -0
  102. package/tree-sitter/src/grammar.json +4976 -0
  103. package/tree-sitter/src/node-types.json +2901 -0
  104. package/tree-sitter/src/parser.c +196465 -0
  105. package/tree-sitter/src/scanner.c +294 -0
  106. package/tree-sitter/src/tree_sitter/alloc.h +54 -0
  107. package/tree-sitter/src/tree_sitter/array.h +330 -0
  108. package/tree-sitter/src/tree_sitter/parser.h +286 -0
  109. package/tree-sitter/test/corpus/chaining.txt +99 -0
  110. package/tree-sitter/test/corpus/classes.txt +147 -0
  111. package/tree-sitter/test/corpus/comprehensions.txt +155 -0
  112. package/tree-sitter/test/corpus/containers.txt +242 -0
  113. package/tree-sitter/test/corpus/control_flow.txt +361 -0
  114. package/tree-sitter/test/corpus/decorators.txt +64 -0
  115. package/tree-sitter/test/corpus/existential.txt +102 -0
  116. package/tree-sitter/test/corpus/functions.txt +293 -0
  117. package/tree-sitter/test/corpus/imports.txt +117 -0
  118. package/tree-sitter/test/corpus/literals.txt +135 -0
  119. package/tree-sitter/test/corpus/operators.txt +296 -0
  120. package/tree-sitter/test/corpus/statements.txt +189 -0
  121. package/tree-sitter/test/corpus/strings.txt +90 -0
  122. package/tree-sitter/test/corpus/subscripts.txt +227 -0
  123. package/tree-sitter/tree-sitter.json +36 -0
  124. package/web-repl/env.js +35 -23
  125. package/web-repl/main.js +8 -8
  126. package/bin/export +0 -75
  127. package/bin/web-repl-export +0 -102
  128. package/tools/cli.js +0 -523
  129. package/tools/compile.js +0 -184
  130. package/tools/compiler.js +0 -84
  131. package/tools/ini.js +0 -65
  132. package/tools/test.js +0 -110
@@ -0,0 +1,321 @@
1
+ #!/usr/bin/env lua
2
+ --
3
+ -- nvim.lua
4
+ -- Copyright (C) 2026 Kovid Goyal <kovid at kovidgoyal.net>
5
+ --
6
+ -- Distributed under terms of the MIT license.
7
+ --
8
+
9
+ local M = {}
10
+
11
+ local _plugin_root = vim.fn.fnamemodify(
12
+ debug.getinfo(1, "S").source:sub(2), ":p:h"
13
+ )
14
+ local _repo_root = vim.fn.fnamemodify(_plugin_root, ":h")
15
+ local ts_root = _repo_root .. '/tree-sitter'
16
+
17
+ -- _ts_so holds the .so/.dll path once the background build succeeds, nil otherwise.
18
+ local _ts_so = nil
19
+
20
+ -- Tracks the async build lifecycle.
21
+ local _build_state = {
22
+ started = false, -- set when _build_async() is called
23
+ done = false, -- set when the job exits (success or failure)
24
+ waiters = {}, -- callbacks queued while the job is running
25
+ error = nil, -- stderr from a failed build, or a plain error string
26
+ }
27
+
28
+ -- Mark the build finished, optionally record the .so path, and fire any waiters.
29
+ local function _build_finish(success, so, err)
30
+ if success then _ts_so = so end
31
+ _build_state.done = true
32
+ _build_state.error = err or nil
33
+ local ws = _build_state.waiters
34
+ _build_state.waiters = {}
35
+ for _, cb in ipairs(ws) do
36
+ vim.schedule(cb)
37
+ end
38
+ end
39
+
40
+ -- Run cb immediately if the build is already done; otherwise enqueue it.
41
+ local function _when_built(cb)
42
+ if _build_state.done then
43
+ cb()
44
+ else
45
+ table.insert(_build_state.waiters, cb)
46
+ end
47
+ end
48
+
49
+ -- Register the compiled shared library with neovim's tree-sitter runtime.
50
+ -- Returns true on success.
51
+ local function _register_queries()
52
+ local queries_dir = ts_root .. '/queries/'
53
+ vim.treesitter.query.set(
54
+ 'rapydscript', 'highlights', table.concat(vim.fn.readfile(queries_dir .. 'highlights.scm'), "\n"))
55
+ vim.treesitter.query.set(
56
+ 'rapydscript', 'indents', table.concat(vim.fn.readfile(queries_dir .. 'indents.scm'), "\n"))
57
+ vim.treesitter.query.set(
58
+ 'rapydscript', 'injections', table.concat(vim.fn.readfile(queries_dir .. 'injections.scm'), "\n"))
59
+ vim.treesitter.query.set(
60
+ 'rapydscript', 'locals', table.concat(vim.fn.readfile(queries_dir .. 'locals.scm'), "\n"))
61
+ end
62
+
63
+
64
+ local function _load_parser(so)
65
+ vim.treesitter.language.register("rapydscript", "rapydscript")
66
+ local ok, err = pcall(vim.treesitter.language.add, "rapydscript", { path = so })
67
+ if not ok then
68
+ vim.notify("rapydscript: failed to load tree-sitter parser: " .. tostring(err), vim.log.levels.ERROR)
69
+ return false
70
+ end
71
+ _register_queries()
72
+ return true
73
+ end
74
+
75
+ -- Compile the tree-sitter parser in a background job.
76
+ local function _build_async()
77
+ _build_state.started = true
78
+
79
+ local ts_src = ts_root .. "/src"
80
+ local parser_c = ts_src .. "/parser.c"
81
+ local scanner_c = ts_src .. "/scanner.c"
82
+ if vim.fn.filereadable(parser_c) == 0 then
83
+ local msg = "parser.c not found: " .. parser_c
84
+ vim.notify("rapydscript: " .. msg, vim.log.levels.ERROR)
85
+ _build_finish(false, nil, msg)
86
+ return
87
+ end
88
+
89
+ local bin_dir = _plugin_root .. "/bin"
90
+ vim.fn.mkdir(bin_dir, "p")
91
+
92
+ local is_win = vim.fn.has("win32") == 1
93
+ local lib_ext = is_win and ".dll" or ".so"
94
+ local so = bin_dir .. "/rapydscript" .. lib_ext
95
+
96
+ local so_mtime = vim.fn.getftime(so)
97
+ local needs = so_mtime < 0
98
+ or vim.fn.getftime(parser_c) > so_mtime
99
+ or vim.fn.getftime(scanner_c) > so_mtime
100
+
101
+ if not needs then
102
+ -- Already up-to-date; load the existing .so and mark done without spawning a job.
103
+ _build_finish(_load_parser(so), so)
104
+ return
105
+ end
106
+
107
+ local cmd
108
+ if is_win then
109
+ local compiler
110
+ if vim.fn.exepath("cl") ~= "" then
111
+ compiler = "cl"
112
+ elseif vim.fn.exepath("clang-cl") ~= "" then
113
+ compiler = "clang-cl"
114
+ else
115
+ local msg = "tree-sitter syntax highlighting requires cl or clang-cl on PATH"
116
+ vim.notify("rapydscript: " .. msg, vim.log.levels.ERROR)
117
+ _build_finish(false, nil, msg)
118
+ return
119
+ end
120
+ -- /LD = build DLL, /nologo = suppress banner, /O2 = optimize,
121
+ -- /I = include path, /Fe: = output DLL path
122
+ cmd = string.format(
123
+ '"%s" /LD /nologo /O2 /I"%s" /Fe:"%s" "%s" "%s"',
124
+ compiler, ts_src, so, parser_c, scanner_c
125
+ )
126
+ else
127
+ local shared = vim.loop.os_uname().sysname == "Darwin" and "-dynamiclib" or "-shared"
128
+ cmd = { "cc", shared, "-fPIC", "-Os", "-I", ts_src, "-o", so, parser_c, scanner_c }
129
+ end
130
+
131
+ vim.notify("rapydscript: compiling tree-sitter parser…", vim.log.levels.INFO)
132
+
133
+ local stderr_lines = {}
134
+ vim.fn.jobstart(cmd, {
135
+ on_stdout = function(_, _data) end,
136
+ on_stderr = function(_, data)
137
+ if data then vim.list_extend(stderr_lines, data) end
138
+ end,
139
+ on_exit = function(_, code)
140
+ vim.schedule(function()
141
+ if code ~= 0 then
142
+ local stderr = table.concat(stderr_lines, "\n")
143
+ vim.notify(
144
+ "rapydscript: tree-sitter compile failed:\n" .. stderr,
145
+ vim.log.levels.ERROR
146
+ )
147
+ _build_finish(false, nil, stderr)
148
+ return
149
+ end
150
+ _build_finish(_load_parser(so), so, nil)
151
+ end)
152
+ end,
153
+ })
154
+ end
155
+
156
+ local function _start_treesitter(bufnr)
157
+ _when_built(function()
158
+ if not _ts_so then return end
159
+ local ts_ok, ts_err = pcall(vim.treesitter.start, bufnr, "rapydscript")
160
+ if not ts_ok then
161
+ vim.notify("rapydscript: tree-sitter start failed: " .. tostring(ts_err), vim.log.levels.ERROR)
162
+ end
163
+ end)
164
+ end
165
+
166
+ -- Populates M._binary_info as a side-effect.
167
+ local function _default_lsp_cmd()
168
+ local repo_bin = _repo_root .. "/bin/rapydscript"
169
+ M._binary_info.repo = { path = repo_bin }
170
+ if vim.fn.has("win32") == 1 then
171
+ -- On Windows the shebang is not honoured; invoke via node explicitly.
172
+ return { "node", repo_bin, "lsp" }
173
+ end
174
+ return { repo_bin, "lsp" }
175
+ end
176
+
177
+ -- Expose tree-sitter compilation result for checkhealth.
178
+ -- Blocks up to 30 s if the background build is still running.
179
+ M._tree_sitter_path = function()
180
+ if _build_state.started and not _build_state.done then
181
+ vim.wait(30000, function() return _build_state.done end, 50)
182
+ end
183
+ return _ts_so
184
+ end
185
+
186
+ -- Expose the build error (if any) for checkhealth.
187
+ -- Must be called after _tree_sitter_path() so the build is already settled.
188
+ M._tree_sitter_error = function()
189
+ return _build_state.error
190
+ end
191
+
192
+ -- Populated by _default_lsp_cmd() below; read by lua/rapydscript/health.lua.
193
+ M._binary_info = { system = nil, repo = nil }
194
+
195
+ -- Expand glob patterns relative to root, keep only dirs that contain .pyj files,
196
+ -- and return them colon-separated. Returns nil when nothing matches.
197
+ local function _resolve_import_paths(root, patterns)
198
+ local seen = {}
199
+ local dirs = {}
200
+ for _, pat in ipairs(patterns) do
201
+ local matches = vim.fn.glob(root .. "/" .. pat, false, true)
202
+ for _, path in ipairs(matches) do
203
+ local norm = vim.fn.fnamemodify(path, ":p"):gsub("/$", "")
204
+ if not seen[norm] and vim.fn.isdirectory(norm) == 1 then
205
+ if #vim.fn.glob(norm .. "/*.pyj", false, true) > 0 then
206
+ seen[norm] = true
207
+ dirs[#dirs + 1] = norm
208
+ end
209
+ end
210
+ end
211
+ end
212
+ return #dirs > 0 and table.concat(dirs, ":") or nil
213
+ end
214
+
215
+ M.defaults = {
216
+ cmd = _default_lsp_cmd(),
217
+ -- Glob patterns relative to the project root; matching dirs that contain
218
+ -- .pyj files are passed automatically as --import-path to the LSP server.
219
+ import_path_patterns = { ".", "src", "src/pyj" },
220
+ line_length = nil,
221
+ preferred_quote = nil,
222
+ filetypes = { "rapydscript" },
223
+ root_markers = { ".git", "package.json", "rapydscript.json" },
224
+ }
225
+
226
+ -- Current runtime settings, kept in sync whenever update_settings() is called.
227
+ M._settings = {}
228
+
229
+ local function build_cmd(opts, import_path)
230
+ local cmd = vim.deepcopy(opts.cmd)
231
+ if import_path then
232
+ vim.list_extend(cmd, { "--import-path", import_path })
233
+ end
234
+ if opts.line_length then
235
+ vim.list_extend(cmd, { "--line-length", tostring(opts.line_length) })
236
+ end
237
+ if opts.preferred_quote then
238
+ vim.list_extend(cmd, { "--preferred-quote", opts.preferred_quote })
239
+ end
240
+ if opts.join_lines then
241
+ vim.list_extend(cmd, { "--join-lines" })
242
+ end
243
+ return cmd
244
+ end
245
+
246
+ local function make_capabilities()
247
+ local caps = vim.lsp.protocol.make_client_capabilities()
248
+ -- Tell the server we support dynamic registration for workspace/didChangeConfiguration
249
+ -- so it will register that notification and accept live setting updates.
250
+ caps.workspace = caps.workspace or {}
251
+ caps.workspace.didChangeConfiguration = { dynamicRegistration = true }
252
+ return caps
253
+ end
254
+
255
+ -- Send workspace/didChangeConfiguration to every active rapydscript client.
256
+ -- `new_settings` is a table with any subset of:
257
+ -- line_length (number)
258
+ -- preferred_quote (string) -- "single" | "double"
259
+ function M.update_settings(new_settings)
260
+ new_settings = new_settings or {}
261
+
262
+ -- Merge into the module-level settings table.
263
+ if new_settings.line_length ~= nil then
264
+ M._settings.lineLength = new_settings.line_length
265
+ end
266
+ if new_settings.preferred_quote ~= nil then
267
+ M._settings.preferredQuote = new_settings.preferred_quote
268
+ end
269
+ if new_settings.join_lines ~= nil then
270
+ M._settings.joinLines = new_settings.join_lines
271
+ end
272
+
273
+ local clients = vim.lsp.get_clients({ name = "rapydscript" })
274
+ if #clients == 0 then
275
+ vim.notify("rapydscript: no active LSP client found", vim.log.levels.WARN)
276
+ return
277
+ end
278
+ for _, client in ipairs(clients) do
279
+ client:notify("workspace/didChangeConfiguration", {
280
+ settings = { rapydscript = M._settings },
281
+ })
282
+ end
283
+ end
284
+
285
+ function M.setup(opts)
286
+ vim.filetype.add({ extension = { pyj = 'rapydscript' } })
287
+ opts = vim.tbl_deep_extend("force", M.defaults, opts or {})
288
+ M._active_opts = opts
289
+
290
+ -- Seed the runtime settings table from the initial opts so that partial
291
+ -- update_settings() calls later always send the full current state.
292
+ M._settings = {
293
+ lineLength = opts.line_length,
294
+ preferredQuote = opts.preferred_quote,
295
+ joinLines = opts.join_lines,
296
+ }
297
+ _build_async()
298
+
299
+ vim.api.nvim_create_autocmd("FileType", {
300
+ pattern = opts.filetypes,
301
+ callback = function(ev)
302
+ vim.bo[ev.buf].syntax = "off" -- use treesitter for syntax highlighting
303
+ _start_treesitter(ev.buf)
304
+ local root = vim.fs.root(ev.buf, opts.root_markers)
305
+ local import_path = root
306
+ and _resolve_import_paths(root, opts.import_path_patterns)
307
+ or nil
308
+ vim.lsp.start({
309
+ name = "rapydscript",
310
+ cmd = build_cmd(opts, import_path),
311
+ root_dir = root or vim.fn.getcwd(),
312
+ capabilities = make_capabilities(),
313
+ settings = {
314
+ rapydscript = M._settings,
315
+ },
316
+ })
317
+ end,
318
+ })
319
+ end
320
+
321
+ return M
package/local-agent.md ADDED
@@ -0,0 +1,28 @@
1
+ initialize_command: bin/rapydscript self --complete
2
+ copy_resource: node_modules
3
+ copy_resource: dev
4
+ prepend_to_path: bin
5
+
6
+ # System Instructions & Project Context
7
+
8
+ ## Rules for Code Generation
9
+ - **Error Handling**: Implement explicit error handling. Avoid silent failures or empty catch blocks.
10
+ - **Dependency Minimization**: Use existing project utilities and native standard libraries before suggesting new external packages.
11
+ - **Local Context**: Search the codebase for existing patterns before writing boilerplate structure from scratch.
12
+
13
+ ## Project Execution Workflows
14
+
15
+ You both build and run the test suite by simply executing:
16
+
17
+ ./build
18
+
19
+ The newly built tools are placed in the bin directory.
20
+
21
+ The test suite runs very fast so dont bother trying to run specific tests, just
22
+ run the entire suite.
23
+
24
+ ## Verification Pipeline
25
+
26
+ Before declaring a task complete, you must follow this exact verification lifecycle:
27
+ 1. Run the local **Build and Test Command** to guarantee zero compilation or compilation-stage errors and no test failures
28
+ 2. If errors occur, analyze the stdout logs completely before writing a fix. Do not guess.
package/package.json CHANGED
@@ -8,16 +8,16 @@
8
8
  "language",
9
9
  "compiler"
10
10
  ],
11
- "main": "tools/compiler.js",
11
+ "main": "tools/compiler.mjs",
12
12
  "scripts": {
13
13
  "test": "node bin/rapydscript self --complete --test",
14
14
  "start": "node bin/rapydscript",
15
15
  "build-self": "node bin/rapydscript self --complete"
16
16
  },
17
- "version": "0.7.24",
17
+ "version": "0.8.1",
18
18
  "license": "BSD-2-Clause",
19
19
  "engines": {
20
- "node": ">=0.12.0"
20
+ "node": ">=0.14.0"
21
21
  },
22
22
  "maintainers": [
23
23
  {
@@ -30,8 +30,7 @@
30
30
  "url": "https://github.com/kovidgoyal/rapydscript-ng.git"
31
31
  },
32
32
  "dependencies": {
33
- "regenerator": ">= 0.12.1",
34
- "uglify-js": ">= 3.0.15"
33
+ "terser": ">=5.49.0"
35
34
  },
36
35
  "optionalDependencies": {
37
36
  "v8-profiler": ">= 5.2.9"
package/publish.py CHANGED
@@ -2,36 +2,46 @@
2
2
  # vim:fileencoding=utf-8
3
3
  # License: BSD Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
4
4
 
5
+ import glob
5
6
  import subprocess
6
7
  import os
7
8
  import shutil
8
9
  import json
10
+ import runpy
9
11
 
10
12
  # Load metadata
11
13
  base = os.path.dirname(os.path.abspath(__file__))
12
- subprocess.check_call([os.path.join(base, 'build')])
13
- with open('package.json', 'rb') as f:
14
- m = json.load(f)
15
- version = m['version']
14
+ with open("package.json", "rb") as f:
15
+ metadata = json.load(f)
16
+ version = metadata["version"]
17
+
18
+ subprocess.check_call([os.path.join(base, "build")])
19
+ runpy.run_path(os.path.join(base, "build_wheels.py"))["main"]()
16
20
 
17
21
  # Update the files in release/ from dev/
18
- shutil.rmtree(os.path.join(base, 'release'))
19
- shutil.copytree(os.path.join(base, 'dev'), os.path.join(base, 'release'))
20
- subprocess.check_call(['git', 'add', os.path.join(base, 'release')])
22
+ shutil.rmtree(os.path.join(base, "release"))
23
+ shutil.copytree(os.path.join(base, "dev"), os.path.join(base, "release"))
24
+ subprocess.check_call(["git", "add", os.path.join(base, "release")])
21
25
  if subprocess.check_output(
22
- 'git status --porcelain --untracked-files release'.split()).strip():
23
- subprocess.check_call([
24
- 'git', 'commit', '-m', 'Updating release build of compiler'])
25
- subprocess.check_call('git push'.split())
26
+ "git status --porcelain --untracked-files release".split()
27
+ ).strip():
28
+ subprocess.check_call(["git", "commit", "-m", "Updating release build of compiler"])
29
+ subprocess.check_call("git push".split())
26
30
 
27
31
  # Tag the release
28
- subprocess.check_call('git tag -s v{0} -m version-{0}'.format(version).split())
29
- subprocess.check_call(['git', 'push', 'origin', 'v'+version])
32
+ subprocess.check_call("git tag -s v{0} -m version-{0}".format(version).split())
33
+ subprocess.check_call(["git", "push", "origin", "v" + version])
30
34
 
31
35
  # Update the web REPL
32
- gh_pages = os.path.join(os.path.dirname(base), 'kovidgoyal.github.io')
33
- subprocess.check_call([os.path.join(gh_pages, 'update-rapyd-repl.py')])
36
+ gh_pages = os.path.join(os.path.dirname(base), "kovidgoyal.github.io")
37
+ subprocess.check_call([os.path.join(gh_pages, "update-rapyd-repl.py")])
38
+
39
+ # Publish to PyPI
40
+ subprocess.check_call(
41
+ ["twine", "upload", "--config-file", os.path.join(os.environ["PENV"], "pypi")]
42
+ + glob.glob("dist/*.whl")
43
+ )
34
44
 
35
45
  # Publish to NPM
36
- subprocess.check_call(['npm', 'login'])
37
- subprocess.check_call(['npm', 'publish', base])
46
+ subprocess.check_call(["npm", "login"])
47
+ subprocess.check_call(["npm", "publish", base])