squared 0.6.5 → 0.6.7

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.
@@ -246,11 +246,11 @@ module Squared
246
246
  if op.empty?
247
247
  op << package
248
248
  if (args = readline('Enter arguments', force: false))
249
- op << '--' unless pnpm?
249
+ op.delim unless pnpm?
250
250
  op << args
251
251
  end
252
252
  else
253
- op << '--' unless pnpm?
253
+ op.delim unless pnpm?
254
254
  op << package << op.join(' ')
255
255
  end
256
256
  else
@@ -426,7 +426,7 @@ module Squared
426
426
  Open3.capture2e(session_output('npm', 'pack --dry-run --no-color', npmname).to_s)
427
427
  .first
428
428
  .scan(/^npm notice \d+(?:\.\d+)?[a-z]+ (.+)$/i)
429
- .map { |item| Pathname.new(item.first) }
429
+ .map! { |item| Pathname.new(item.first) }
430
430
  .select(&:exist?)
431
431
  end.concat(Array(files))
432
432
  packed = true
@@ -507,22 +507,23 @@ module Squared
507
507
  end
508
508
  save, exact, omit = save if save.is_a?(Array)
509
509
  ws = env('NODE_WORKSPACES', equals: '0')
510
- ci = -> { option('ci') }
511
- is = -> { option('ignore-scripts') }
512
- om = lambda do
513
- next unless omit
514
-
515
- save = case save
516
- when 'peer'
517
- 'optional'
518
- when 'optional'
519
- 'dev'
520
- when 'dev'
521
- 'prod'
522
- end
510
+ om = lambda do |cmd|
511
+ if omit
512
+ save = case save
513
+ when 'peer'
514
+ 'optional'
515
+ when 'optional'
516
+ 'dev'
517
+ when 'dev'
518
+ 'prod'
519
+ end
520
+ end
521
+ return unless save && save != 'bundle'
522
+
523
+ cmd << "--#{save}"
523
524
  end
524
525
  rm = lambda do |target|
525
- next if remove.empty?
526
+ return if remove.empty?
526
527
 
527
528
  run(target.temp(*remove).sub!(/ (?:add|install) /, ' remove '), from: :remove, sync: sync)
528
529
  end
@@ -531,15 +532,15 @@ module Squared
531
532
  append_loglevel
532
533
  if yarn == 1
533
534
  cmd << '--ignore-engines' unless option('ignore-engines', equals: '0')
534
- cmd << '--ignore-scripts' if is.call
535
+ cmd << '--ignore-scripts' if option('ignore-scripts')
535
536
  cmd << '--force' if option('force')
536
537
  else
537
- cmd << '--mode=skip-build' if is.call
538
+ cmd << '--mode=skip-build' if option('ignore-scripts')
538
539
  cmd << '--check-cache' if !flag && option('force')
539
540
  end
540
541
  if nolockfile?('yarn')
541
542
  cmd << '--no-lockfile'
542
- elsif ci.call
543
+ elsif option('ci')
543
544
  if yarn == 1
544
545
  cmd << '--frozen-lockfile'
545
546
  elsif !flag
@@ -549,8 +550,7 @@ module Squared
549
550
  if add
550
551
  cmd << '-W' if yarn == 1 && !option('w', 'ignore-workspace-root-check', equals: '0')
551
552
  rm.call(cmd)
552
- om.call
553
- cmd << "--#{save}" if save && save != 'bundle'
553
+ om.call(cmd)
554
554
  cmd << '--exact' if exact
555
555
  end
556
556
  elsif pnpm?
@@ -558,8 +558,7 @@ module Squared
558
558
  append_nocolor
559
559
  append_loglevel
560
560
  if add
561
- om.call
562
- cmd << "--save-#{save}" if save && save != 'bundle'
561
+ om.call(cmd)
563
562
  rm.call(cmd)
564
563
  cmd << '--save-exact' if exact
565
564
  option('allow-build') { |val| cmd << quote_option('allow-build', val) }
