File tree Expand file tree Collapse file tree 4 files changed +22
-6
lines changed Expand file tree Collapse file tree 4 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -904,6 +904,7 @@ The following parameters are available in the `python::pyvenv` defined type:
904904* [ ` path ` ] ( #-python--pyvenv--path )
905905* [ ` environment ` ] ( #-python--pyvenv--environment )
906906* [ ` prompt ` ] ( #-python--pyvenv--prompt )
907+ * [ ` index ` ] ( #-python--pyvenv--index )
907908* [ ` pip_version ` ] ( #-python--pyvenv--pip_version )
908909
909910##### <a name =" -python--pyvenv--ensure " ></a >` ensure `
@@ -986,6 +987,14 @@ Optionally specify the virtualenv prompt (python >= 3.6)
986987
987988Default value: ` undef `
988989
990+ ##### <a name =" -python--pyvenv--index " ></a >` index `
991+
992+ Data type: ` Optional[String[1]] `
993+
994+ Optionally specify an index location from where pip and setuptools should be installed
995+
996+ Default value: ` undef `
997+
989998##### <a name =" -python--pyvenv--pip_version " ></a >` pip_version `
990999
9911000Data type: ` Python::Venv::PipVersion `
Original file line number Diff line number Diff line change 1111# @param path Specifies the PATH variable.
1212# @param environment Optionally specify environment variables for pyvenv
1313# @param prompt Optionally specify the virtualenv prompt (python >= 3.6)
14+ # @param index Optionally specify an index location from where pip and setuptools should be installed
1415#
1516# @example
1617# python::pyvenv { '/var/www/project1' :
3435 Array $environment = [],
3536 Optional[String[1]] $prompt = undef ,
3637 Python::Venv::PipVersion $pip_version = ' latest' ,
38+ Optional[String[1]] $index = undef ,
3739) {
3840 include python
3941
8082
8183 $pip_cmd = " ${python::exec_prefix}${venv_dir} /bin/pip"
8284
85+ $index_config = $index ? {
86+ undef => ' ' ,
87+ default => " -i ${index} "
88+ }
89+
8390 $pip_upgrade = ($pip_version != ' latest' ) ? {
8491 true => " --upgrade 'pip ${pip_version} '" ,
8592 false => ' --upgrade pip' ,
8693 }
8794
8895 exec { "python_virtualenv_${venv_dir}" :
89- 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" ,
96+ command => " ${virtualenv_cmd} --clear ${system_pkgs_flag} ${prompt_arg} ${venv_dir} && ${pip_cmd} --log ${venv_dir} /pip.log install ${index_config} ${ pip_upgrade} && ${pip_cmd} --log ${venv_dir} /pip.log install ${index_config} --upgrade setuptools" ,
9097 user => $owner ,
9198 creates => " ${venv_dir} /bin/activate" ,
9299 path => $_path,
Original file line number Diff line number Diff line change 155155 it {
156156 expect ( subject ) . to contain_exec ( 'python_virtualenv_/opt/env1' ) .
157157 with (
158- 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' ,
158+ 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' ,
159159 user : 'root' ,
160160 creates : '/opt/env1/bin/activate' ,
161161 path : [
175175 it {
176176 expect ( subject ) . to contain_exec ( 'python_virtualenv_/opt/env2' ) .
177177 with (
178- 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' ,
178+ 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' ,
179179 user : 'root' ,
180180 creates : '/opt/env2/bin/activate' ,
181181 path : [
Original file line number Diff line number Diff line change 1919
2020 context 'with default parameters' do
2121 it { is_expected . to contain_file ( '/opt/env' ) . that_requires ( 'Class[python::install]' ) }
22- 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' ) }
22+ 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' ) }
2323 end
2424
2525 describe 'when ensure' do
5757
5858 it {
5959 is_expected . to contain_file ( '/opt/env' ) . that_requires ( 'Class[python::install]' )
60- 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' )
60+ 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' )
6161 }
6262 end
6363 end
8181
8282 it {
8383 is_expected . to contain_file ( '/opt/env' ) . that_requires ( 'Class[python::install]' )
84- 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' )
84+ 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' )
8585 }
8686 end
8787 end
You can’t perform that action at this time.
0 commit comments