squared 0.2.2 → 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 +66 -1
- 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 +3 -3
- data/lib/squared/common/shell.rb +11 -6
- 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 +321 -124
- data/lib/squared/workspace/project/git.rb +498 -296
- data/lib/squared/workspace/project/node.rb +245 -101
- data/lib/squared/workspace/project/python.rb +101 -87
- 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
- metadata +3 -3
@@ -4,19 +4,22 @@ module Squared
|
|
4
4
|
module Workspace
|
5
5
|
module Project
|
6
6
|
class Python < Git
|
7
|
-
REQUIREMENTS = %w[requirements.txt pyproject.toml
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
7
|
+
REQUIREMENTS = %w[requirements.txt pyproject.toml].freeze
|
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,56 +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
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
when :target
|
124
|
-
cmd << quote_option('target', basepath(param))
|
125
|
-
else
|
126
|
-
append_global
|
127
|
-
end
|
128
|
-
append_pip opts if flag
|
129
|
-
if type == 2
|
130
|
-
cmd << '.'
|
131
|
-
elsif !cmd.find { |val| val =~ /^(?:-r|--requirement)/ }
|
132
|
-
cmd << '-r requirements.txt'
|
133
|
-
end
|
134
|
-
when 3
|
135
|
-
cmd = python_session 'setup.py', 'install'
|
136
|
-
case flag
|
137
|
-
when :user
|
138
|
-
cmd << '--user'
|
139
|
-
when :target
|
140
|
-
cmd << quote_option('build-base', basepath(dir))
|
141
|
-
end
|
142
|
-
if option('user')
|
143
|
-
cmd << '--user'
|
144
|
-
else
|
145
|
-
append_first(%w[home prefix], equals: true, escape: false, quote: true, ignore: false)
|
146
|
-
end
|
147
|
-
cmd.delete('--user') if workspace.windows?
|
125
|
+
cmd = pip_session 'install'
|
126
|
+
case flag
|
127
|
+
when :user
|
128
|
+
cmd << "--#{flag}"
|
129
|
+
when :target
|
130
|
+
cmd << quote_option('target', basepath(target))
|
131
|
+
when :force
|
132
|
+
cmd << '--force-reinstall'
|
133
|
+
else
|
134
|
+
append_global
|
135
|
+
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 << '.'
|
148
141
|
end
|
149
142
|
run(from: :depend, sync: sync)
|
150
143
|
end
|
151
144
|
end
|
152
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
|
+
|
153
161
|
def outdated(*, sync: invoked_sync?('outdated'))
|
154
162
|
cmd = pip_session 'list', '--outdated'
|
155
163
|
append_global
|
@@ -256,36 +264,42 @@ module Squared
|
|
256
264
|
session('python', *cmd)
|
257
265
|
end
|
258
266
|
|
259
|
-
def append_pip(
|
267
|
+
def append_pip(flag, opts, target: @session, from: nil)
|
260
268
|
append_nocolor(target: target)
|
261
|
-
return
|
269
|
+
return [] unless from && !opts.empty?
|
262
270
|
|
271
|
+
opts, pat = option_sanitize(opts, OPT_PIP[from] + OPT_PIP[:common], target: target)
|
263
272
|
out = []
|
264
|
-
|
273
|
+
edit = nil
|
265
274
|
opts.each do |opt|
|
266
275
|
if opt =~ /^(v+|q+)$/
|
267
276
|
cmd << "-#{$1}"
|
268
277
|
elsif opt =~ pat
|
269
278
|
case $1
|
270
|
-
when 'root', 'prefix', 'src', 'cert', 'client-cert', 'cache-dir', 'log', 'report',
|
271
|
-
'r', 'requirement', 'c', 'constraint', 't', 'target'
|
272
|
-
target << quote_option($1, basepath($2))
|
273
279
|
when 'e', 'editable'
|
274
|
-
|
275
|
-
target << quote_option($1, val =~ %r{^[a-z]+\+[a-z]+://} ? val : basepath(val))
|
276
|
-
when 'proxy', 'config-settings', 'global-option', 'extra-index-url',
|
277
|
-
'f', 'find-links', 'i', 'index-url'
|
278
|
-
target << quote_option($1, $2)
|
279
|
-
when 'retries', 'timeout'
|
280
|
-
target << basic_option($1, $2) if $2.to_i > 0
|
281
|
-
else
|
282
|
-
target << shell_option($1, $2)
|
280
|
+
edit = $2
|
283
281
|
end
|
282
|
+
elsif flag == :editable && !edit
|
283
|
+
edit = opt
|
284
284
|
else
|
285
285
|
out << opt
|
286
286
|
end
|
287
287
|
end
|
288
|
-
|
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
|
299
|
+
else
|
300
|
+
option_clear(out, target: target)
|
301
|
+
[]
|
302
|
+
end
|
289
303
|
end
|
290
304
|
|
291
305
|
def append_global
|
@@ -297,7 +311,7 @@ module Squared
|
|
297
311
|
quote_option('cache-dir', basepath(val))
|
298
312
|
end
|
299
313
|
end
|
300
|
-
cmd <<
|
314
|
+
cmd << shell_option('proxy', val) if (val = option('proxy'))
|
301
315
|
cmd << quote_option('python', basepath(val)) if (val = option('python'))
|
302
316
|
append_nocolor
|
303
317
|
end
|