-
-
Notifications
You must be signed in to change notification settings - Fork 375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix virtualenv deprecated "--no-site-packages" argument #552
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,10 +99,16 @@ | |
} elsif (( versioncmp($_virtualenv_version,'1.7') < 0 ) and ( $systempkgs == false )) { | ||
$system_pkgs_flag = '--no-site-packages' | ||
} else { | ||
$system_pkgs_flag = $systempkgs ? { | ||
true => '--system-site-packages', | ||
false => '--no-site-packages', | ||
default => fail('Invalid value for systempkgs. Boolean value is expected') | ||
case $systempkgs { | ||
true: { $system_pkgs_flag = '--system-site-packages' } | ||
false: { | ||
if ( versioncmp($_virtualenv_version, '20.0.1') < 0 ) { | ||
$system_pkgs_flag = '--no-site-packages' | ||
} else { | ||
$system_pkgs_flag = '' | ||
} | ||
} | ||
default: { fail('Invalid value for systempkgs. Boolean value is expected') } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if we added type annotations, this the question, of course would remain whether puppet lint would know that…… (that the case is already exhaustive) |
||
} | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not add another
elsif
a few lines up?Tbh that logic structure isn't too clean either, but at least it's consistently dirty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think i agree with @thebigb on this one
this
case
is pretty unclean in the else, so why not avoid it altogetherThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah there's actually a subtle difference in logic here. When the
virtualenv_version
is not yet populated (e.g. the package has been just installed in the current run), @saz's version will default to an empty$system_pkgs_flag
, and my version will default to--no-site-packages
.I don't know enough about older versions virtualenv. If between 1.7 and 20.0.1 the
--no-site-packages
option was redundant anyway, the logic proposed by this PR is favorable. Otherwise this breaks the first run for everyone installing versions < 20.0.1.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So depending on what's desirable one of these should do the trick:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found a bug in the examples of my previous comment. For some reason I thought that it would jump to the
else
block if thevirtualenv_version
is empty, but that's obviously not the case. I edited the comment and the logic should work now.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.