squared 0.4.29 → 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 -416
- data/README.md +1279 -650
- data/README.ruby.md +722 -0
- data/lib/squared/common/base.rb +8 -9
- data/lib/squared/common/format.rb +22 -29
- data/lib/squared/common/prompt.rb +46 -47
- data/lib/squared/common/shell.rb +50 -63
- data/lib/squared/common/system.rb +34 -37
- data/lib/squared/common/utils.rb +3 -28
- data/lib/squared/common.rb +2 -1
- data/lib/squared/config.rb +21 -21
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +74 -95
- data/lib/squared/workspace/project/base.rb +408 -536
- data/lib/squared/workspace/project/docker.rb +176 -206
- data/lib/squared/workspace/project/git.rb +357 -498
- data/lib/squared/workspace/project/node.rb +180 -286
- data/lib/squared/workspace/project/python.rb +88 -306
- data/lib/squared/workspace/project/ruby.rb +221 -301
- data/lib/squared/workspace/project/support/class.rb +93 -300
- data/lib/squared/workspace/project.rb +0 -10
- data/lib/squared/workspace/repo.rb +54 -93
- data/lib/squared/workspace/series.rb +34 -32
- 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 -171
- data/lib/squared/workspace/support/base.rb +0 -32
|
@@ -7,8 +7,8 @@ module Squared
|
|
|
7
7
|
DEP_PYTHON = %w[poetry.lock setup.cfg pyproject.toml setup.py requirements.txt].freeze
|
|
8
8
|
DIR_PYTHON = (DEP_PYTHON + %w[README.rst]).freeze
|
|
9
9
|
OPT_PYTHON = {
|
|
10
|
-
common: %w[b B d E h i I O 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
|
|
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 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
|
|
41
|
-
i|identity=b 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
|
|
@@ -207,7 +134,7 @@ module Squared
|
|
|
207
134
|
if flag == :create
|
|
208
135
|
format_desc action, flag, 'dir,opts*'
|
|
209
136
|
task flag, [:dir] do |_, args|
|
|
210
|
-
dir =
|
|
137
|
+
dir = path + param_guard(action, flag, args: args, key: :dir)
|
|
211
138
|
venv_create dir, args.extras
|
|
212
139
|
end
|
|
213
140
|
elsif venv
|
|
@@ -242,11 +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
|
-
install flag, ['upgrade', *args.to_a, 'pip']
|
|
249
|
-
end
|
|
250
172
|
when :freeze
|
|
251
173
|
format_desc action, flag, "file?=#{DEP_PYTHON[4]},opts*"
|
|
252
174
|
task flag do |_, args|
|
|
@@ -292,30 +214,14 @@ module Squared
|
|
|
292
214
|
depend flag, args.to_a
|
|
293
215
|
end
|
|
294
216
|
end
|
|
295
|
-
when 'outdated'
|
|
296
|
-
format_desc action, flag, 'eager?,user?'
|
|
297
|
-
task flag do |_, args|
|
|
298
|
-
outdated flag, args.to_a
|
|
299
|
-
end
|
|
300
217
|
when 'build'
|
|
301
|
-
case flag
|
|
302
|
-
when :poetry
|
|
303
|
-
next unless build_backend == 'poetry.core.masonry.api'
|
|
304
|
-
when :pdm
|
|
305
|
-
next unless build_backend == 'pdm.backend'
|
|
306
|
-
when :hatch
|
|
307
|
-
next unless build_backend == 'hatchling.build'
|
|
308
|
-
end
|
|
309
218
|
format_desc(action, flag, 'opts*', after: case flag
|
|
310
219
|
when :python then 'srcdir?'
|
|
311
|
-
when :poetry then 'output?'
|
|
312
|
-
when :pdm then 'dest?'
|
|
313
220
|
when :hatch then 'location?'
|
|
314
221
|
end)
|
|
315
222
|
task flag do |_, args|
|
|
316
223
|
build! flag, args.to_a
|
|
317
224
|
end
|
|
318
|
-
break unless flag == :python
|
|
319
225
|
when 'publish'
|
|
320
226
|
format_desc(action, flag, 'opts*', after: case flag
|
|
321
227
|
when :hatch then 'artifacts?'
|
|
@@ -338,8 +244,8 @@ module Squared
|
|
|
338
244
|
elsif outdated?
|
|
339
245
|
venv_init
|
|
340
246
|
workspace.rev_clear(name, sync: sync)
|
|
341
|
-
if !flag &&
|
|
342
|
-
cmd = poetry_session 'install -n'
|
|
247
|
+
if !flag && dependtype == 1
|
|
248
|
+
cmd = poetry_session 'install', '-n'
|
|
343
249
|
cmd << '--no-root' if option('no-root')
|
|
344
250
|
else
|
|
345
251
|
cmd = pip_session 'install'
|
|
@@ -348,7 +254,7 @@ module Squared
|
|
|
348
254
|
when :user
|
|
349
255
|
cmd << '--user'
|
|
350
256
|
when :target
|
|
351
|
-
cmd << quote_option('target',
|
|
257
|
+
cmd << quote_option('target', path + target)
|
|
352
258
|
when :force
|
|
353
259
|
cmd << '--force-reinstall'
|
|
354
260
|
end
|
|
@@ -363,8 +269,8 @@ module Squared
|
|
|
363
269
|
end
|
|
364
270
|
end
|
|
365
271
|
|
|
366
|
-
def outdated(
|
|
367
|
-
cmd = pip_session 'list --outdated'
|
|
272
|
+
def outdated(*, sync: invoked_sync?('outdated'))
|
|
273
|
+
cmd = pip_session 'list', '--outdated'
|
|
368
274
|
append_global
|
|
369
275
|
cmd = session_done cmd
|
|
370
276
|
log.info cmd
|
|
@@ -373,39 +279,28 @@ module Squared
|
|
|
373
279
|
print_item banner if sync
|
|
374
280
|
start = 0
|
|
375
281
|
found = 0
|
|
376
|
-
major =
|
|
377
|
-
minor = []
|
|
378
|
-
patch = []
|
|
282
|
+
major = 0
|
|
379
283
|
pwd_set(from: :outdated) do
|
|
380
284
|
buffer = []
|
|
381
285
|
out = ->(val) { sync ? puts(val) : buffer << val }
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
else
|
|
385
|
-
IO.popen(runenv || {}, cmd)
|
|
386
|
-
end.each do |line|
|
|
387
|
-
next if line.match?(/^[ -]+$/)
|
|
286
|
+
IO.popen(runenv || {}, cmd).each do |line|
|
|
287
|
+
next if line.match?(/^[\s-]+$/)
|
|
388
288
|
|
|
389
289
|
if start > 0
|
|
390
290
|
unless stdin?
|
|
391
|
-
|
|
392
|
-
next unless cur && lat
|
|
291
|
+
data = line.scan(SEM_VER)
|
|
292
|
+
next unless (cur = data.shift) && (lat = data.shift)
|
|
393
293
|
|
|
394
294
|
latest = lat.join
|
|
395
295
|
current = cur.join
|
|
396
296
|
semver cur
|
|
397
297
|
semver lat
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
0
|
|
405
|
-
else
|
|
406
|
-
minor << name
|
|
407
|
-
1
|
|
408
|
-
end
|
|
298
|
+
if semmajor?(cur, lat)
|
|
299
|
+
type = 2
|
|
300
|
+
major += 1
|
|
301
|
+
else
|
|
302
|
+
type = cur[2] == lat[2] ? 0 : 1
|
|
303
|
+
end
|
|
409
304
|
if type == 0
|
|
410
305
|
styles = color(:yellow)
|
|
411
306
|
else
|
|
@@ -439,18 +334,7 @@ module Squared
|
|
|
439
334
|
puts buffer
|
|
440
335
|
end
|
|
441
336
|
if found > 0
|
|
442
|
-
|
|
443
|
-
pkg = case flag
|
|
444
|
-
when :major
|
|
445
|
-
major + minor + patch
|
|
446
|
-
when :minor
|
|
447
|
-
minor + patch
|
|
448
|
-
when :patch
|
|
449
|
-
patch
|
|
450
|
-
end
|
|
451
|
-
unless !pkg || pkg.empty?
|
|
452
|
-
install(:upgrade, pkg, strategy: opts.include?('eager') ? 'eager' : nil, user: opts.include?('user'))
|
|
453
|
-
end
|
|
337
|
+
puts print_footer empty_status('Updates are available', 'major', major)
|
|
454
338
|
elsif start == 0
|
|
455
339
|
puts 'No updates were found'
|
|
456
340
|
end
|
|
@@ -458,7 +342,7 @@ module Squared
|
|
|
458
342
|
on :last, :outdated
|
|
459
343
|
end
|
|
460
344
|
|
|
461
|
-
def install(flag, opts = [], strategy: nil
|
|
345
|
+
def install(flag, opts = [], strategy: nil)
|
|
462
346
|
cmd = pip_session 'install'
|
|
463
347
|
out = append_pip(flag, opts, from: :install)
|
|
464
348
|
case flag
|
|
@@ -468,10 +352,8 @@ module Squared
|
|
|
468
352
|
when :upgrade
|
|
469
353
|
raise_error('no packages listed', hint: flag) if out.empty?
|
|
470
354
|
cmd << '--upgrade'
|
|
471
|
-
cmd << '--user' if user
|
|
472
355
|
cmd << basic_option('upgrade-strategy', strategy) if strategy
|
|
473
356
|
append_value out
|
|
474
|
-
python_session('-m pip', *cmd.to_a.drop(1)) if workspace.windows?
|
|
475
357
|
end
|
|
476
358
|
run(from: :install)
|
|
477
359
|
end
|
|
@@ -484,9 +366,6 @@ module Squared
|
|
|
484
366
|
when :poetry
|
|
485
367
|
cmd = poetry_session 'build'
|
|
486
368
|
list = OPT_POETRY[:build] + OPT_POETRY[:common]
|
|
487
|
-
when :pdm
|
|
488
|
-
cmd, opts = pdm_session('build', opts: opts)
|
|
489
|
-
list = OPT_PDM[:build]
|
|
490
369
|
when :hatch
|
|
491
370
|
cmd, opts = hatch_session('build', opts: opts)
|
|
492
371
|
list = OPT_HATCH[:build]
|
|
@@ -494,7 +373,7 @@ module Squared
|
|
|
494
373
|
srcdir = nil
|
|
495
374
|
op = OptionPartition.new(opts, list, cmd, project: self, single: singleopt(flag))
|
|
496
375
|
op.each do |opt|
|
|
497
|
-
if !srcdir && basepath(opt
|
|
376
|
+
if !srcdir && basepath(opt).exist? && projectpath?(opt)
|
|
498
377
|
srcdir = opt
|
|
499
378
|
else
|
|
500
379
|
op.found << opt
|
|
@@ -502,13 +381,12 @@ module Squared
|
|
|
502
381
|
end
|
|
503
382
|
op.swap
|
|
504
383
|
case flag
|
|
505
|
-
when :poetry
|
|
384
|
+
when :poetry
|
|
506
385
|
if srcdir
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
op.push(srcdir)
|
|
386
|
+
if op.arg?('o', 'output')
|
|
387
|
+
op.extras << srcdir
|
|
510
388
|
else
|
|
511
|
-
op << quote_option(
|
|
389
|
+
op << quote_option('output', path + srcdir)
|
|
512
390
|
end
|
|
513
391
|
srcdir = nil
|
|
514
392
|
end
|
|
@@ -520,7 +398,7 @@ module Squared
|
|
|
520
398
|
end
|
|
521
399
|
op << basic_option('p', project) unless ENV['HATCH_PROJECT'] || op.arg?('p', 'project')
|
|
522
400
|
end
|
|
523
|
-
op
|
|
401
|
+
op << shell_quote(path + srcdir) if srcdir
|
|
524
402
|
op.clear
|
|
525
403
|
run(from: :"#{flag}:build")
|
|
526
404
|
end
|
|
@@ -530,35 +408,21 @@ module Squared
|
|
|
530
408
|
when :poetry
|
|
531
409
|
poetry_session 'publish'
|
|
532
410
|
list = OPT_POETRY[:publish] + OPT_POETRY[:common]
|
|
533
|
-
when :pdm
|
|
534
|
-
opts = pdm_session('publish', opts: opts).last
|
|
535
|
-
list = OPT_PDM[:publish]
|
|
536
|
-
when :hatch
|
|
537
|
-
opts = hatch_session('publish', opts: opts).last
|
|
538
|
-
list = OPT_HATCH[:publish]
|
|
539
411
|
when :twine
|
|
540
412
|
session 'twine', 'upload'
|
|
541
413
|
list = OPT_TWINE[:publish]
|
|
414
|
+
when :hatch
|
|
415
|
+
opts = hatch_session('publish', opts: opts).last
|
|
416
|
+
list = OPT_HATCH[:publish]
|
|
542
417
|
end
|
|
543
418
|
op = OptionPartition.new(opts, list, @session, project: self, single: singleopt(flag))
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
end
|
|
549
|
-
case flag
|
|
550
|
-
when :hatch, :twine
|
|
551
|
-
if op.empty?
|
|
552
|
-
op.push("#{dist.call}/*")
|
|
553
|
-
else
|
|
554
|
-
op.map! { |val| basepath(val) }
|
|
555
|
-
end
|
|
556
|
-
op.append
|
|
557
|
-
else
|
|
558
|
-
dist.call unless op.arg?(*(flag == :poetry ? ['dist-dir'] : ['d', 'dest']))
|
|
559
|
-
op.clear(pass: false)
|
|
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
|
|
560
423
|
end
|
|
561
|
-
|
|
424
|
+
op.append
|
|
425
|
+
run(from: :"#{flag}:publish")
|
|
562
426
|
end
|
|
563
427
|
|
|
564
428
|
def pip(flag, opts = [])
|
|
@@ -566,7 +430,7 @@ module Squared
|
|
|
566
430
|
out = append_pip(nil, opts, from: flag)
|
|
567
431
|
case flag
|
|
568
432
|
when :uninstall
|
|
569
|
-
raise_error('no packages listed', hint:
|
|
433
|
+
raise_error('no packages listed', hint: 'uninstall') if out.empty?
|
|
570
434
|
cmd.merge(out)
|
|
571
435
|
when :freeze
|
|
572
436
|
venv_init
|
|
@@ -578,7 +442,13 @@ module Squared
|
|
|
578
442
|
ret
|
|
579
443
|
end
|
|
580
444
|
|
|
581
|
-
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
|
|
582
452
|
case key
|
|
583
453
|
when :dependfile
|
|
584
454
|
req = basepath(*val)
|
|
@@ -614,37 +484,27 @@ module Squared
|
|
|
614
484
|
def python_session(*cmd, opts: nil)
|
|
615
485
|
return session('python', *preopts(quiet: false), *cmd, path: venv.nil?) unless opts
|
|
616
486
|
|
|
617
|
-
op = OptionPartition.new(opts, OPT_PYTHON[:common], project: self, single: /\
|
|
487
|
+
op = OptionPartition.new(opts, OPT_PYTHON[:common], project: self, single: /\Av+\z/)
|
|
618
488
|
ret = session('python', *op.to_a, *cmd, path: venv.nil?)
|
|
619
489
|
[ret, op.extras]
|
|
620
490
|
end
|
|
621
491
|
|
|
622
492
|
def poetry_session(*cmd)
|
|
623
493
|
ret = session('poetry', *cmd, *preopts)
|
|
624
|
-
|
|
625
|
-
ret << quote_option('project', basepath(val))
|
|
626
|
-
end
|
|
494
|
+
option('project', ignore: false) { |val| ret << quote_option('project', path + val) }
|
|
627
495
|
ret
|
|
628
496
|
end
|
|
629
497
|
|
|
630
|
-
def pdm_session(*cmd, opts: nil)
|
|
631
|
-
create_session(*cmd, name: 'pdm', common: OPT_PDM[:common], opts: opts)
|
|
632
|
-
end
|
|
633
|
-
|
|
634
498
|
def hatch_session(*cmd, opts: nil)
|
|
635
|
-
|
|
636
|
-
end
|
|
637
|
-
|
|
638
|
-
def create_session(*cmd, name:, common:, opts: nil)
|
|
639
|
-
return session(name, *preopts, *cmd, path: venv.nil?) unless opts
|
|
499
|
+
return session('hatch', *preopts, *cmd, path: venv.nil?) unless opts
|
|
640
500
|
|
|
641
|
-
op = OptionPartition.new(opts, common, project: self, single: singleopt)
|
|
642
|
-
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?)
|
|
643
503
|
[ret, op.extras]
|
|
644
504
|
end
|
|
645
505
|
|
|
646
506
|
def append_pip(flag, opts, target: @session, from: nil)
|
|
647
|
-
|
|
507
|
+
if !from || opts.empty?
|
|
648
508
|
append_global(target: target)
|
|
649
509
|
return []
|
|
650
510
|
end
|
|
@@ -667,11 +527,11 @@ module Squared
|
|
|
667
527
|
end
|
|
668
528
|
op.swap
|
|
669
529
|
if edit
|
|
670
|
-
edit =
|
|
530
|
+
edit = path + edit unless %r{^[a-z]+(?:\+[a-z]+)?://}i.match?(edit)
|
|
671
531
|
if flag == :editable
|
|
672
|
-
op.
|
|
532
|
+
op.extras << edit
|
|
673
533
|
else
|
|
674
|
-
|
|
534
|
+
target << quote_option('e', edit)
|
|
675
535
|
end
|
|
676
536
|
end
|
|
677
537
|
case flag
|
|
@@ -682,112 +542,48 @@ module Squared
|
|
|
682
542
|
[]
|
|
683
543
|
end
|
|
684
544
|
else
|
|
685
|
-
|
|
545
|
+
opts
|
|
686
546
|
end
|
|
687
547
|
end
|
|
688
548
|
|
|
689
549
|
def append_editable(target: @session)
|
|
690
|
-
return if requirements?
|
|
550
|
+
return if requirements?
|
|
691
551
|
|
|
692
552
|
if (val = option('editable', 'e', target: target, ignore: false))
|
|
693
|
-
|
|
553
|
+
session_delete('e', 'editable', target: target)
|
|
694
554
|
case val
|
|
695
555
|
when '0', 'false'
|
|
696
556
|
return
|
|
697
557
|
else
|
|
698
|
-
val =
|
|
558
|
+
val = path + val
|
|
699
559
|
end
|
|
700
560
|
elsif session_arg?('e', 'editable', target: target) || !(val = editable)
|
|
701
561
|
return
|
|
702
562
|
end
|
|
703
|
-
target << quote_option('e',
|
|
563
|
+
target << quote_option('e', val)
|
|
704
564
|
end
|
|
705
565
|
|
|
706
566
|
def append_global(target: @session)
|
|
707
|
-
|
|
567
|
+
option('cache-dir', target: target) do |val|
|
|
708
568
|
target << case val
|
|
709
569
|
when '0', 'false'
|
|
710
570
|
'--no-cache-dir'
|
|
711
571
|
else
|
|
712
|
-
quote_option('cache-dir',
|
|
572
|
+
quote_option('cache-dir', path + val)
|
|
713
573
|
end
|
|
714
574
|
end
|
|
715
|
-
|
|
716
|
-
|
|
575
|
+
option('proxy', target: target) { |val| target << shell_option('proxy', val) }
|
|
576
|
+
option('python', target: target) { |val| target << quote_option('python', path + val) }
|
|
717
577
|
append_nocolor(target: target)
|
|
718
578
|
end
|
|
719
579
|
|
|
720
|
-
def
|
|
721
|
-
@
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
unless (ret = (@pyproject ||= {})[table])
|
|
728
|
-
ret = []
|
|
729
|
-
start = /^\s*\[#{Regexp.escape(table)}\]\s*$/
|
|
730
|
-
ch = nil
|
|
731
|
-
found = false
|
|
732
|
-
File.foreach(file) do |line|
|
|
733
|
-
if found
|
|
734
|
-
break if line.match?(/^\s*\[[\w.-]+\]\s*$/)
|
|
735
|
-
|
|
736
|
-
if ch
|
|
737
|
-
val = line.rstrip
|
|
738
|
-
case ch
|
|
739
|
-
when '}', ']'
|
|
740
|
-
ch = nil if val.end_with?(ch)
|
|
741
|
-
val = "\n#{val}"
|
|
742
|
-
else
|
|
743
|
-
if val.chomp!(ch)
|
|
744
|
-
ch = nil
|
|
745
|
-
else
|
|
746
|
-
val = line
|
|
747
|
-
end
|
|
748
|
-
end
|
|
749
|
-
ret.last[1] += val
|
|
750
|
-
elsif (data = line.match(/^\s*(\S+)\s*=\s*([+-]?[\d.]+|true|false|("""|'''|["'\[{])(.*?))\s*$/))
|
|
751
|
-
if (val = data[4])
|
|
752
|
-
case (ch = data[3])
|
|
753
|
-
when '{', '['
|
|
754
|
-
val = "#{ch}#{val}"
|
|
755
|
-
ch = ch == '{' ? '}' : ']'
|
|
756
|
-
ch = nil if val.end_with?(ch)
|
|
757
|
-
else
|
|
758
|
-
if val.chomp!(ch)
|
|
759
|
-
ch = nil
|
|
760
|
-
elsif ch.size == 1
|
|
761
|
-
next
|
|
580
|
+
def editable_set(val)
|
|
581
|
+
@editable = case val
|
|
582
|
+
when '.', Pathname
|
|
583
|
+
val
|
|
584
|
+
when String
|
|
585
|
+
Pathname.new(editable)
|
|
762
586
|
end
|
|
763
|
-
end
|
|
764
|
-
else
|
|
765
|
-
val = case (val = data[2])
|
|
766
|
-
when 'true'
|
|
767
|
-
true
|
|
768
|
-
when 'false'
|
|
769
|
-
false
|
|
770
|
-
else
|
|
771
|
-
val.include?('.') ? val.to_f : val.to_i
|
|
772
|
-
end
|
|
773
|
-
end
|
|
774
|
-
ret << [data[1], val]
|
|
775
|
-
end
|
|
776
|
-
else
|
|
777
|
-
found = line.match?(start)
|
|
778
|
-
end
|
|
779
|
-
end
|
|
780
|
-
@pyproject[table] = ret
|
|
781
|
-
end
|
|
782
|
-
return ret.find { |val| val.first == key }&.last if key
|
|
783
|
-
|
|
784
|
-
ret
|
|
785
|
-
end
|
|
786
|
-
|
|
787
|
-
def pyprojectfile
|
|
788
|
-
return unless (ret = basepath(DEP_PYTHON[2])).exist?
|
|
789
|
-
|
|
790
|
-
ret
|
|
791
587
|
end
|
|
792
588
|
|
|
793
589
|
def singleopt(flag = nil)
|
|
@@ -830,23 +626,13 @@ module Squared
|
|
|
830
626
|
@venv&.join(workspace.windows? ? 'Scripts' : 'bin')
|
|
831
627
|
end
|
|
832
628
|
|
|
833
|
-
def editable_set(val)
|
|
834
|
-
@editable = case val
|
|
835
|
-
when '.', Pathname
|
|
836
|
-
val
|
|
837
|
-
when String
|
|
838
|
-
Pathname.new(val) unless val.empty?
|
|
839
|
-
end
|
|
840
|
-
end
|
|
841
|
-
|
|
842
629
|
def venv_set(val)
|
|
843
|
-
return unless val
|
|
844
|
-
|
|
845
630
|
if val.is_a?(Array)
|
|
846
631
|
val, *opts = val
|
|
847
632
|
@venvopts = opts
|
|
848
633
|
end
|
|
849
|
-
@venv =
|
|
634
|
+
@venv = Pathname.new(val)
|
|
635
|
+
@venv = @path + @venv unless @venv.absolute?
|
|
850
636
|
if projectpath?(@venv)
|
|
851
637
|
if @venv.exist?
|
|
852
638
|
log.debug "venv found: #{@venv}"
|
|
@@ -864,8 +650,8 @@ module Squared
|
|
|
864
650
|
return if !venv || (venvbin.directory? && !venvbin.empty?)
|
|
865
651
|
|
|
866
652
|
puts log_message(Logger::INFO, venv, subject: 'venv', hint: 'init')
|
|
867
|
-
|
|
868
|
-
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)
|
|
869
655
|
puts log_message(Logger::INFO, venv, subject: 'venv', hint: 'created')
|
|
870
656
|
end
|
|
871
657
|
|
|
@@ -874,15 +660,11 @@ module Squared
|
|
|
874
660
|
op = OptionPartition.new(opts, OPT_PYTHON[:venv], cmd, project: self)
|
|
875
661
|
op.append(dir, delim: true)
|
|
876
662
|
.clear(pass: false)
|
|
877
|
-
status = op.arg?(/\A-v+\z
|
|
663
|
+
status = op.arg?(/\A-v+\z/, 'verbose')
|
|
878
664
|
run(op, env, exception: true, banner: banner)
|
|
879
665
|
puts(dir.directory? ? "Success: #{dir}" : 'Failed') if banner && !status
|
|
880
666
|
end
|
|
881
667
|
|
|
882
|
-
def poetry?
|
|
883
|
-
dependtype == 1
|
|
884
|
-
end
|
|
885
|
-
|
|
886
668
|
def requirements?
|
|
887
669
|
dependtype == 5
|
|
888
670
|
end
|