Skip to content

Commit

Permalink
Merge pull request #486 from alphagov/ris-freeze-requirements-upgrade…
Browse files Browse the repository at this point in the history
…-pip

repoutils.freeze_requirements: upgrade pip to latest version in newly created venv
  • Loading branch information
risicle authored Jan 22, 2019
2 parents cbd5269 + 8674e39 commit 9a25baf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 3 additions & 2 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ in (with args; {

hardeningDisable = pkgs.stdenv.lib.optionals pkgs.stdenv.isDarwin [ "format" ];

VIRTUALENV_ROOT = "venv${pythonPackages.python.pythonVersion}";
VIRTUALENV_ROOT = (toString (./.)) + "/venv${pythonPackages.python.pythonVersion}";
VIRTUAL_ENV_DISABLE_PROMPT = "1";
SOURCE_DATE_EPOCH = "315532800";

Expand All @@ -37,7 +37,8 @@ in (with args; {
${pythonPackages.python}/bin/python -m venv $VIRTUALENV_ROOT
fi
source $VIRTUALENV_ROOT/bin/activate
make requirements${pkgs.stdenv.lib.optionalString forDev "-dev"}
pip install --upgrade pip==18.0 # some packages are sensitive to "old" pips
make -C ${toString (./.)} requirements${pkgs.stdenv.lib.optionalString forDev "-dev"}
'';
}).overrideAttrs (if builtins.pathExists localOverridesPath then (import localOverridesPath args) else (x: x));
})
2 changes: 1 addition & 1 deletion dmutils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
from .flask_init import init_app, init_manager


__version__ = '45.4.0'
__version__ = '45.5.0'
8 changes: 8 additions & 0 deletions dmutils/repoutils/freeze_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ def exit_failure(messages, code=1):
logger.info(f'Creating virtualenv: {virtualenv_name}')
venv.main(args=(virtualenv_name,))

logger.info(f'Upgrading pip version in virtualenv: {virtualenv_name}')
install_cmd = subprocess.run(
[f'{virtualenv_name}/bin/pip', 'install', '--upgrade', 'pip'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True
)

logger.info(f'Installing requirements from {target} in virtualenv: {virtualenv_name}')
install_cmd = subprocess.run(
[f'{virtualenv_name}/bin/pip', 'install', '-r', target],
Expand Down

0 comments on commit 9a25baf

Please sign in to comment.