Skip to content

Commit 29d79b6

Browse files
allow setting an index URL when creating the venv
1 parent 175ac42 commit 29d79b6

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

REFERENCE.md

+9
Original file line numberDiff line numberDiff 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

987988
Default 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

9911000
Data type: `Python::Venv::PipVersion`

manifests/pyvenv.pp

+8-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
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' :
@@ -34,6 +35,7 @@
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

@@ -80,13 +82,18 @@
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,

0 commit comments

Comments
 (0)