Skip to content

Commit 5b3d64e

Browse files
committed
Do not pass --log to pip install
When passing a `--log` option to `pip install`, _verbose_ logging is appended to the specified file, and the default logging captured by puppet is _quitter_ than the default. When an installation error occur, the quieter output does not contain the reason for the failure, and inspection of the log file is necessary to determine the reason of the error. This is impractical in CI systems where this file cannot be retrieved easily, and makes fixing regressions harder. On production systems, this log is also mostly useless since projects dependencies versions are generally expected to be found in the requirement file used for installation in order for deployments to be reproducible.
1 parent 40a84a9 commit 5b3d64e

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

manifests/pip.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@
181181
default => "'${url}#egg=${egg_name}'",
182182
}
183183

184-
$pip_install = "${pip_env} --log ${log}/pip.log install"
184+
$pip_install = "${pip_env} install"
185185
$pip_common_args = "${pypi_index} ${pypi_extra_index} ${proxy_flag} ${install_editable} ${source}"
186186

187187
# Explicit version out of VCS when PIP supported URL is provided

manifests/pyvenv.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
}
9595

9696
exec { "python_virtualenv_${venv_dir}":
97-
command => "${virtualenv_cmd} --clear ${system_pkgs_flag} ${prompt_arg} ${venv_dir} && ${pip_cmd} --log ${venv_dir}/pip.log install ${pip_upgrade} && ${pip_cmd} --log ${venv_dir}/pip.log install --upgrade setuptools",
97+
command => "${virtualenv_cmd} --clear ${system_pkgs_flag} ${prompt_arg} ${venv_dir} && ${pip_cmd} install ${pip_upgrade} && ${pip_cmd} install --upgrade setuptools",
9898
user => $owner,
9999
creates => "${venv_dir}/bin/activate",
100100
path => $_path,

manifests/requirements.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898

9999
exec { "python_requirements${name}":
100100
provider => shell,
101-
command => "${pip_env} --log ${log}/pip.log install ${proxy_flag} ${src_flag} -r ${requirements} ${extra_pip_args}",
101+
command => "${pip_env} install ${proxy_flag} ${src_flag} -r ${requirements} ${extra_pip_args}",
102102
refreshonly => !$forceupdate,
103103
timeout => $timeout,
104104
cwd => $cwd,

spec/classes/python_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
it {
158158
expect(subject).to contain_exec('python_virtualenv_/opt/env1').
159159
with(
160-
command: 'python3.8 -m venv --clear /opt/env1 && /opt/env1/bin/pip --log /opt/env1/pip.log install --upgrade pip && /opt/env1/bin/pip --log /opt/env1/pip.log install --upgrade setuptools',
160+
command: 'python3.8 -m venv --clear /opt/env1 && /opt/env1/bin/pip install --upgrade pip && /opt/env1/bin/pip install --upgrade setuptools',
161161
user: 'root',
162162
creates: '/opt/env1/bin/activate',
163163
path: [
@@ -177,7 +177,7 @@
177177
it {
178178
expect(subject).to contain_exec('python_virtualenv_/opt/env2').
179179
with(
180-
command: 'python3.8 -m venv --clear /opt/env2 && /opt/env2/bin/pip --log /opt/env2/pip.log install --upgrade \'pip <= 20.3.4\' && /opt/env2/bin/pip --log /opt/env2/pip.log install --upgrade setuptools',
180+
command: 'python3.8 -m venv --clear /opt/env2 && /opt/env2/bin/pip install --upgrade \'pip <= 20.3.4\' && /opt/env2/bin/pip install --upgrade setuptools',
181181
user: 'root',
182182
creates: '/opt/env2/bin/activate',
183183
path: [

spec/defines/pip_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
context 'adds proxy to install command if proxy set' do
7878
let(:params) { { proxy: 'http://my.proxy:3128' } }
7979

80-
it { is_expected.to contain_exec('pip_install_rpyc').with_command('pip --log /tmp/pip.log install --proxy=http://my.proxy:3128 rpyc') }
80+
it { is_expected.to contain_exec('pip_install_rpyc').with_command('pip install --proxy=http://my.proxy:3128 rpyc') }
8181
end
8282
end
8383

@@ -91,7 +91,7 @@
9191
context 'adds index to install command if index set' do
9292
let(:params) { { index: 'http://www.example.com/simple/' } }
9393

94-
it { is_expected.to contain_exec('pip_install_rpyc').with_command('pip --log /tmp/pip.log install --index-url=http://www.example.com/simple/ rpyc') }
94+
it { is_expected.to contain_exec('pip_install_rpyc').with_command('pip install --index-url=http://www.example.com/simple/ rpyc') }
9595
end
9696
end
9797

@@ -105,7 +105,7 @@
105105
context 'adds extra_index to install command if extra_index set' do
106106
let(:params) { { extra_index: 'http://www.example.com/extra/simple/' } }
107107

108-
it { is_expected.to contain_exec('pip_install_rpyc').with_command('pip --log /tmp/pip.log install --extra-index-url=http://www.example.com/extra/simple/ rpyc') }
108+
it { is_expected.to contain_exec('pip_install_rpyc').with_command('pip install --extra-index-url=http://www.example.com/extra/simple/ rpyc') }
109109
end
110110
end
111111

@@ -122,7 +122,7 @@
122122
context 'adds install_args to install command if install_args set' do
123123
let(:params) { { install_args: '--pre' } }
124124

125-
it { is_expected.to contain_exec('pip_install_rpyc').with_command('pip --log /tmp/pip.log install --pre rpyc') }
125+
it { is_expected.to contain_exec('pip_install_rpyc').with_command('pip install --pre rpyc') }
126126
end
127127
end
128128

@@ -151,13 +151,13 @@
151151
context 'supports v-prefixed version string' do
152152
let(:params) { { ensure: 'v1.7.0' } }
153153

154-
it { is_expected.to contain_exec('pip_install_rpyc').with_command('pip --log /tmp/pip.log install rpyc==v1.7.0') }
154+
it { is_expected.to contain_exec('pip_install_rpyc').with_command('pip install rpyc==v1.7.0') }
155155
end
156156

157157
context 'supports version string without v-prefix' do
158158
let(:params) { { ensure: '1.7.0' } }
159159

160-
it { is_expected.to contain_exec('pip_install_rpyc').with_command('pip --log /tmp/pip.log install rpyc==1.7.0') }
160+
it { is_expected.to contain_exec('pip_install_rpyc').with_command('pip install rpyc==1.7.0') }
161161
end
162162
end
163163

@@ -235,13 +235,13 @@
235235
context 'suceeds with no extras' do
236236
let(:params) { {} }
237237

238-
it { is_expected.to contain_exec('pip_install_requests').with_command('pip --log /tmp/pip.log install requests') }
238+
it { is_expected.to contain_exec('pip_install_requests').with_command('pip install requests') }
239239
end
240240

241241
context 'succeeds with extras' do
242242
let(:params) { { extras: ['security'] } }
243243

244-
it { is_expected.to contain_exec('pip_install_requests').with_command('pip --log /tmp/pip.log install requests[security]') }
244+
it { is_expected.to contain_exec('pip_install_requests').with_command('pip install requests[security]') }
245245
end
246246
end
247247
end

spec/defines/pyvenv_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
context 'with default parameters' do
3131
it { is_expected.to contain_file('/opt/env').that_requires('Class[python::install]') }
32-
it { is_expected.to contain_exec('python_virtualenv_/opt/env').with_command('pyvenv-3.5 --clear /opt/env && /opt/env/bin/pip --log /opt/env/pip.log install --upgrade pip && /opt/env/bin/pip --log /opt/env/pip.log install --upgrade setuptools') }
32+
it { is_expected.to contain_exec('python_virtualenv_/opt/env').with_command('pyvenv-3.5 --clear /opt/env && /opt/env/bin/pip install --upgrade pip && /opt/env/bin/pip install --upgrade setuptools') }
3333
end
3434

3535
describe 'when ensure' do
@@ -67,7 +67,7 @@
6767

6868
it {
6969
is_expected.to contain_file('/opt/env').that_requires('Class[python::install]')
70-
is_expected.to contain_exec('python_virtualenv_/opt/env').with_command('python3.6 -m venv --clear --prompt custom\\ prompt /opt/env && /opt/env/bin/pip --log /opt/env/pip.log install --upgrade pip && /opt/env/bin/pip --log /opt/env/pip.log install --upgrade setuptools')
70+
is_expected.to contain_exec('python_virtualenv_/opt/env').with_command('python3.6 -m venv --clear --prompt custom\\ prompt /opt/env && /opt/env/bin/pip install --upgrade pip && /opt/env/bin/pip install --upgrade setuptools')
7171
}
7272
end
7373
end
@@ -91,7 +91,7 @@
9191

9292
it {
9393
is_expected.to contain_file('/opt/env').that_requires('Class[python::install]')
94-
is_expected.to contain_exec('python_virtualenv_/opt/env').with_command('pyvenv-3.5 --clear /opt/env && /opt/env/bin/pip --log /opt/env/pip.log install --upgrade pip && /opt/env/bin/pip --log /opt/env/pip.log install --upgrade setuptools')
94+
is_expected.to contain_exec('python_virtualenv_/opt/env').with_command('pyvenv-3.5 --clear /opt/env && /opt/env/bin/pip install --upgrade pip && /opt/env/bin/pip install --upgrade setuptools')
9595
}
9696
end
9797
end

0 commit comments

Comments
 (0)