@@ -574,17 +573,18 @@ module Squared
574
573
  '--force'
575
574
  elsif nolockfile?('pnpm')
576
575
  '--no-lockfile'
577
- elsif ci.call
576
+ elsif option('ci')
578
577
  '--frozen-lockfile'
579
578
  end
580
- cmd << '--ignore-scripts' if is.call
579
+ cmd << '--ignore-scripts' if option('ignore-scripts')
581
580
  else
582
- cmd = session('npm', (ci = ci.call) ? 'ci' : 'install')
581
+ cmd = session 'npm'
582
+ cmd << (ci = option('ci') ? 'ci' : 'install')
583
583
  cmd << '--workspaces=false' if ws
584
584
  append_nocolor
585
585
  append_loglevel
586
586
  if omit
587
- cmd << "--omit=#{save}"
587
+ cmd << "--omit=#{save || omit}"
588
588
  save = nil
589
589
  end
590
590
  unless ci
@@ -597,7 +597,7 @@ module Squared
597
597
  end
598
598
  end
599
599
  cmd << '--package-lock=false' << 'save=false' if nolockfile?('npm')
600
- cmd << '--ignore-scripts' if is.call
600
+ cmd << '--ignore-scripts' if option('ignore-scripts')
601
601
  end
602
602
  if add
603
603
  return if packages.empty?
@@ -710,7 +710,7 @@ module Squared
710
710
  width = ->(a, i) { a.map { |aa| aa[i] }.max_by(&:size).size }
711
711
  pad = ->(val, ord) { val.succ.to_s.rjust([ord.size.to_s.size, 2].max) }
712
712
  footer = lambda do |val, size|
713
- next unless verbose
713
+ return unless verbose
714
714
 
715
715
  msg, hint = if modified == -1
716
716
  ['Packages were updated', 'more possible']
@@ -814,6 +814,7 @@ module Squared
814
814
  else
815
815
  footer.call(0, found.size)
816
816
  end
817
+ printsucc
817
818
  commit(:add, [dependname], pass: true)
818
819
  end
819
820
  end
@@ -961,7 +962,7 @@ module Squared
961
962
  case flag
962
963
  when :install, :update
963
964
  opts.unshift('package-lock=false', 'save=false') if nolockfile?('npm')
964
- spec = 0
965
+ spec = flag == :install ? 0 : 2
965
966
  when :add
966
967
  spec = 1
967
968
  flag = :install
@@ -1000,17 +1001,17 @@ module Squared
1000
1001
  end
1001
1002
  append_loglevel
1002
1003
  case spec
1003
- when 0, 1
1004
+ when Numeric
1004
1005
  op.each do |opt|
1005
1006
  if opt =~ op.values
1006
1007
  case $1
1007
1008
  when 'w', 'workspace'
1008
1009
  op << quotepath($1, $2)
1009
1010
  end
1010
- elsif opt.include?('=') || opt.start_with?('-')
1011
+ elsif opt.match?(/^-|=/)
1011
1012
  op.errors << opt
1012
1013
  else
1013
- op.found << opt
1014
+ op.found << (spec == 2 && (n = opt.index('@')) ? opt[0, n] : opt)
1014
1015
  end
1015
1016
  end
1016
1017
  op.swap
@@ -1112,7 +1113,7 @@ module Squared
1112
1113
  print_run(cmd, banner, **kwargs)
1113
1114
  session 'npx', cmd
1114
1115
  start = time_epoch if kwargs.fetch(:verbose, verbose? && !stdin?)
1115
- run(sync: sync, banner: banner, from: from).tap do |ret|
1116
+ run(sync: sync, banner: banner, exception: kwargs.fetch(:exception, exception), from: from).tap do |ret|
1116
1117
  next unless success?(ret, banner, start.nil?) && start
1117
1118
 
1118
1119
  print_status(name, subject: 'tsc', start: start, from: :completed)
@@ -1326,7 +1327,7 @@ module Squared
1326
1327
 
