squared 0.4.18 → 0.5.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 +62 -242
- data/README.md +1280 -647
- data/README.ruby.md +722 -0
- data/lib/squared/common/base.rb +8 -9
- data/lib/squared/common/format.rb +6 -14
- data/lib/squared/common/prompt.rb +38 -42
- data/lib/squared/common/shell.rb +10 -10
- data/lib/squared/common/system.rb +31 -35
- data/lib/squared/common/utils.rb +3 -28
- data/lib/squared/common.rb +2 -1
- data/lib/squared/config.rb +19 -19
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +55 -89
- data/lib/squared/workspace/project/base.rb +258 -399
- data/lib/squared/workspace/project/docker.rb +106 -120
- data/lib/squared/workspace/project/git.rb +330 -467
- data/lib/squared/workspace/project/node.rb +96 -141
- data/lib/squared/workspace/project/python.rb +73 -299
- data/lib/squared/workspace/project/ruby.rb +158 -237
- data/lib/squared/workspace/project/support/class.rb +81 -134
- data/lib/squared/workspace/project.rb +0 -10
- data/lib/squared/workspace/repo.rb +51 -79
- data/lib/squared/workspace/series.rb +16 -16
- data/lib/squared/workspace/support/data.rb +3 -2
- data/lib/squared/workspace/support.rb +0 -1
- data/lib/squared/workspace.rb +1 -1
- data/squared.gemspec +5 -5
- metadata +7 -8
- data/lib/squared/common/class.rb +0 -110
- data/lib/squared/workspace/support/base.rb +0 -17
@@ -8,7 +8,7 @@ module Squared
|
|
8
8
|
DIR_PYTHON = (DEP_PYTHON + %w[README.rst]).freeze
|
9
9
|
OPT_PYTHON = {
|
10
10
|
common: %w[b B d E h i I O OO P q s S u v x c=q m=b W=b X=q check-hash-based-pycs=b].freeze,
|
11
|
-
build: %w[n|no-isolation s|sdist x|skip-dependency-check
|
11
|
+
build: %w[n|no-isolation s|sdist v|verbose w|wheel x|skip-dependency-check C|config-setting=q installer=b
|
12
12
|
o|outdir=p].freeze,
|
13
13
|
venv: %w[clear copies symlinks system-site-packages upgrade upgrade-deps without-scm-ignore-files without-pip
|
14
14
|
prompt=q].freeze
|
@@ -28,18 +28,11 @@ module Squared
|
|
28
28
|
freeze: %w[all exclude-editable l|local user exclude=b path=p r|requirement=p].freeze
|
29
29
|
}.freeze
|
30
30
|
OPT_POETRY = {
|
31
|
-
common: %w[ansi no-ansi no-cache n|no-interaction no-plugins q|quiet v|verbose
|
31
|
+
common: %w[ansi no-ansi no-cache n|no-interaction no-plugins P|project=p q|quiet v|verbose].freeze,
|
32
32
|
build: %w[clean config-settings=qq f|format=b o|output=p].freeze,
|
33
|
-
publish: %w[build dry-run
|
33
|
+
publish: %w[build dry-run client-cert=p cert=p dist-dir=p p|password=b r|repository=b skip-existing
|
34
34
|
u|username=b].freeze
|
35
35
|
}.freeze
|
36
|
-
OPT_PDM = {
|
37
|
-
common: %w[I|ignore-python no-cache n|non-interactive].freeze,
|
38
|
-
build: %w[C=bm no-clean no-isolation no-sdist no-wheel quiet verbose config-setting=q d|dest=p p|project=p
|
39
|
-
k|skip=b].freeze,
|
40
|
-
publish: %w[no-build no-very-ssl quiet S|sign skip-existing verbose ca-certs=p c|comment=q d|dest=p identity=b
|
41
|
-
p|password=q p|project=p r|repository=q k|skip=b u|username=b].freeze
|
42
|
-
}.freeze
|
43
36
|
OPT_HATCH = {
|
44
37
|
common: %w[color interactive no-color no-interactive cache-dir=p config=p data-dir=p e|env=b p|project=b
|
45
38
|
q|quiet v|verbose].freeze,
|
@@ -48,11 +41,11 @@ module Squared
|
|
48
41
|
p|publisher=b r|repo=b u|user=q].freeze
|
49
42
|
}.freeze
|
50
43
|
OPT_TWINE = {
|
51
|
-
publish: %w[attestations disable-progress-bar non-interactive
|
52
|
-
|
44
|
+
publish: %w[attestations disable-progress-bar non-interactive skip-existing verbose s|sign c|comment=q
|
45
|
+
config-file=p cert=p client-cert=p i|identity=b p|password=q r|repository=b repository-url=q
|
53
46
|
sign-with=b u|username=q].freeze
|
54
47
|
}.freeze
|
55
|
-
private_constant :DEP_PYTHON, :DIR_PYTHON, :OPT_PYTHON, :OPT_PIP, :OPT_POETRY, :
|
48
|
+
private_constant :DEP_PYTHON, :DIR_PYTHON, :OPT_PYTHON, :OPT_PIP, :OPT_POETRY, :OPT_HATCH, :OPT_TWINE
|
56
49
|
|
57
50
|
class << self
|
58
51
|
def populate(*); end
|
@@ -78,7 +71,7 @@ module Squared
|
|
78
71
|
|
79
72
|
attr_reader :venv, :editable
|
80
73
|
|
81
|
-
def initialize(*, editable: '.', verbose: nil, **kwargs)
|
74
|
+
def initialize(*, venv: nil, editable: '.', verbose: nil, **kwargs)
|
82
75
|
super
|
83
76
|
if @pass.include?(Python.ref)
|
84
77
|
initialize_ref Python.ref
|
@@ -88,100 +81,34 @@ module Squared
|
|
88
81
|
initialize_env(**kwargs)
|
89
82
|
end
|
90
83
|
dependfile_set DEP_PYTHON
|
84
|
+
@verbose = verbose.size if verbose.is_a?(String) && verbose.match?(/\Av+\z/)
|
91
85
|
editable_set editable
|
92
|
-
venv_set
|
86
|
+
venv_set venv if venv
|
93
87
|
end
|
94
88
|
|
95
89
|
subtasks({
|
96
90
|
'venv' => %i[exec create remove show].freeze,
|
97
|
-
'pip' => %i[
|
91
|
+
'pip' => %i[uninstall freeze].freeze,
|
98
92
|
'install' => %i[user force upgrade target editable].freeze,
|
99
|
-
'
|
100
|
-
'
|
101
|
-
'publish' => %i[poetry pdm hatch twine].freeze,
|
102
|
-
'run' => nil,
|
93
|
+
'build' => %i[python poetry hatch].freeze,
|
94
|
+
'publish' => %i[poetry twine hatch].freeze,
|
103
95
|
'exec' => nil
|
104
96
|
})
|
105
97
|
|
106
|
-
def verbose=(val)
|
107
|
-
case val
|
108
|
-
when /\Av+\z/
|
109
|
-
@verbose = val.size
|
110
|
-
else
|
111
|
-
super
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
98
|
def ref
|
116
99
|
Python.ref
|
117
100
|
end
|
118
101
|
|
119
102
|
def populate(*, **)
|
120
103
|
super
|
121
|
-
return unless
|
104
|
+
return unless outdated? && ref?(Python.ref)
|
122
105
|
|
123
106
|
namespace name do
|
124
107
|
Python.subtasks do |action, flags|
|
125
|
-
next if
|
108
|
+
next if @pass.include?(action)
|
126
109
|
|
127
110
|
if flags.nil?
|
128
111
|
case action
|
129
|
-
when 'run'
|
130
|
-
next unless pyprojectfile
|
131
|
-
|
132
|
-
format_desc action, nil, "script+|#{indexchar}index+|#,pattern*"
|
133
|
-
task action, [:command] do |_, args|
|
134
|
-
found = 0
|
135
|
-
%w[tool.poetry.scripts tool.pdm.scripts project.scripts].each_with_index do |table, index|
|
136
|
-
next if (list = read_pyproject(table)).empty?
|
137
|
-
|
138
|
-
if args.command == '#'
|
139
|
-
format_list(list, "run[#{indexchar}N]", 'scripts', grep: args.extras, from: pyprojectfile)
|
140
|
-
found |= 1
|
141
|
-
else
|
142
|
-
args.to_a.each do |val|
|
143
|
-
if (n, = indexitem(val))
|
144
|
-
if (script, = list[n - 1])
|
145
|
-
case index
|
146
|
-
when 0
|
147
|
-
script = session_output 'poetry', 'run', script
|
148
|
-
when 1
|
149
|
-
script = pdm_session 'run', script
|
150
|
-
else
|
151
|
-
venv_init
|
152
|
-
end
|
153
|
-
found |= 1
|
154
|
-
run(script, from: :run)
|
155
|
-
elsif exception
|
156
|
-
indexerror n, list
|
157
|
-
else
|
158
|
-
found |= 2
|
159
|
-
log.warn "run script #{n} of #{list.size} (out of range)"
|
160
|
-
end
|
161
|
-
else
|
162
|
-
case index
|
163
|
-
when 0
|
164
|
-
found |= 1
|
165
|
-
run(session_output('poetry', 'run', val), from: :run)
|
166
|
-
when 1
|
167
|
-
found |= 1
|
168
|
-
run(pdm_session('run', val), from: :run)
|
169
|
-
else
|
170
|
-
raise_error "script: #{val}" if exception
|
171
|
-
found |= 2
|
172
|
-
log.warn "run script \"#{val}\" (not indexed)"
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|
176
|
-
end
|
177
|
-
break
|
178
|
-
end
|
179
|
-
unless found.anybits?(1)
|
180
|
-
puts log_message(found == 0 ? Logger::INFO : Logger.WARN,
|
181
|
-
"no scripts #{found == 0 ? 'found' : 'executed'}",
|
182
|
-
subject: name, hint: pyprojectfile)
|
183
|
-
end
|
184
|
-
end
|
185
112
|
when 'exec'
|
186
113
|
format_desc action, nil, 'command|:,args*'
|
187
114
|
task action do |_, args|
|
@@ -191,12 +118,12 @@ module Squared
|
|
191
118
|
elsif i || args.empty?
|
192
119
|
readline('Enter command', force: true)
|
193
120
|
else
|
194
|
-
if (val = command_args(args,
|
121
|
+
if (val = command_args(args, prefix: 'python'))
|
195
122
|
args << val
|
196
123
|
end
|
197
124
|
args.join(' ')
|
198
125
|
end
|
199
|
-
|
126
|
+
Kernel.exec(cmd, chdir: path)
|
200
127
|
end
|
201
128
|
end
|
202
129
|
else
|
@@ -242,14 +169,6 @@ module Squared
|
|
242
169
|
end
|
243
170
|
when 'pip'
|
244
171
|
case flag
|
245
|
-
when :upgrade
|
246
|
-
format_desc action, flag, 'opts*'
|
247
|
-
task flag do |_, args|
|
248
|
-
args = args.to_a
|
249
|
-
args.unshift('upgrade')
|
250
|
-
args << 'pip'
|
251
|
-
install flag, args
|
252
|
-
end
|
253
172
|
when :freeze
|
254
173
|
format_desc action, flag, "file?=#{DEP_PYTHON[4]},opts*"
|
255
174
|
task flag do |_, args|
|
@@ -295,30 +214,14 @@ module Squared
|
|
295
214
|
depend flag, args.to_a
|
296
215
|
end
|
297
216
|
end
|
298
|
-
when 'outdated'
|
299
|
-
format_desc action, flag, 'eager?,user?'
|
300
|
-
task flag do |_, args|
|
301
|
-
outdated flag, args.to_a
|
302
|
-
end
|
303
217
|
when 'build'
|
304
|
-
case flag
|
305
|
-
when :poetry
|
306
|
-
next unless poetry?
|
307
|
-
when :pdm
|
308
|
-
next unless build_backend == 'pdm.backend'
|
309
|
-
when :hatch
|
310
|
-
next unless build_backend == 'hatchling.build'
|
311
|
-
end
|
312
218
|
format_desc(action, flag, 'opts*', after: case flag
|
313
219
|
when :python then 'srcdir?'
|
314
|
-
when :poetry then 'output?'
|
315
|
-
when :pdm then 'dest?'
|
316
220
|
when :hatch then 'location?'
|
317
221
|
end)
|
318
222
|
task flag do |_, args|
|
319
223
|
build! flag, args.to_a
|
320
224
|
end
|
321
|
-
break unless flag == :python
|
322
225
|
when 'publish'
|
323
226
|
format_desc(action, flag, 'opts*', after: case flag
|
324
227
|
when :hatch then 'artifacts?'
|
@@ -341,8 +244,8 @@ module Squared
|
|
341
244
|
elsif outdated?
|
342
245
|
venv_init
|
343
246
|
workspace.rev_clear(name, sync: sync)
|
344
|
-
if !flag &&
|
345
|
-
cmd = poetry_session 'install -n'
|
247
|
+
if !flag && dependtype == 1
|
248
|
+
cmd = poetry_session 'install', '-n'
|
346
249
|
cmd << '--no-root' if option('no-root')
|
347
250
|
else
|
348
251
|
cmd = pip_session 'install'
|
@@ -366,8 +269,8 @@ module Squared
|
|
366
269
|
end
|
367
270
|
end
|
368
271
|
|
369
|
-
def outdated(
|
370
|
-
cmd = pip_session 'list --outdated'
|
272
|
+
def outdated(*, sync: invoked_sync?('outdated'))
|
273
|
+
cmd = pip_session 'list', '--outdated'
|
371
274
|
append_global
|
372
275
|
cmd = session_done cmd
|
373
276
|
log.info cmd
|
@@ -376,39 +279,28 @@ module Squared
|
|
376
279
|
print_item banner if sync
|
377
280
|
start = 0
|
378
281
|
found = 0
|
379
|
-
major =
|
380
|
-
minor = []
|
381
|
-
patch = []
|
282
|
+
major = 0
|
382
283
|
pwd_set(from: :outdated) do
|
383
284
|
buffer = []
|
384
285
|
out = ->(val) { sync ? puts(val) : buffer << val }
|
385
|
-
|
386
|
-
|
387
|
-
else
|
388
|
-
IO.popen(runenv || {}, cmd)
|
389
|
-
end.each do |line|
|
390
|
-
next if line.match?(/^[ -]+$/)
|
286
|
+
IO.popen(runenv || {}, cmd).each do |line|
|
287
|
+
next if line.match?(/^[\s-]+$/)
|
391
288
|
|
392
289
|
if start > 0
|
393
290
|
unless stdin?
|
394
|
-
|
395
|
-
next unless cur && lat
|
291
|
+
data = line.scan(SEM_VER)
|
292
|
+
next unless (cur = data.shift) && (lat = data.shift)
|
396
293
|
|
397
294
|
latest = lat.join
|
398
295
|
current = cur.join
|
399
296
|
semver cur
|
400
297
|
semver lat
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
0
|
408
|
-
else
|
409
|
-
minor << name
|
410
|
-
1
|
411
|
-
end
|
298
|
+
if semmajor?(cur, lat)
|
299
|
+
type = 2
|
300
|
+
major += 1
|
301
|
+
else
|
302
|
+
type = cur[2] == lat[2] ? 0 : 1
|
303
|
+
end
|
412
304
|
if type == 0
|
413
305
|
styles = color(:yellow)
|
414
306
|
else
|
@@ -442,18 +334,7 @@ module Squared
|
|
442
334
|
puts buffer
|
443
335
|
end
|
444
336
|
if found > 0
|
445
|
-
|
446
|
-
pkg = case flag
|
447
|
-
when :major
|
448
|
-
major + minor + patch
|
449
|
-
when :minor
|
450
|
-
minor + patch
|
451
|
-
when :patch
|
452
|
-
patch
|
453
|
-
end
|
454
|
-
unless !pkg || pkg.empty?
|
455
|
-
install(:upgrade, pkg, strategy: opts.include?('eager') ? 'eager' : nil, user: opts.include?('user'))
|
456
|
-
end
|
337
|
+
puts print_footer empty_status('Updates are available', 'major', major)
|
457
338
|
elsif start == 0
|
458
339
|
puts 'No updates were found'
|
459
340
|
end
|
@@ -461,7 +342,7 @@ module Squared
|
|
461
342
|
on :last, :outdated
|
462
343
|
end
|
463
344
|
|
464
|
-
def install(flag, opts = [], strategy: nil
|
345
|
+
def install(flag, opts = [], strategy: nil)
|
465
346
|
cmd = pip_session 'install'
|
466
347
|
out = append_pip(flag, opts, from: :install)
|
467
348
|
case flag
|
@@ -471,14 +352,8 @@ module Squared
|
|
471
352
|
when :upgrade
|
472
353
|
raise_error('no packages listed', hint: flag) if out.empty?
|
473
354
|
cmd << '--upgrade'
|
474
|
-
cmd << '--user' if user
|
475
355
|
cmd << basic_option('upgrade-strategy', strategy) if strategy
|
476
356
|
append_value out
|
477
|
-
if workspace.windows?
|
478
|
-
pip = cmd.to_a.drop(1)
|
479
|
-
cmd = python_session '-m pip'
|
480
|
-
cmd.merge(pip)
|
481
|
-
end
|
482
357
|
end
|
483
358
|
run(from: :install)
|
484
359
|
end
|
@@ -491,9 +366,6 @@ module Squared
|
|
491
366
|
when :poetry
|
492
367
|
cmd = poetry_session 'build'
|
493
368
|
list = OPT_POETRY[:build] + OPT_POETRY[:common]
|
494
|
-
when :pdm
|
495
|
-
cmd, opts = pdm_session('build', opts: opts)
|
496
|
-
list = OPT_PDM[:build]
|
497
369
|
when :hatch
|
498
370
|
cmd, opts = hatch_session('build', opts: opts)
|
499
371
|
list = OPT_HATCH[:build]
|
@@ -501,7 +373,7 @@ module Squared
|
|
501
373
|
srcdir = nil
|
502
374
|
op = OptionPartition.new(opts, list, cmd, project: self, single: singleopt(flag))
|
503
375
|
op.each do |opt|
|
504
|
-
if !srcdir && basepath(opt
|
376
|
+
if !srcdir && basepath(opt).exist? && projectpath?(opt)
|
505
377
|
srcdir = opt
|
506
378
|
else
|
507
379
|
op.found << opt
|
@@ -509,13 +381,12 @@ module Squared
|
|
509
381
|
end
|
510
382
|
op.swap
|
511
383
|
case flag
|
512
|
-
when :poetry
|
384
|
+
when :poetry
|
513
385
|
if srcdir
|
514
|
-
|
515
|
-
|
516
|
-
op.push(srcdir)
|
386
|
+
if op.arg?('o', 'output')
|
387
|
+
op.extras << srcdir
|
517
388
|
else
|
518
|
-
op << quote_option(
|
389
|
+
op << quote_option('output', path + srcdir)
|
519
390
|
end
|
520
391
|
srcdir = nil
|
521
392
|
end
|
@@ -527,7 +398,7 @@ module Squared
|
|
527
398
|
end
|
528
399
|
op << basic_option('p', project) unless ENV['HATCH_PROJECT'] || op.arg?('p', 'project')
|
529
400
|
end
|
530
|
-
op
|
401
|
+
op << shell_quote(path + srcdir) if srcdir
|
531
402
|
op.clear
|
532
403
|
run(from: :"#{flag}:build")
|
533
404
|
end
|
@@ -537,35 +408,21 @@ module Squared
|
|
537
408
|
when :poetry
|
538
409
|
poetry_session 'publish'
|
539
410
|
list = OPT_POETRY[:publish] + OPT_POETRY[:common]
|
540
|
-
when :pdm
|
541
|
-
opts = pdm_session('publish', opts: opts).last
|
542
|
-
list = OPT_PDM[:publish]
|
543
|
-
when :hatch
|
544
|
-
opts = hatch_session('publish', opts: opts).last
|
545
|
-
list = OPT_HATCH[:publish]
|
546
411
|
when :twine
|
547
412
|
session 'twine', 'upload'
|
548
413
|
list = OPT_TWINE[:publish]
|
414
|
+
when :hatch
|
415
|
+
opts = hatch_session('publish', opts: opts).last
|
416
|
+
list = OPT_HATCH[:publish]
|
549
417
|
end
|
550
418
|
op = OptionPartition.new(opts, list, @session, project: self, single: singleopt(flag))
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
419
|
+
if op.empty?
|
420
|
+
dist = path + 'dist'
|
421
|
+
raise_error('no source files found', hint: dist) unless dist.directory? && !dist.empty?
|
422
|
+
op.extras << "#{dist}/*" unless flag == :poetry
|
555
423
|
end
|
556
|
-
|
557
|
-
|
558
|
-
if op.empty?
|
559
|
-
op.push("#{dist.call}/*")
|
560
|
-
else
|
561
|
-
op.map! { |val| path + val }
|
562
|
-
end
|
563
|
-
op.append
|
564
|
-
else
|
565
|
-
dist.call unless op.arg?(*(flag == :poetry ? ['dist-dir'] : ['d', 'dest']))
|
566
|
-
op.clear(pass: false)
|
567
|
-
end
|
568
|
-
run(from: :"#{flag}:publish", interactive: "Publish #{sub_style(project, styles: theme[:active])}")
|
424
|
+
op.append
|
425
|
+
run(from: :"#{flag}:publish")
|
569
426
|
end
|
570
427
|
|
571
428
|
def pip(flag, opts = [])
|
@@ -573,7 +430,7 @@ module Squared
|
|
573
430
|
out = append_pip(nil, opts, from: flag)
|
574
431
|
case flag
|
575
432
|
when :uninstall
|
576
|
-
raise_error('no packages listed', hint:
|
433
|
+
raise_error('no packages listed', hint: 'uninstall') if out.empty?
|
577
434
|
cmd.merge(out)
|
578
435
|
when :freeze
|
579
436
|
venv_init
|
@@ -585,7 +442,13 @@ module Squared
|
|
585
442
|
ret
|
586
443
|
end
|
587
444
|
|
588
|
-
def variable_set(key, *val,
|
445
|
+
def variable_set(key, *val, **, &blk)
|
446
|
+
if block_given?
|
447
|
+
case key
|
448
|
+
when :dependfile, :venv, :editable
|
449
|
+
val = block_args val, &blk
|
450
|
+
end
|
451
|
+
end
|
589
452
|
case key
|
590
453
|
when :dependfile
|
591
454
|
req = basepath(*val)
|
@@ -628,25 +491,15 @@ module Squared
|
|
628
491
|
|
629
492
|
def poetry_session(*cmd)
|
630
493
|
ret = session('poetry', *cmd, *preopts)
|
631
|
-
|
632
|
-
ret << quote_option('project', path + val)
|
633
|
-
end
|
494
|
+
option('project', ignore: false) { |val| ret << quote_option('project', path + val) }
|
634
495
|
ret
|
635
496
|
end
|
636
497
|
|
637
|
-
def pdm_session(*cmd, opts: nil)
|
638
|
-
create_session(*cmd, name: 'pdm', common: OPT_PDM[:common], opts: opts)
|
639
|
-
end
|
640
|
-
|
641
498
|
def hatch_session(*cmd, opts: nil)
|
642
|
-
|
643
|
-
end
|
644
|
-
|
645
|
-
def create_session(*cmd, name:, common:, opts: nil)
|
646
|
-
return session(name, *preopts, *cmd, path: venv.nil?) unless opts
|
499
|
+
return session('hatch', *preopts, *cmd, path: venv.nil?) unless opts
|
647
500
|
|
648
|
-
op = OptionPartition.new(opts, common, project: self, single: singleopt)
|
649
|
-
ret = session(
|
501
|
+
op = OptionPartition.new(opts, OPT_HATCH[:common], project: self, single: singleopt)
|
502
|
+
ret = session('hatch', *op.to_a, *cmd, path: venv.nil?)
|
650
503
|
[ret, op.extras]
|
651
504
|
end
|
652
505
|
|
@@ -674,9 +527,9 @@ module Squared
|
|
674
527
|
end
|
675
528
|
op.swap
|
676
529
|
if edit
|
677
|
-
edit = path + edit unless %r{
|
530
|
+
edit = path + edit unless %r{^[a-z]+(?:\+[a-z]+)?://}i.match?(edit)
|
678
531
|
if flag == :editable
|
679
|
-
op.
|
532
|
+
op.extras << edit
|
680
533
|
else
|
681
534
|
target << quote_option('e', edit)
|
682
535
|
end
|
@@ -711,7 +564,7 @@ module Squared
|
|
711
564
|
end
|
712
565
|
|
713
566
|
def append_global(target: @session)
|
714
|
-
|
567
|
+
option('cache-dir', target: target) do |val|
|
715
568
|
target << case val
|
716
569
|
when '0', 'false'
|
717
570
|
'--no-cache-dir'
|
@@ -719,82 +572,18 @@ module Squared
|
|
719
572
|
quote_option('cache-dir', path + val)
|
720
573
|
end
|
721
574
|
end
|
722
|
-
|
723
|
-
|
575
|
+
option('proxy', target: target) { |val| target << shell_option('proxy', val) }
|
576
|
+
option('python', target: target) { |val| target << quote_option('python', path + val) }
|
724
577
|
append_nocolor(target: target)
|
725
578
|
end
|
726
579
|
|
727
|
-
def
|
728
|
-
@
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
unless (ret = (@pyproject ||= {})[table])
|
735
|
-
ret = []
|
736
|
-
start = /^\s*\[#{Regexp.escape(table)}\]\s*$/
|
737
|
-
ch = nil
|
738
|
-
found = false
|
739
|
-
File.foreach(file) do |line|
|
740
|
-
if found
|
741
|
-
break if line.match?(/^\s*\[[\w.-]+\]\s*$/)
|
742
|
-
|
743
|
-
if ch
|
744
|
-
val = line.rstrip
|
745
|
-
case ch
|
746
|
-
when '}', ']'
|
747
|
-
ch = nil if val.end_with?(ch)
|
748
|
-
val = "\n#{val}"
|
749
|
-
else
|
750
|
-
if val.chomp!(ch)
|
751
|
-
ch = nil
|
752
|
-
else
|
753
|
-
val = line
|
754
|
-
end
|
755
|
-
end
|
756
|
-
ret.last[1] += val
|
757
|
-
elsif (data = line.match(/^\s*(\S+)\s*=\s*([+-]?[\d.]+|true|false|("""|'''|["'\[{])(.*?))\s*$/))
|
758
|
-
if (val = data[4])
|
759
|
-
case (ch = data[3])
|
760
|
-
when '{', '['
|
761
|
-
val = "#{ch}#{val}"
|
762
|
-
ch = ch == '{' ? '}' : ']'
|
763
|
-
ch = nil if val.end_with?(ch)
|
764
|
-
else
|
765
|
-
if val.chomp!(ch)
|
766
|
-
ch = nil
|
767
|
-
elsif ch.size == 1
|
768
|
-
next
|
580
|
+
def editable_set(val)
|
581
|
+
@editable = case val
|
582
|
+
when '.', Pathname
|
583
|
+
val
|
584
|
+
when String
|
585
|
+
Pathname.new(editable)
|
769
586
|
end
|
770
|
-
end
|
771
|
-
else
|
772
|
-
val = case (val = data[2])
|
773
|
-
when 'true'
|
774
|
-
true
|
775
|
-
when 'false'
|
776
|
-
false
|
777
|
-
else
|
778
|
-
val.include?('.') ? val.to_f : val.to_i
|
779
|
-
end
|
780
|
-
end
|
781
|
-
ret << [data[1], val]
|
782
|
-
end
|
783
|
-
else
|
784
|
-
found = line.match?(start)
|
785
|
-
end
|
786
|
-
end
|
787
|
-
@pyproject[table] = ret
|
788
|
-
end
|
789
|
-
return ret.find { |val| val.first == key }&.last if key
|
790
|
-
|
791
|
-
ret
|
792
|
-
end
|
793
|
-
|
794
|
-
def pyprojectfile
|
795
|
-
return unless (ret = basepath(DEP_PYTHON[2])).exist?
|
796
|
-
|
797
|
-
ret
|
798
587
|
end
|
799
588
|
|
800
589
|
def singleopt(flag = nil)
|
@@ -837,18 +626,7 @@ module Squared
|
|
837
626
|
@venv&.join(workspace.windows? ? 'Scripts' : 'bin')
|
838
627
|
end
|
839
628
|
|
840
|
-
def editable_set(val)
|
841
|
-
@editable = case val
|
842
|
-
when '.', Pathname
|
843
|
-
val
|
844
|
-
when String
|
845
|
-
Pathname.new(editable)
|
846
|
-
end
|
847
|
-
end
|
848
|
-
|
849
629
|
def venv_set(val)
|
850
|
-
return unless val
|
851
|
-
|
852
630
|
if val.is_a?(Array)
|
853
631
|
val, *opts = val
|
854
632
|
@venvopts = opts
|
@@ -872,8 +650,8 @@ module Squared
|
|
872
650
|
return if !venv || (venvbin.directory? && !venvbin.empty?)
|
873
651
|
|
874
652
|
puts log_message(Logger::INFO, venv, subject: 'venv', hint: 'init')
|
875
|
-
|
876
|
-
venv_create(venv,
|
653
|
+
@venvopts &&= @venvopts.map { |val| OptionPartition.strip(val) }.flatten
|
654
|
+
venv_create(venv, @venvopts || ["prompt=#{name}", 'upgrade-deps'], env: false, banner: false)
|
877
655
|
puts log_message(Logger::INFO, venv, subject: 'venv', hint: 'created')
|
878
656
|
end
|
879
657
|
|
@@ -887,10 +665,6 @@ module Squared
|
|
887
665
|
puts(dir.directory? ? "Success: #{dir}" : 'Failed') if banner && !status
|
888
666
|
end
|
889
667
|
|
890
|
-
def poetry?
|
891
|
-
build_backend ? build_backend == 'poetry.core.masonry.api' : dependtype == 1
|
892
|
-
end
|
893
|
-
|
894
668
|
def requirements?
|
895
669
|
dependtype == 5
|
896
670
|
end
|