Files
zuul/tools/pip.sh
T
Monty Taylor fadd15a001 Use nodeenv for npm and yarn in tox
Add a wrapper installation script that will install npm and yarn into the
current virtualenv. If yarn is installed globally, the script is a
no-op.

If yarn is not installed globally, whenever tox thinks it needs to
create or re-create a virtualenv, install nodeenv then use it to
install yarn.

This removes the use of the zuul-tox-py35 job because it should now just work
properly with the normal job. It does not remove the job itself because
it's still used in tox-py35-on-zuul.

Change-Id: If360a3f0c6b3d74498f8aa063d8b1ae87daff101
2018-04-12 12:38:55 -05:00

38 lines
1.3 KiB
Bash

#!/bin/bash
# Copyright 2018 Red Hat, Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
# This script checks if yarn is installed in the current path. If it is not,
# it will use nodeenv to install node, npm and yarn.
# Finally, it will install pip things.
if [[ ! $(command -v yarn) ]]
then
pip install nodeenv
# Initialize nodeenv and tell it to re-use the currently active virtualenv
nodeenv --python-virtualenv
# Use -g because inside of the virtualenv '-g' means 'install into the'
# virtualenv - as opposed to installing into the local node_modules.
# Avoid writing a package-lock.json file since we don't use it.
# Avoid writing yarn into package.json.
npm install -g --no-package-lock --no-save yarn
fi
if [[ ! -f zuul/web/static/status.html ]]
then
yarn install
npm run build:dev
fi
pip install $*