1327
1328
  def remove_modules(prefix = dependbin)
1328
1329
  modules = basepath 'node_modules'
1329
- return false unless modules.directory? && (option('Y', prefix: prefix) || confirm_basic('Remove?', modules))
1330
+ return false unless modules.directory? && (option('y', prefix: prefix) || confirm_basic('Remove?', modules))
1330
1331
 
1331
1332
  modules.rmtree
1332
1333
  rescue Timeout::Error => e
@@ -1373,7 +1374,11 @@ module Squared
1373
1374
  end
1374
1375
 
1375
1376
  def append_platform(target: @session)
1376
- %w[cpu os libc].each { |name| option(name) { |val| target << basic_option(name, val) } }
1377
+ %w[cpu os libc].each do |name|
1378
+ next unless (val = option(name))
1379
+
1380
+ target << basic_option(name, val)
1381
+ end
1377
1382
  end
1378
1383
 
1379
1384
  def quotepath(name, val)
@@ -7,9 +7,9 @@ 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 v|verbose w|wheel C|config-setting=q installer=b
12
- o|outdir=p].freeze,
10
+ common: %w[b=+ B d E h i I O P q=+ s S u v=+ V=+ x c=q m=b W=b X=q check-hash-based-pycs=b].freeze,
11
+ build: %w[C=bm n|no-isolation s|sdist x|skip-dependency-check v|verbose w|wheel config-json=q config-setting=q
12
+ installer=b 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
15
15
  }.freeze
@@ -68,6 +68,7 @@ module Squared
68
68
  sign-with=b u|username=q].freeze
69
69
  }.freeze
