squared 0.4.36 → 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 +64 -529
- data/README.md +1283 -663
- data/README.ruby.md +722 -0
- data/lib/squared/common/base.rb +8 -9
- data/lib/squared/common/format.rb +26 -39
- data/lib/squared/common/prompt.rb +46 -51
- data/lib/squared/common/shell.rb +50 -70
- 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 +30 -33
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +82 -122
- data/lib/squared/workspace/project/base.rb +432 -578
- data/lib/squared/workspace/project/docker.rb +186 -214
- data/lib/squared/workspace/project/git.rb +368 -512
- data/lib/squared/workspace/project/node.rb +195 -315
- data/lib/squared/workspace/project/python.rb +125 -355
- data/lib/squared/workspace/project/ruby.rb +258 -340
- data/lib/squared/workspace/project/support/class.rb +92 -313
- data/lib/squared/workspace/project.rb +0 -10
- data/lib/squared/workspace/repo.rb +58 -99
- data/lib/squared/workspace/series.rb +41 -47
- data/lib/squared/workspace/support/data.rb +3 -2
- data/lib/squared/workspace/support.rb +0 -1
- data/lib/squared/workspace.rb +3 -5
- data/squared.gemspec +5 -5
- metadata +7 -8
- data/lib/squared/common/class.rb +0 -186
- 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[
|
|
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,17 +28,10 @@ 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
|
|
34
|
-
u|username=
|
|
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=qq].freeze
|
|
33
|
+
publish: %w[build dry-run client-cert=p cert=p dist-dir=p p|password=b r|repository=b skip-existing
|
|
34
|
+
u|username=b].freeze
|
|
42
35
|
}.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
|
|
@@ -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
|
-
|
|
53
|
-
sign-with=b u|username=
|
|
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
|
|
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: '.', **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
|
|
@@ -228,7 +155,7 @@ module Squared
|
|
|
228
155
|
if args.empty?
|
|
229
156
|
args = readline('Enter command', force: true).split(' ', 2)
|
|
230
157
|
elsif args.size == 1 && !option('interactive', prefix: 'venv', equals: '0')
|
|
231
|
-
args << readline('Enter arguments', force: false)
|
|
158
|
+
args << readline('Enter arguments', force: false)
|
|
232
159
|
end
|
|
233
160
|
venv_init
|
|
234
161
|
run args.join(' ')
|
|
@@ -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
|
-
when :
|
|
311
|
-
when :pdm then 'dest?'
|
|
219
|
+
when :python then 'srcdir?'
|
|
312
220
|
when :hatch then 'location?'
|
|
313
|
-
else 'outdir?'
|
|
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,18 +244,17 @@ 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'
|
|
346
|
-
cmd << '--upgrade-strategy=eager' if env('PYTHON_UPDATE')
|
|
347
252
|
if flag
|
|
348
253
|
case flag
|
|
349
254
|
when :user
|
|
350
255
|
cmd << '--user'
|
|
351
256
|
when :target
|
|
352
|
-
cmd << quote_option('target',
|
|
257
|
+
cmd << quote_option('target', path + target)
|
|
353
258
|
when :force
|
|
354
259
|
cmd << '--force-reinstall'
|
|
355
260
|
end
|
|
@@ -364,8 +269,8 @@ module Squared
|
|
|
364
269
|
end
|
|
365
270
|
end
|
|
366
271
|
|
|
367
|
-
def outdated(
|
|
368
|
-
cmd = pip_session 'list --outdated'
|
|
272
|
+
def outdated(*, sync: invoked_sync?('outdated'))
|
|
273
|
+
cmd = pip_session 'list', '--outdated'
|
|
369
274
|
append_global
|
|
370
275
|
cmd = session_done cmd
|
|
371
276
|
log.info cmd
|
|
@@ -374,39 +279,28 @@ module Squared
|
|
|
374
279
|
print_item banner if sync
|
|
375
280
|
start = 0
|
|
376
281
|
found = 0
|
|
377
|
-
major =
|
|
378
|
-
minor = []
|
|
379
|
-
patch = []
|
|
282
|
+
major = 0
|
|
380
283
|
pwd_set(from: :outdated) do
|
|
381
284
|
buffer = []
|
|
382
285
|
out = ->(val) { sync ? puts(val) : buffer << val }
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
else
|
|
386
|
-
IO.popen(runenv || {}, cmd)
|
|
387
|
-
end.each do |line|
|
|
388
|
-
next if line.match?(/^[ -]+$/)
|
|
286
|
+
IO.popen(runenv || {}, cmd).each do |line|
|
|
287
|
+
next if line.match?(/^[\s-]+$/)
|
|
389
288
|
|
|
390
289
|
if start > 0
|
|
391
290
|
unless stdin?
|
|
392
|
-
|
|
393
|
-
next unless cur && lat
|
|
291
|
+
data = line.scan(SEM_VER)
|
|
292
|
+
next unless (cur = data.shift) && (lat = data.shift)
|
|
394
293
|
|
|
395
294
|
latest = lat.join
|
|
396
295
|
current = cur.join
|
|
397
296
|
semver cur
|
|
398
297
|
semver lat
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
0
|
|
406
|
-
else
|
|
407
|
-
minor << name
|
|
408
|
-
1
|
|
409
|
-
end
|
|
298
|
+
if semmajor?(cur, lat)
|
|
299
|
+
type = 2
|
|
300
|
+
major += 1
|
|
301
|
+
else
|
|
302
|
+
type = cur[2] == lat[2] ? 0 : 1
|
|
303
|
+
end
|
|
410
304
|
if type == 0
|
|
411
305
|
styles = color(:yellow)
|
|
412
306
|
else
|
|
@@ -440,18 +334,7 @@ module Squared
|
|
|
440
334
|
puts buffer
|
|
441
335
|
end
|
|
442
336
|
if found > 0
|
|
443
|
-
|
|
444
|
-
pkg = case flag
|
|
445
|
-
when :major
|
|
446
|
-
major + minor + patch
|
|
447
|
-
when :minor
|
|
448
|
-
minor + patch
|
|
449
|
-
when :patch
|
|
450
|
-
patch
|
|
451
|
-
end
|
|
452
|
-
unless !pkg || pkg.empty?
|
|
453
|
-
install(:upgrade, pkg, strategy: opts.include?('eager') ? 'eager' : nil, user: opts.include?('user'))
|
|
454
|
-
end
|
|
337
|
+
puts print_footer empty_status('Updates are available', 'major', major)
|
|
455
338
|
elsif start == 0
|
|
456
339
|
puts 'No updates were found'
|
|
457
340
|
end
|
|
@@ -459,7 +342,7 @@ module Squared
|
|
|
459
342
|
on :last, :outdated
|
|
460
343
|
end
|
|
461
344
|
|
|
462
|
-
def install(flag, opts = [], strategy: nil
|
|
345
|
+
def install(flag, opts = [], strategy: nil)
|
|
463
346
|
cmd = pip_session 'install'
|
|
464
347
|
out = append_pip(flag, opts, from: :install)
|
|
465
348
|
case flag
|
|
@@ -469,50 +352,53 @@ module Squared
|
|
|
469
352
|
when :upgrade
|
|
470
353
|
raise_error('no packages listed', hint: flag) if out.empty?
|
|
471
354
|
cmd << '--upgrade'
|
|
472
|
-
cmd << '--user' if user
|
|
473
355
|
cmd << basic_option('upgrade-strategy', strategy) if strategy
|
|
474
356
|
append_value out
|
|
475
|
-
python_session('-m pip', *cmd.to_a.drop(1)) if workspace.windows?
|
|
476
357
|
end
|
|
477
358
|
run(from: :install)
|
|
478
359
|
end
|
|
479
360
|
|
|
480
361
|
def build!(flag, opts = [])
|
|
481
362
|
case flag
|
|
363
|
+
when :python
|
|
364
|
+
cmd, opts = python_session('-m build', opts: opts)
|
|
365
|
+
list = OPT_PYTHON[:build]
|
|
482
366
|
when :poetry
|
|
483
367
|
cmd = poetry_session 'build'
|
|
484
368
|
list = OPT_POETRY[:build] + OPT_POETRY[:common]
|
|
485
|
-
when :pdm
|
|
486
|
-
cmd, opts = pdm_session('build', opts: opts)
|
|
487
|
-
list = OPT_PDM[:build]
|
|
488
369
|
when :hatch
|
|
489
370
|
cmd, opts = hatch_session('build', opts: opts)
|
|
490
371
|
list = OPT_HATCH[:build]
|
|
491
|
-
else
|
|
492
|
-
cmd, opts = python_session('-m build', opts: opts)
|
|
493
|
-
list = OPT_PYTHON[:build]
|
|
494
372
|
end
|
|
373
|
+
srcdir = nil
|
|
495
374
|
op = OptionPartition.new(opts, list, cmd, project: self, single: singleopt(flag))
|
|
375
|
+
op.each do |opt|
|
|
376
|
+
if !srcdir && basepath(opt).exist? && projectpath?(opt)
|
|
377
|
+
srcdir = opt
|
|
378
|
+
else
|
|
379
|
+
op.found << opt
|
|
380
|
+
end
|
|
381
|
+
end
|
|
382
|
+
op.swap
|
|
496
383
|
case flag
|
|
497
|
-
when :
|
|
498
|
-
if
|
|
499
|
-
op.
|
|
384
|
+
when :poetry
|
|
385
|
+
if srcdir
|
|
386
|
+
if op.arg?('o', 'output')
|
|
387
|
+
op.extras << srcdir
|
|
388
|
+
else
|
|
389
|
+
op << quote_option('output', path + srcdir)
|
|
390
|
+
end
|
|
391
|
+
srcdir = nil
|
|
500
392
|
end
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
when :pdm
|
|
507
|
-
%w[d dest]
|
|
508
|
-
else
|
|
509
|
-
srcdir = true
|
|
510
|
-
%w[o outdir]
|
|
511
|
-
end
|
|
512
|
-
op << quote_option(args.last, basepath(op.shift)) unless op.arg?(*args)
|
|
393
|
+
when :hatch
|
|
394
|
+
if ENV['HATCH_BUILD_LOCATION']
|
|
395
|
+
srcdir = nil
|
|
396
|
+
else
|
|
397
|
+
srcdir ||= path
|
|
513
398
|
end
|
|
399
|
+
op << basic_option('p', project) unless ENV['HATCH_PROJECT'] || op.arg?('p', 'project')
|
|
514
400
|
end
|
|
515
|
-
op
|
|
401
|
+
op << shell_quote(path + srcdir) if srcdir
|
|
516
402
|
op.clear
|
|
517
403
|
run(from: :"#{flag}:build")
|
|
518
404
|
end
|
|
@@ -522,35 +408,21 @@ module Squared
|
|
|
522
408
|
when :poetry
|
|
523
409
|
poetry_session 'publish'
|
|
524
410
|
list = OPT_POETRY[:publish] + OPT_POETRY[:common]
|
|
525
|
-
when :pdm
|
|
526
|
-
opts = pdm_session('publish', opts: opts).last
|
|
527
|
-
list = OPT_PDM[:publish]
|
|
528
|
-
when :hatch
|
|
529
|
-
opts = hatch_session('publish', opts: opts).last
|
|
530
|
-
list = OPT_HATCH[:publish]
|
|
531
411
|
when :twine
|
|
532
412
|
session 'twine', 'upload'
|
|
533
413
|
list = OPT_TWINE[:publish]
|
|
414
|
+
when :hatch
|
|
415
|
+
opts = hatch_session('publish', opts: opts).last
|
|
416
|
+
list = OPT_HATCH[:publish]
|
|
534
417
|
end
|
|
535
418
|
op = OptionPartition.new(opts, list, @session, project: self, single: singleopt(flag))
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
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
|
|
540
423
|
end
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
if op.empty?
|
|
544
|
-
op.push("#{dist.call}/*")
|
|
545
|
-
else
|
|
546
|
-
op.map! { |val| basepath(val) }
|
|
547
|
-
end
|
|
548
|
-
op.append
|
|
549
|
-
else
|
|
550
|
-
dist.call unless op.arg?(*(flag == :poetry ? ['dist-dir'] : ['d', 'dest']))
|
|
551
|
-
op.clear(pass: false)
|
|
552
|
-
end
|
|
553
|
-
run(from: :"#{flag}:publish", interactive: "Publish #{sub_style(project, styles: theme[:active])}")
|
|
424
|
+
op.append
|
|
425
|
+
run(from: :"#{flag}:publish")
|
|
554
426
|
end
|
|
555
427
|
|
|
556
428
|
def pip(flag, opts = [])
|
|
@@ -558,7 +430,7 @@ module Squared
|
|
|
558
430
|
out = append_pip(nil, opts, from: flag)
|
|
559
431
|
case flag
|
|
560
432
|
when :uninstall
|
|
561
|
-
raise_error('no packages listed', hint:
|
|
433
|
+
raise_error('no packages listed', hint: 'uninstall') if out.empty?
|
|
562
434
|
cmd.merge(out)
|
|
563
435
|
when :freeze
|
|
564
436
|
venv_init
|
|
@@ -570,24 +442,26 @@ module Squared
|
|
|
570
442
|
ret
|
|
571
443
|
end
|
|
572
444
|
|
|
573
|
-
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
|
|
574
452
|
case key
|
|
575
453
|
when :dependfile
|
|
576
|
-
|
|
577
|
-
|
|
454
|
+
req = basepath(*val)
|
|
455
|
+
if (index = DEP_PYTHON.index(req.basename.to_s))
|
|
456
|
+
@dependindex = index
|
|
457
|
+
@dependfile = req
|
|
578
458
|
else
|
|
579
|
-
req
|
|
580
|
-
if (index = DEP_PYTHON.index(req.basename.to_s))
|
|
581
|
-
@dependindex = index
|
|
582
|
-
@dependfile = req
|
|
583
|
-
else
|
|
584
|
-
log.warn "variable_set: @#{key}=#{req} (not supported)"
|
|
585
|
-
end
|
|
459
|
+
log.warn "variable_set: @#{key}=#{req} (not supported)"
|
|
586
460
|
end
|
|
587
461
|
when :editable
|
|
588
462
|
editable_set val.first
|
|
589
463
|
when :venv
|
|
590
|
-
|
|
464
|
+
instance_variable_set(:"@#{key}", val.empty? ? nil : basepath(*val))
|
|
591
465
|
else
|
|
592
466
|
super
|
|
593
467
|
end
|
|
@@ -598,7 +472,7 @@ module Squared
|
|
|
598
472
|
end
|
|
599
473
|
|
|
600
474
|
def outdated?
|
|
601
|
-
dependtype > 0
|
|
475
|
+
dependtype > 0
|
|
602
476
|
end
|
|
603
477
|
|
|
604
478
|
private
|
|
@@ -608,40 +482,29 @@ module Squared
|
|
|
608
482
|
end
|
|
609
483
|
|
|
610
484
|
def python_session(*cmd, opts: nil)
|
|
611
|
-
|
|
612
|
-
return session('python', *pre, *cmd, path: venv.nil?) unless opts
|
|
485
|
+
return session('python', *preopts(quiet: false), *cmd, path: venv.nil?) unless opts
|
|
613
486
|
|
|
614
|
-
op = OptionPartition.new(opts, OPT_PYTHON[:common], project: self, single:
|
|
615
|
-
ret = session('python', *
|
|
487
|
+
op = OptionPartition.new(opts, OPT_PYTHON[:common], project: self, single: /\Av+\z/)
|
|
488
|
+
ret = session('python', *op.to_a, *cmd, path: venv.nil?)
|
|
616
489
|
[ret, op.extras]
|
|
617
490
|
end
|
|
618
491
|
|
|
619
492
|
def poetry_session(*cmd)
|
|
620
493
|
ret = session('poetry', *cmd, *preopts)
|
|
621
|
-
|
|
622
|
-
ret << quote_option('project', basepath(val))
|
|
623
|
-
end
|
|
494
|
+
option('project', ignore: false) { |val| ret << quote_option('project', path + val) }
|
|
624
495
|
ret
|
|
625
496
|
end
|
|
626
497
|
|
|
627
|
-
def pdm_session(*cmd, opts: nil)
|
|
628
|
-
create_session(*cmd, name: 'pdm', common: OPT_PDM[:common], opts: opts)
|
|
629
|
-
end
|
|
630
|
-
|
|
631
498
|
def hatch_session(*cmd, opts: nil)
|
|
632
|
-
|
|
633
|
-
end
|
|
634
|
-
|
|
635
|
-
def create_session(*cmd, name:, common:, opts: nil)
|
|
636
|
-
return session(name, *preopts, *cmd, path: venv.nil?) unless opts
|
|
499
|
+
return session('hatch', *preopts, *cmd, path: venv.nil?) unless opts
|
|
637
500
|
|
|
638
|
-
op = OptionPartition.new(opts, common, project: self, single: singleopt
|
|
639
|
-
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?)
|
|
640
503
|
[ret, op.extras]
|
|
641
504
|
end
|
|
642
505
|
|
|
643
506
|
def append_pip(flag, opts, target: @session, from: nil)
|
|
644
|
-
|
|
507
|
+
if !from || opts.empty?
|
|
645
508
|
append_global(target: target)
|
|
646
509
|
return []
|
|
647
510
|
end
|
|
@@ -664,11 +527,11 @@ module Squared
|
|
|
664
527
|
end
|
|
665
528
|
op.swap
|
|
666
529
|
if edit
|
|
667
|
-
edit =
|
|
530
|
+
edit = path + edit unless %r{^[a-z]+(?:\+[a-z]+)?://}i.match?(edit)
|
|
668
531
|
if flag == :editable
|
|
669
|
-
op.
|
|
532
|
+
op.extras << edit
|
|
670
533
|
else
|
|
671
|
-
|
|
534
|
+
target << quote_option('e', edit)
|
|
672
535
|
end
|
|
673
536
|
end
|
|
674
537
|
case flag
|
|
@@ -679,120 +542,54 @@ module Squared
|
|
|
679
542
|
[]
|
|
680
543
|
end
|
|
681
544
|
else
|
|
682
|
-
|
|
545
|
+
opts
|
|
683
546
|
end
|
|
684
547
|
end
|
|
685
548
|
|
|
686
549
|
def append_editable(target: @session)
|
|
687
|
-
return if requirements?
|
|
550
|
+
return if requirements?
|
|
688
551
|
|
|
689
552
|
if (val = option('editable', 'e', target: target, ignore: false))
|
|
690
|
-
|
|
553
|
+
session_delete('e', 'editable', target: target)
|
|
691
554
|
case val
|
|
692
555
|
when '0', 'false'
|
|
693
|
-
return
|
|
556
|
+
return
|
|
694
557
|
else
|
|
695
|
-
val =
|
|
558
|
+
val = path + val
|
|
696
559
|
end
|
|
697
|
-
elsif session_arg?('e', 'editable', target: target) || !
|
|
560
|
+
elsif session_arg?('e', 'editable', target: target) || !(val = editable)
|
|
698
561
|
return
|
|
699
|
-
else
|
|
700
|
-
val = editable
|
|
701
562
|
end
|
|
702
|
-
target <<
|
|
563
|
+
target << quote_option('e', val)
|
|
703
564
|
end
|
|
704
565
|
|
|
705
566
|
def append_global(target: @session)
|
|
706
|
-
|
|
567
|
+
option('cache-dir', target: target) do |val|
|
|
707
568
|
target << case val
|
|
708
569
|
when '0', 'false'
|
|
709
570
|
'--no-cache-dir'
|
|
710
571
|
else
|
|
711
|
-
quote_option('cache-dir',
|
|
572
|
+
quote_option('cache-dir', path + val)
|
|
712
573
|
end
|
|
713
574
|
end
|
|
714
|
-
|
|
715
|
-
|
|
575
|
+
option('proxy', target: target) { |val| target << shell_option('proxy', val) }
|
|
576
|
+
option('python', target: target) { |val| target << quote_option('python', path + val) }
|
|
716
577
|
append_nocolor(target: target)
|
|
717
578
|
end
|
|
718
579
|
|
|
719
|
-
def
|
|
720
|
-
@
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
unless (ret = (@pyproject ||= {})[table])
|
|
727
|
-
ret = []
|
|
728
|
-
start = /^\s*\[#{Regexp.escape(table)}\]\s*$/
|
|
729
|
-
ch = nil
|
|
730
|
-
found = false
|
|
731
|
-
File.foreach(file) do |line|
|
|
732
|
-
if found
|
|
733
|
-
break if line.match?(/^\s*\[[\w.-]+\]\s*$/)
|
|
734
|
-
|
|
735
|
-
if ch
|
|
736
|
-
val = line.rstrip
|
|
737
|
-
case ch
|
|
738
|
-
when '}', ']'
|
|
739
|
-
ch = nil if val.end_with?(ch)
|
|
740
|
-
val = "\n#{val}"
|
|
741
|
-
else
|
|
742
|
-
if val.chomp!(ch)
|
|
743
|
-
ch = nil
|
|
744
|
-
else
|
|
745
|
-
val = line
|
|
746
|
-
end
|
|
747
|
-
end
|
|
748
|
-
ret.last[1] += val
|
|
749
|
-
elsif (data = line.match(/^\s*(\S+)\s*=\s*([+-]?[\d.]+|true|false|("""|'''|["'\[{])(.*?))\s*$/))
|
|
750
|
-
if (val = data[4])
|
|
751
|
-
case (ch = data[3])
|
|
752
|
-
when '{', '['
|
|
753
|
-
val = "#{ch}#{val}"
|
|
754
|
-
ch = ch == '{' ? '}' : ']'
|
|
755
|
-
ch = nil if val.end_with?(ch)
|
|
756
|
-
else
|
|
757
|
-
if val.chomp!(ch)
|
|
758
|
-
ch = nil
|
|
759
|
-
elsif ch.size == 1
|
|
760
|
-
next
|
|
580
|
+
def editable_set(val)
|
|
581
|
+
@editable = case val
|
|
582
|
+
when '.', Pathname
|
|
583
|
+
val
|
|
584
|
+
when String
|
|
585
|
+
Pathname.new(editable)
|
|
761
586
|
end
|
|
762
|
-
end
|
|
763
|
-
else
|
|
764
|
-
val = case (val = data[2])
|
|
765
|
-
when 'true'
|
|
766
|
-
true
|
|
767
|
-
when 'false'
|
|
768
|
-
false
|
|
769
|
-
else
|
|
770
|
-
val.include?('.') ? val.to_f : val.to_i
|
|
771
|
-
end
|
|
772
|
-
end
|
|
773
|
-
ret << [data[1], val]
|
|
774
|
-
end
|
|
775
|
-
else
|
|
776
|
-
found = line.match?(start)
|
|
777
|
-
end
|
|
778
|
-
end
|
|
779
|
-
@pyproject[table] = ret
|
|
780
|
-
end
|
|
781
|
-
return ret.find { |val| val.first == key }&.last if key
|
|
782
|
-
|
|
783
|
-
ret
|
|
784
|
-
end
|
|
785
|
-
|
|
786
|
-
def pyprojectfile
|
|
787
|
-
return unless (ret = basepath(DEP_PYTHON[2])).exist?
|
|
788
|
-
|
|
789
|
-
ret
|
|
790
587
|
end
|
|
791
588
|
|
|
792
589
|
def singleopt(flag = nil)
|
|
793
590
|
case flag
|
|
794
591
|
when :python
|
|
795
|
-
/\A(?:v+|q+|b
|
|
592
|
+
/\A(?:v+|q+|b+)\z/
|
|
796
593
|
when :twine
|
|
797
594
|
nil
|
|
798
595
|
else
|
|
@@ -829,23 +626,13 @@ module Squared
|
|
|
829
626
|
@venv&.join(workspace.windows? ? 'Scripts' : 'bin')
|
|
830
627
|
end
|
|
831
628
|
|
|
832
|
-
def editable_set(val)
|
|
833
|
-
@editable = case val
|
|
834
|
-
when '.', Pathname
|
|
835
|
-
val
|
|
836
|
-
when String
|
|
837
|
-
Pathname.new(val) unless val.empty?
|
|
838
|
-
end
|
|
839
|
-
end
|
|
840
|
-
|
|
841
629
|
def venv_set(val)
|
|
842
|
-
return unless val
|
|
843
|
-
|
|
844
630
|
if val.is_a?(Array)
|
|
845
631
|
val, *opts = val
|
|
846
632
|
@venvopts = opts
|
|
847
633
|
end
|
|
848
|
-
@venv =
|
|
634
|
+
@venv = Pathname.new(val)
|
|
635
|
+
@venv = @path + @venv unless @venv.absolute?
|
|
849
636
|
if projectpath?(@venv)
|
|
850
637
|
if @venv.exist?
|
|
851
638
|
log.debug "venv found: #{@venv}"
|
|
@@ -863,8 +650,8 @@ module Squared
|
|
|
863
650
|
return if !venv || (venvbin.directory? && !venvbin.empty?)
|
|
864
651
|
|
|
865
652
|
puts log_message(Logger::INFO, venv, subject: 'venv', hint: 'init')
|
|
866
|
-
|
|
867
|
-
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)
|
|
868
655
|
puts log_message(Logger::INFO, venv, subject: 'venv', hint: 'created')
|
|
869
656
|
end
|
|
870
657
|
|
|
@@ -873,28 +660,11 @@ module Squared
|
|
|
873
660
|
op = OptionPartition.new(opts, OPT_PYTHON[:venv], cmd, project: self)
|
|
874
661
|
op.append(dir, delim: true)
|
|
875
662
|
.clear(pass: false)
|
|
876
|
-
status = op.arg?(/\A-v+\z
|
|
663
|
+
status = op.arg?(/\A-v+\z/, 'verbose')
|
|
877
664
|
run(op, env, exception: true, banner: banner)
|
|
878
|
-
if poetry?
|
|
879
|
-
install(:upgrade, ['poetry'])
|
|
880
|
-
elsif setuptools?
|
|
881
|
-
install(:upgrade, ['setuptools', 'wheel'])
|
|
882
|
-
end
|
|
883
665
|
puts(dir.directory? ? "Success: #{dir}" : 'Failed') if banner && !status
|
|
884
666
|
end
|
|
885
667
|
|
|
886
|
-
def installable?
|
|
887
|
-
setuptools? || !!pyprojectfile
|
|
888
|
-
end
|
|
889
|
-
|
|
890
|
-
def setuptools?
|
|
891
|
-
dependtype == 2 || dependtype == 4
|
|
892
|
-
end
|
|
893
|
-
|
|
894
|
-
def poetry?
|
|
895
|
-
dependtype == 1
|
|
896
|
-
end
|
|
897
|
-
|
|
898
668
|
def requirements?
|
|
899
669
|
dependtype == 5
|
|
900
670
|
end
|