squared 0.2.9 → 0.3.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 +55 -83
- data/README.ruby.md +150 -68
- data/lib/squared/common/base.rb +3 -1
- data/lib/squared/common/class.rb +27 -2
- data/lib/squared/common/format.rb +11 -11
- data/lib/squared/common/shell.rb +10 -12
- data/lib/squared/common/utils.rb +24 -13
- data/lib/squared/config.rb +4 -3
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +54 -19
- data/lib/squared/workspace/project/base.rb +350 -157
- data/lib/squared/workspace/project/git.rb +514 -316
- data/lib/squared/workspace/project/node.rb +248 -107
- data/lib/squared/workspace/project/python.rb +101 -78
- data/lib/squared/workspace/project/ruby.rb +175 -163
- data/lib/squared/workspace/repo.rb +7 -4
- data/lib/squared/workspace/series.rb +10 -4
- data/squared.gemspec +0 -1
- metadata +3 -17
@@ -5,18 +5,21 @@ module Squared
|
|
5
5
|
module Project
|
6
6
|
class Python < Git
|
7
7
|
REQUIREMENTS = %w[requirements.txt pyproject.toml].freeze
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
8
|
+
SETUPTOOLS = %w[setup.py pyproject.toml].freeze
|
9
|
+
DIR_PYTHON = (REQUIREMENTS + SETUPTOOLS).freeze
|
10
|
+
OPT_PIP = {
|
11
|
+
common: %w[debug disable-pip-version-check isolated no-cache-dir no-color no-input no-python-version-warning
|
12
|
+
q|quiet require-virtualenv v|verbose cache-dir=p cert=p client-cert=p exists-action=b log=p
|
13
|
+
proxy=q python=e retries=i timeout=i trusted-host=e use-deprecated=e use-feature=e].freeze,
|
14
|
+
install: %w[break-system-packages check-build-dependencies compile dry-run force-reinstall I|ignore-installed
|
15
|
+
ignore-requires-python no-build-isolation no-clean no-compile no-deps no-index no-warn-conflicts
|
16
|
+
no-warn-script-location pre prefer-binary require-hashes U|upgrade use-pep517 user abi=e
|
17
|
+
config-settings=q c|constraint=p e|editable=s? extra-index-url=q f|find-links=q global-option=q
|
18
|
+
implementation=b i|index-url=q no-binary=q only-binary=q platform=q prefix=p progress-bar=b
|
19
|
+
python-version=q report=p r|requirement=p root=p root-user-action=e src=p t|target=p
|
20
|
+
upgrade-strategy=b].freeze
|
21
|
+
}.freeze
|
22
|
+
private_constant :REQUIREMENTS, :SETUPTOOLS, :DIR_PYTHON, :OPT_PIP
|
20
23
|
|
21
24
|
class << self
|
22
25
|
def populate(*); end
|
@@ -37,7 +40,7 @@ module Squared
|
|
37
40
|
def config?(val)
|
38
41
|
return false unless (val = as_path(val))
|
39
42
|
|
40
|
-
|
43
|
+
DIR_PYTHON.any? { |file| val.join(file).exist? }
|
41
44
|
end
|
42
45
|
end
|
43
46
|
|
@@ -55,7 +58,7 @@ module Squared
|
|
55
58
|
end
|
56
59
|
|
57
60
|
@@tasks[ref] = {
|
58
|
-
'install' => %i[user upgrade
|
61
|
+
'install' => %i[user force upgrade target editable].freeze
|
59
62
|
}.freeze
|
60
63
|
|
61
64
|
def ref
|
@@ -74,23 +77,38 @@ module Squared
|
|
74
77
|
flags.each do |flag|
|
75
78
|
case action
|
76
79
|
when 'install'
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
80
|
+
format_desc(action, flag, 'opts*', before: case flag
|
81
|
+
when :target
|
82
|
+
'dir'
|
83
|
+
when :editable
|
84
|
+
'path/url?'
|
85
|
+
when :upgrade
|
86
|
+
'eager?,package+'
|
87
|
+
end)
|
85
88
|
case flag
|
86
|
-
when :
|
87
|
-
task flag
|
88
|
-
|
89
|
-
|
89
|
+
when :editable
|
90
|
+
task flag do |_, args|
|
91
|
+
install flag, args.to_a
|
92
|
+
end
|
93
|
+
when :upgrade
|
94
|
+
task flag, [:strategy] do |_, args|
|
95
|
+
case (strategy = args.strategy)
|
96
|
+
when 'eager', 'only-if-needed'
|
97
|
+
opts = args.extras
|
98
|
+
else
|
99
|
+
opts = args.to_a
|
100
|
+
strategy = nil
|
101
|
+
end
|
102
|
+
install(flag, opts, strategy: strategy)
|
103
|
+
end
|
104
|
+
when :target
|
105
|
+
task flag, [:dir] do |_, args|
|
106
|
+
dir = param_guard(action, flag, args: args, key: :dir)
|
107
|
+
depend(flag, args.extras, target: dir)
|
90
108
|
end
|
91
109
|
else
|
92
110
|
task flag do |_, args|
|
93
|
-
depend
|
111
|
+
depend flag, args.to_a
|
94
112
|
end
|
95
113
|
end
|
96
114
|
end
|
@@ -100,41 +118,46 @@ module Squared
|
|
100
118
|
end
|
101
119
|
end
|
102
120
|
|
103
|
-
def depend(flag = nil, sync: invoked_sync?('depend', flag),
|
121
|
+
def depend(flag = nil, opts = [], sync: invoked_sync?('depend', flag), target: nil, **)
|
104
122
|
if @depend && !flag
|
105
123
|
super
|
106
124
|
elsif outdated?
|
107
125
|
cmd = pip_session 'install'
|
108
126
|
case flag
|
109
127
|
when :user
|
110
|
-
cmd <<
|
111
|
-
when :
|
112
|
-
cmd << '
|
113
|
-
case param
|
114
|
-
when 'eager', 'only-if-needed'
|
115
|
-
cmd << basic_option('upgrade-strategy', param)
|
116
|
-
else
|
117
|
-
opts << param
|
118
|
-
end
|
128
|
+
cmd << "--#{flag}"
|
129
|
+
when :target
|
130
|
+
cmd << quote_option('target', basepath(target))
|
119
131
|
when :force
|
120
132
|
cmd << '--force-reinstall'
|
121
|
-
when :target
|
122
|
-
cmd << quote_option('target', basepath(param))
|
123
133
|
else
|
124
134
|
append_global
|
125
135
|
end
|
126
|
-
append_pip
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
cmd << '-r requirements.txt'
|
132
|
-
end
|
136
|
+
append_pip(flag, opts, from: :install) if flag
|
137
|
+
if dependtype == 1 && !session_arg?('e', 'editable')
|
138
|
+
cmd << '-r requirements.txt' unless session_arg?('r', 'requirement')
|
139
|
+
elsif !session_arg?('e', 'editable', value: true)
|
140
|
+
cmd << '.'
|
133
141
|
end
|
134
142
|
run(from: :depend, sync: sync)
|
135
143
|
end
|
136
144
|
end
|
137
145
|
|
146
|
+
def install(flag, opts, strategy: nil)
|
147
|
+
cmd = pip_session 'install'
|
148
|
+
out = append_pip(flag, opts, from: :install)
|
149
|
+
case flag
|
150
|
+
when :editable
|
151
|
+
cmd << '--editable' << (out.pop || '.')
|
152
|
+
option_clear out
|
153
|
+
when :upgrade
|
154
|
+
cmd << '--upgrade'
|
155
|
+
cmd << basic_option('upgrade-strategy', strategy) if strategy
|
156
|
+
append_value out
|
157
|
+
end
|
158
|
+
run(from: :install)
|
159
|
+
end
|
160
|
+
|
138
161
|
def outdated(*, sync: invoked_sync?('outdated'))
|
139
162
|
cmd = pip_session 'list', '--outdated'
|
140
163
|
append_global
|
@@ -241,56 +264,56 @@ module Squared
|
|
241
264
|
session('python', *cmd)
|
242
265
|
end
|
243
266
|
|
244
|
-
def append_pip(flag, opts, target: @session)
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
267
|
+
def append_pip(flag, opts, target: @session, from: nil)
|
268
|
+
append_nocolor(target: target)
|
269
|
+
return [] unless from && !opts.empty?
|
270
|
+
|
271
|
+
opts, pat = option_sanitize(opts, OPT_PIP[from] + OPT_PIP[:common], target: target)
|
249
272
|
out = []
|
250
|
-
|
251
|
-
append_global(target: target)
|
273
|
+
edit = nil
|
252
274
|
opts.each do |opt|
|
253
275
|
if opt =~ /^(v+|q+)$/
|
254
276
|
cmd << "-#{$1}"
|
255
277
|
elsif opt =~ pat
|
256
278
|
case $1
|
257
|
-
when 'root', 'prefix', 'src', 'cert', 'client-cert', 'cache-dir', 'log', 'report',
|
258
|
-
'r', 'requirement', 'c', 'constraint', 't', 'target'
|
259
|
-
target << quote_option($1, basepath($2))
|
260
279
|
when 'e', 'editable'
|
261
|
-
|
262
|
-
target << quote_option($1, val =~ %r{^[a-z]+(?:\+[a-z]+)?://}i ? val : basepath(val))
|
263
|
-
when 'proxy', 'config-settings', 'global-option', 'extra-index-url',
|
264
|
-
'f', 'find-links', 'i', 'index-url'
|
265
|
-
target << quote_option($1, $2)
|
266
|
-
when 'retries', 'timeout'
|
267
|
-
target << basic_option($1, $2) if $2.to_i > 0
|
268
|
-
else
|
269
|
-
target << shell_option($1, $2)
|
280
|
+
edit = $2
|
270
281
|
end
|
282
|
+
elsif flag == :editable && !edit
|
283
|
+
edit = opt
|
271
284
|
else
|
272
285
|
out << opt
|
273
286
|
end
|
274
287
|
end
|
275
|
-
if
|
276
|
-
|
288
|
+
if edit
|
289
|
+
edit = basepath(edit) unless %r{^[a-z]+(?:\+[a-z]+)?://}i.match?(edit)
|
290
|
+
if flag == :editable
|
291
|
+
out << edit
|
292
|
+
else
|
293
|
+
target << quote_option('editable', edit)
|
294
|
+
end
|
295
|
+
end
|
296
|
+
case flag
|
297
|
+
when :editable, :upgrade
|
298
|
+
out
|
277
299
|
else
|
278
300
|
option_clear(out, target: target)
|
301
|
+
[]
|
279
302
|
end
|
280
303
|
end
|
281
304
|
|
282
|
-
def append_global
|
283
|
-
if (val = option('cache-dir'
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
305
|
+
def append_global
|
306
|
+
if (val = option('cache-dir'))
|
307
|
+
cmd << case val
|
308
|
+
when '0', 'false'
|
309
|
+
'--no-cache-dir'
|
310
|
+
else
|
311
|
+
quote_option('cache-dir', basepath(val))
|
312
|
+
end
|
290
313
|
end
|
291
|
-
|
292
|
-
|
293
|
-
append_nocolor
|
314
|
+
cmd << shell_option('proxy', val) if (val = option('proxy'))
|
315
|
+
cmd << quote_option('python', basepath(val)) if (val = option('python'))
|
316
|
+
append_nocolor
|
294
317
|
end
|
295
318
|
end
|
296
319
|
|