squared 0.2.5 → 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 +51 -29
- 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 +4 -4
- data/lib/squared/common/shell.rb +8 -9
- data/lib/squared/common/utils.rb +23 -12
- data/lib/squared/config.rb +4 -3
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +52 -17
- data/lib/squared/workspace/project/base.rb +328 -127
- data/lib/squared/workspace/project/git.rb +507 -306
- data/lib/squared/workspace/project/node.rb +248 -107
- data/lib/squared/workspace/project/python.rb +89 -64
- data/lib/squared/workspace/project/ruby.rb +171 -155
- 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,39 +264,41 @@ module Squared
|
|
241
264
|
session('python', *cmd)
|
242
265
|
end
|
243
266
|
|
244
|
-
def append_pip(flag, opts, target: @session)
|
267
|
+
def append_pip(flag, opts, target: @session, from: nil)
|
245
268
|
append_nocolor(target: target)
|
246
|
-
return
|
269
|
+
return [] unless from && !opts.empty?
|
247
270
|
|
271
|
+
opts, pat = option_sanitize(opts, OPT_PIP[from] + OPT_PIP[:common], target: target)
|
248
272
|
out = []
|
249
|
-
|
273
|
+
edit = nil
|
250
274
|
opts.each do |opt|
|
251
275
|
if opt =~ /^(v+|q+)$/
|
252
276
|
cmd << "-#{$1}"
|
253
277
|
elsif opt =~ pat
|
254
278
|
case $1
|
255
|
-
when 'root', 'prefix', 'src', 'cert', 'client-cert', 'cache-dir', 'log', 'report',
|
256
|
-
'r', 'requirement', 'c', 'constraint', 't', 'target'
|
257
|
-
target << quote_option($1, basepath($2))
|
258
279
|
when 'e', 'editable'
|
259
|
-
|
260
|
-
target << quote_option($1, val =~ %r{^[a-z]+(?:\+[a-z]+)?://}i ? val : basepath(val))
|
261
|
-
when 'proxy', 'config-settings', 'global-option', 'extra-index-url',
|
262
|
-
'f', 'find-links', 'i', 'index-url'
|
263
|
-
target << quote_option($1, $2)
|
264
|
-
when 'retries', 'timeout'
|
265
|
-
target << basic_option($1, $2) if $2.to_i > 0
|
266
|
-
else
|
267
|
-
target << shell_option($1, $2)
|
280
|
+
edit = $2
|
268
281
|
end
|
282
|
+
elsif flag == :editable && !edit
|
283
|
+
edit = opt
|
269
284
|
else
|
270
285
|
out << opt
|
271
286
|
end
|
272
287
|
end
|
273
|
-
if
|
274
|
-
|
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
|
275
299
|
else
|
276
300
|
option_clear(out, target: target)
|
301
|
+
[]
|
277
302
|
end
|
278
303
|
end
|
279
304
|
|
@@ -286,7 +311,7 @@ module Squared
|
|
286
311
|
quote_option('cache-dir', basepath(val))
|
287
312
|
end
|
288
313
|
end
|
289
|
-
cmd <<
|
314
|
+
cmd << shell_option('proxy', val) if (val = option('proxy'))
|
290
315
|
cmd << quote_option('python', basepath(val)) if (val = option('python'))
|
291
316
|
append_nocolor
|
292
317
|
end
|