70
70
  PASS_PYTHON = {
71
+ python: %w[c v V].freeze,
71
72
  pip: {
72
73
  debug: %w[platform].freeze,
73
74
  install: %w[C config-settings c constraint extra-index-url no-binary only-binary platform
@@ -100,7 +101,7 @@ module Squared
100
101
 
101
102
  attr_reader :venv, :editable
102
103
 
103
- def initialize(*, editable: '.', verbose: nil, asdf: 'python', **kwargs)
104
+ def initialize(*, editable: '.', asdf: 'python', **kwargs)
104
105
  super
105
106
  if @pass.include?(Python.ref)
106
107
  initialize_ref Python.ref
@@ -178,7 +179,7 @@ module Squared
178
179
  indexerror n, list
179
180
  else
180
181
  found |= 2
181
- log.warn "run script #{n} of #{list.size} (out of range)"
182
+ log.warn "run script #{n} of #{list.size}".subhint('out of range')
182
183
  end
183
184
  else
184
185
  case i
@@ -191,18 +192,18 @@ module Squared
191
192
  else
192
193
  raise_error "script: #{val}" if exception
193
194
  found |= 2
194
- log.warn "run script \"#{val}\" (not indexed)"
195
+ log.warn "run script \"#{val}\"".subhint('not indexed')
195
196
  end
196
197
  end
197
198
  end
198
199
  end
199
200
  break
200
201
  end
201
- unless found.anybits?(1)
202
- puts log_message(found == 0 ? Logger::INFO : Logger.WARN,
203
- "no scripts #{found == 0 ? 'found' : 'executed'}",
204
- subject: name, hint: pyprojectfile)
205
- end
202
+ next if found.anybits?(1)
203
+
204
+ puts log_message(found == 0 ? Logger::INFO : Logger.WARN,
205
+ "no scripts #{found == 0 ? 'found' : 'executed'}",
206
+ subject: name, hint: pyprojectfile)
206
207
  end
207
208
  when 'exec'
208
209
  format_desc action, nil, ':|command,args*'
@@ -234,11 +235,12 @@ module Squared
234
235
  when :remove
235
236
  next unless projectpath?(venv)
236
237
 
237
- format_desc action, flag, 'c/reate?,d/epend?'
238
+ format_desc action, flag, 'c/reate?,d/epend?,opts*'
238
239
  task flag do |_, args|
240
+ args = args.to_a
239
241
  rm_rf(venv, verbose: true)
240
- venv_init if has_value?(args = args.to_a, 'c', 'create')
241
- depend if has_value?(args, 'd', 'depend')
242
+ venv_init if has_value!(args, 'c', 'create')
243
+ depend :force, args if has_value!(args, 'd', 'depend')
242
244
  end
243
245
  when :exec
244
246
  format_desc action, flag, 'command,args*'
@@ -286,11 +288,11 @@ module Squared
286
288
  pip(flag, opts: args.to_a, banner: true)
287
289
  end
288
290
  when :reinstall
289
- if venv && projectpath?(venv)
290
- format_desc action, flag
291
- task flag do
292
- ns['venv:remove'].invoke('depend')
293
- end
291
+ next unless venv && projectpath?(venv)
292
+
293
+ format_desc action, flag
294
+ task flag do
295
+ ns['venv:remove'].invoke('depend')
294
296
  end
295
297
  end
296
298
  when 'install'
@@ -309,7 +311,7 @@ module Squared
309
311
  install flag, (case args.strategy
310
312
  when 'eager'
311
313
  'eager'
312
- when /(?:\Aonly-if|needed\z)/
314
+ when /^only-if|needed$/
313
315
  'only-if-needed'
314
316
  end.yield_self do |val|
315
317
  if val
@@ -342,7 +344,7 @@ module Squared
342
344
  when :poetry then 'output?'
343
345
  when :pdm then 'dest?'
344
346
  when :hatch then 'location?'
345
- else 'srcdir?'
347
+ else 'outdir?,srcdir?'
346
348
  end)
347
349
  task flag do |_, args|
348
350
  build! flag, args.to_a
@@ -451,11 +453,10 @@ module Squared
451
453
  buffer = []
452
454
  out = ->(val) { sync ? puts(val) : buffer << val }
453
455
  if workspace.windows?
454
- (venv ? command(runenv, cmd) : `#{cmd}`).lines
456
+ (venv ? command(runenv, cmd) : `#{cmd}`).lines(chomp: true)
455
457
  else
456
- IO.popen(runenv || {}, cmd)
458
+ IO.popen(runenv || {}, cmd).readlines(chomp: true)
457
459
  end.each do |line|
458
- line.chomp!
459
460
  next if line.match?(/^[ -]+$/)
460
461
 
461
462
  if start > 0
@@ -516,34 +517,33 @@ module Squared
516
517
  puts buffer
517
518
  end
518
519
  if found > 0
519
- if se
520
- choice('Select a package', items.map(&:first),
521
- multiple: true, force: false, index: true, border: true).map! { |n| items[n.pred].last }
522
- elsif ia
523
- items.map(&:last)
524
- else
525
- case flag
526
- when :major
527
- major + minor + patch
528
- when :minor
529
- minor + patch
520
+ items = if se
521
+ choice('Select a package', items.map(&:first),
522
+ multiple: true, force: false, index: true, border: true).map! { |n| items[n.pred].last }
523
+ elsif ia
524
+ items.map(&:last)
525
+ else
526
+ case flag
527
+ when :major
528
+ major + minor + patch
529
+ when :minor
530
+ minor + patch
531
+ else
532
+ patch
533
+ end
534
+ end
535
+ if up && !items.empty?
536
+ base = %w[eager no-deps]
537
+ base << 'user' unless venv
538
+ opts = (base & opts).map! { |val| val == 'eager' ? "upgrade-strategy=#{val}" : val }
539
+ if dryrun
540
+ opts.map! { |val| fill_option(val) }
541
+ print_run pip_output('install --upgrade', *opts, *items.quote!), false
530
542
  else
531
- patch
532
- end
533
- end.tap do |packages|
534
- if up && !packages.empty?
535
- base = %w[eager no-deps]
536
- base << 'user' unless venv
537
- opts = (base & opts).map! { |val| val == 'eager' ? "upgrade-strategy=#{val}" : val }
538
- if dryrun
539
- opts.map! { |val| fill_option(val) }
540
- print_run pip_output('install --upgrade', *opts, *packages.quote!), false
541
- else
542
- install(:upgrade, opts, packages: packages, banner: false)
543
- end
543
+ install(:upgrade, opts, packages: items, banner: false)
544
544
  end
545
- print_status(major.size, minor.size, patch.size, from: :outdated)
546
545
  end
546
+ print_status(major.size, minor.size, patch.size, from: :outdated)
547
547
  elsif start == 0 || hide
548
548
  puts 'No updates were found'
549
549
  end
@@ -582,36 +582,28 @@ module Squared
582
582
  cmd, opts = python_session('-m build', opts: opts)
583
583
  OPT_PYTHON[:build]
584
584
  end
585
- srcdir = nil
586
585
  op = OptionPartition.new(opts, list, cmd, project: self, single: singleopt(flag))
587
- op.each do |opt|
588
- if !srcdir && exist?(opt.chomp('*')) && projectpath?(opt.chomp('*'))
589
- srcdir = opt
590
- else
591
- op.found << opt
592
- end
593
- end
594
- op.swap
595
586
  case flag
596
- when :poetry, :pdm
597
- if srcdir
598
- args = flag == :pdm ? %w[d dest] : %w[o output]
599
- if op.arg?(*args)
600
- op.push(srcdir)
601
- else
602
- op << quote_option(args.last, basepath(srcdir))
603
- end
604
- srcdir = nil
605
- end
606
587
  when :hatch
607
- if ENV['HATCH_BUILD_LOCATION']
608
- srcdir = nil
609
- else
610
- srcdir ||= path
588
+ if !ENV['HATCH_BUILD_LOCATION'] && (outdir ||= op.shift)
589
+ op.add_path(outdir)
611
590
  end
612
591
  op << basic_option('p', project) unless ENV['HATCH_PROJECT'] || op.arg?('p', 'project')
592
+ else
593
+ unless op.empty?
594
+ args = case flag
595
+ when :poetry
596
+ %w[o output]
597
+ when :pdm
598
+ %w[d dest]
599
+ else
600
+ srcdir = true
601
+ %w[o outdir]
602
+ end
603
+ op << quote_option(args.last, basepath(op.shift)) unless op.arg?(*args)
604
+ end
613
605
  end
614
- op.add_path(srcdir) if srcdir
606
+ op.exist?(add: true, first: true) if srcdir
615
607
  op.clear
616
608
  run(from: :"#{flag}:build")
617
609
  end
@@ -634,7 +626,7 @@ module Squared
634
626
  op = OptionPartition.new(opts, list, @session, project: self, single: singleopt(flag))
635
627
  dist = lambda do
636
628
  dir = basepath 'dist'
637
- next dir if dir.directory? && !dir.empty?
629
+ return dir if dir.directory? && !dir.empty?
638
630
 
639
631
  if dir.exist?
640
632
  raise_error 'no source to publish', hint: dir
@@ -663,6 +655,27 @@ module Squared
663
655
  run(from: :"#{flag}:publish", interactive: ['Publish', 'N', project])
664
656
  end
665
657
 
658
+ def python(*args, sync: true, banner: verbose?, with: nil, pass: PASS_PYTHON[:python], **kwargs)
659
+ op = OptionPartition.new(session_opts(with, args: args, kwargs: kwargs, pass: pass), OPT_PYTHON[:common],
660
+ session('python', path: venv.nil?),
661
+ project: self, multiple: [/^-c/], single: singleopt(:python), args: true,
662
+ stdin: true)
663
+ op.concat(args)
664
+ if op.include?('-')
665
+ op.exist?(add: true)
666
+ else
667
+ op.append_any { |val| OptionPartition.parse_arg!('c', val) }
668
+ if op.arg?('c')
669
+ op.clear
670
+ else
671
+ op.exist?(add: true, first: true) unless op.arg?('m')
672
+ op.append(escape: kwargs.fetch(:escape, false), quote: kwargs.fetch(:quote, false))
673
+ end
674
+ end
675
+ print_run(op, banner, **kwargs)
676
+ run(sync: sync, banner: banner, exception: kwargs.fetch(:exception, exception), from: :python)
677
+ end
678
+
666
679
  def pip(flag, *args, sync: true, banner: verbose?, with: nil, pass: nil, **kwargs)
667
680
  flag = flag.to_sym
668
681
  pass = PASS_PYTHON[:pip].fetch(pip_install?(flag) ? :install : flag, []) + %w[v verbose] if pass.nil?
@@ -736,7 +749,8 @@ module Squared
736
749
  op.clear
737
750
  end
738
751
  print_run(op, banner, **kwargs)
739
- run(sync: sync, banner: banner, from: :"pip:#{flag}").yield_self { |val| ret || val }
752
+ run(sync: sync, banner: banner, exception: kwargs.fetch(:exception, exception), from: :"pip:#{flag}")
753
+ .yield_self { |val| ret || val }
740
754
  end
741
755
 
742
756
  def variable_set(key, *args, **, &blk)
@@ -785,14 +799,14 @@ module Squared
785
799
  def python_session(*cmd, opts: nil)
786
800
  return session('python', *preopts(quiet: false), *cmd, path: venv.nil?) unless opts
787
801
 
788
- op = OptionPartition.new(opts, OPT_PYTHON[:common], project: self, single: /\A(?:v+|OO)\z/)
802
+ op = OptionPartition.new(opts, OPT_PYTHON[:common], project: self, single: singleopt(:python))
789
803
  [session('python', *op.to_a, *cmd, path: venv.nil?), op.extras]
790
804
  end
791
805
 
792
806
  def poetry_session(*cmd)
793
- session('poetry', *cmd, *preopts).tap do |ret|
794
- option('project', ignore: false) { |val| ret << quote_option('project', basepath(val)) }
795
- end
807
+ ret = session('poetry', *cmd, *preopts)
808
+ option('project', ignore: false) { |val| ret << quote_option('project', basepath(val)) }
809
+ ret
796
810
  end
797
811
 
798
812
  def pdm_session(*cmd, opts: nil)
@@ -859,7 +873,7 @@ module Squared
859
873
  def append_editable(target: @session)
860
874
  return if requirements? && editable == '.'
861
875
 
862
- if (val = option('editable', 'e', target: target, ignore: false))
876
+ if (val = option('e', 'editable', target: target, ignore: false))
863
877
  OptionPartition.delete_key(target, 'e', 'editable')
864
878
  case val
865
879
  when '0', 'false'
@@ -883,7 +897,7 @@ module Squared
883
897
  quote_option 'cache-dir', basepath(val)
884
898
  end
885
899
  end,
886
- option('proxy', target: target) { |val| shell_option('proxy', val) },
900
+ option('proxy', target: target) { |val| quote_option('proxy', val) },
887
901
  option('python', target: target) { |val| quote_option('python', basepath(val)) }
888
902
  ])
889
903
  append_nocolor(target: target)
@@ -957,15 +971,14 @@ module Squared
957
971
  end
958
972
 
959
973
  def pyprojectfile
960
- return @pyprojectfile || nil unless @pyprojectfile.nil?
961
-
962
- @pyprojectfile = (file = basepath(DEP_PYTHON[2])).exist? ? file : false
974
+ @pyprojectfile = basepath!(DEP_PYTHON[2]) || false if @pyprojectfile.nil?
975
+ @pyprojectfile || nil
963
976
  end
964
977
 
965
978
  def singleopt(flag = nil)
966
979
  case flag
967
980
  when :python
968
- /\A(?:v+|q+|b+)\z/
981
+ /\A(?:v+|q+|b+|V+|O+)\z/
969
982
  when :pdm
970
983
  /\Av+\z/
971
984
  when :twine
@@ -976,14 +989,14 @@ module Squared
976
989
  end
977
990
 
978
991
  def preopts(quiet: true)
979
- [].tap do |ret|
980
- case verbose
981
- when FalseClass
982
- ret << '--quiet' if quiet
983
- when Numeric
984
- ret << "-#{'v' * verbose}" if verbose > 0
985
- end
992
+ ret = []
993
+ case verbose
994
+ when FalseClass
995
+ ret << '--quiet' if quiet
996
+ when Numeric
997
+ ret << "-#{'v' * verbose}" if verbose > 0
986
998
  end
999
+ ret
987
1000
  end
988
1001
 
989
1002
  def variables
@@ -1016,20 +1029,21 @@ module Squared
1016
1029
  def venv_set(val)
1017
1030
  return unless val
1018
1031
 
1032
+ write = ->(level, hint) { log.add(level, "venv: #{@venv}".subhint(hint)) }
1019
1033
  if val.is_a?(Array)
1020
1034
  val, *opts = val
1021
1035
  @venvopts = opts
1022
1036
  end
1023
- @venv = basepath(val)
1037
+ @venv = basepath val
1024
1038
  if projectpath?(@venv)
1025
1039
  if @venv.exist?
1026
- log.debug "venv found: #{@venv}"
1027
- elsif @path.directory? && !@path.empty?
1040
+ write.call(Logger::DEBUG, 'found')
1041
+ elsif path.directory? && !path.empty?
1028
1042
  @venv.mkpath
1029
- log.info "venv mkdir: #{@venv}"
1043
+ write.call(Logger::INFO, 'mkdir')
1030
1044
  end
1031
1045
  elsif !@venv.directory?
1032
- log.warn "venv invalid: #{@venv}"
1046
+ write.call(Logger::WARN, 'invalid')
1033
1047
  @venv = nil
1034
1048
  end
1035
1049
  end
@@ -1037,20 +1051,21 @@ module Squared
1037
1051
  def venv_init
1038
1052
  return if !venv || (venvbin.directory? && !venvbin.empty?)
1039
1053
 
1040
- puts log_message(venv, subject: 'venv', hint: 'init')
1054
+ puts log_message(venv, subject: 'venv', hint: 'init') unless silent?
1041
1055
  opts = @venvopts&.map { |val| OptionPartition.strip(val) }&.flatten
1042
1056
  venv_create(venv, opts || ["prompt=#{name}", 'upgrade-deps'], env: false, banner: false)
1043
- puts log_message(venv, subject: 'venv', hint: 'created')
1057
+ puts log_message(venv, subject: 'venv', hint: 'created') unless silent?
1044
1058
  end
1045
1059
 
1046
- def venv_create(dir, opts = [], env: nil, banner: true)
1060
+ def venv_create(dir, opts = [], env: nil, banner: banner?)
1047
1061
  cmd, opts = python_session('-m venv', opts: opts)
1048
1062
  op = OptionPartition.new(opts, OPT_PYTHON[:venv], cmd, project: self)
1049
1063
  status = op.append(dir, delim: true)
1050
1064
  .clear(pass: false)
1051
1065
  .arg?(/\A-v+\z/)
1052
- run(op, env, exception: true, banner: banner)
1053
- puts(dir.directory? ? "Success: #{dir}" : 'Failed') if banner && !status
1066
+ success?(run(op, env, exception: true, banner: banner), banner, !status) do |ret|
1067
+ puts(ret && dir.directory? ? "Success: #{dir}" : 'Failed')
1068
+ end
1054
1069
  end
1055
1070
 
1056
1071
  def pip_install?(flag)
@@ -1071,7 +1086,7 @@ module Squared
1071
1086
  end
1072
1087
 
1073
1088
  def installable?
1074
- setuptools? || !pyprojectfile.nil?
1089
+ setuptools? || !!pyprojectfile
1075
1090
  end
1076
1091
 
1077
1092
  def setuptools?