Skip to content

Commit 1769155

Browse files
author
Jarl Stefansson
committed
Disable system package flag on older virtualenv
1 parent a017bd3 commit 1769155

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

lib/facter/virtualenv_version.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
require 'puppet'
2+
pkg = Puppet::Type.type(:package).new(:name => "virtualenv")
3+
Facter.add("virtualenv_version") do
4+
setcode do
5+
/^(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1]
6+
end
7+
end

manifests/virtualenv.pp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#
1616
# [*systempkgs*]
1717
# Copy system site-packages into virtualenv. Default: don't
18+
# If virtualenv version < 1.7 this flag has no effect since
19+
# the system packages were not supported
1820
#
1921
# [*distribute*]
2022
# Include distribute in the virtualenv. Default: true
@@ -88,9 +90,12 @@
8890
default => "&& export http_proxy=${proxy}",
8991
}
9092

91-
$system_pkgs_flag = $systempkgs ? {
92-
false => '',
93-
default => '--system-site-packages',
93+
# Virtualenv versions prior to 1.7 do not support the
94+
# --system-site-packages flag, default off for prior versions
95+
if versioncmp($::virtualenv_version,'1.7') > 0 and systempkgs == true {
96+
$system_pkgs_flag = '--system-site-packages',
97+
} else {
98+
$system_pkgs_flag = ''
9499
}
95100

96101
$distribute_pkg = $distribute ? {

0 commit comments

Comments
 (0)