-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.sh
executable file
·144 lines (125 loc) · 3.98 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/usr/bin/env bash
# USAGE:
# bash install.sh # Standard (user) install
# bash install.sh 1 # Developer install
platform=$(uname)
if [ "$platform" == 'Linux' ]
then
miniforge_url="https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-$(uname -m).sh"
elif [ "$platform" == 'Darwin' ]
then
miniforge_url="https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-$(uname -m).sh"
else
echo 'Unsupported platform. Exiting.'
exit 1
fi
# Name of package
PACKAGE_NAME=lsforce
# Name of new environment
ENV_NAME=$PACKAGE_NAME
# Is mamba installed?
if ! mamba --version
then
echo 'No mamba detected.'
# Is conda installed?
if ! conda --version
then
echo 'No conda detected, either — installing Miniforge...'
# Try to download shell script using curl
if ! curl -L $miniforge_url -o Miniforge3.sh
then
echo 'Failed to download Miniforge installer shell script. Exiting.'
exit 1
fi
# Try to install Miniforge
echo 'Install directory: ~/miniforge3'
if ! bash Miniforge3.sh -f -b -p ~/miniforge3
then
echo 'Failed to run Miniforge installer shell script. Exiting.'
exit 1
fi
# "create the path to conda" — see:
# https://github.com/conda-forge/miniforge/blob/main/README.md#as-part-of-a-ci-pipeline
source ~/miniforge3/etc/profile.d/conda.sh
echo 'mamba installed.'
CONDA_CMD=mamba
else
echo 'conda detected.'
CONDA_CMD=conda
fi
else
echo 'mamba detected.'
CONDA_CMD=mamba
fi
# "create the path to conda" — see:
# https://github.com/conda-forge/miniforge/blob/main/README.md#as-part-of-a-ci-pipeline
source $(conda info --base)/etc/profile.d/conda.sh
# Try to activate the base environment
echo 'Activating the base environment.'
if ! conda activate base
then
echo 'Failed to activate the base environment. Exiting.'
exit 1
fi
# Remove existing environment if it exists
conda remove --yes --name $ENV_NAME --all
# Try to create the environment
echo "Creating the $ENV_NAME environment"
if ! $CONDA_CMD env create --yes --name $ENV_NAME --file environment.yml
then
echo 'Failed to create environment. Exiting.'
exit 1
fi
# Try to activate the new environment
echo "Activating the $ENV_NAME environment."
if ! conda activate $ENV_NAME
then
echo '"conda activate" failed, trying "source activate" instead...'
if ! source activate $ENV_NAME
then
echo "Failed to activate the $ENV_NAME environment. Exiting."
exit 1
fi
fi
# Try to upgrade pip, mostly so pip doesn't complain about not being new...
if ! pip install --upgrade pip
then
echo 'Failed to upgrade pip. Trying to continue...'
fi
# If user supplied the developer flag, install developer packages
if [ "$1" == 1 ]
then
echo 'Installing developer packages...'
if ! pip install --requirement requirements.txt
then
echo 'Failed to install developer packages. Exiting.'
fi
fi
# If we're on the GitLab runner, then we need to install git because it's needed for
# setuptools_scm to get the version number from the git repository during pip install
if [ "$GITLAB_CI" == true ]
then
echo 'GitLab CI/CD instance detected, installing git...'
if ! $CONDA_CMD install --yes --channel conda-forge git
then
echo 'Failed to install git. Exiting.'
exit 1
fi
fi
# Try to install this package
echo
echo "Installing $PACKAGE_NAME using pip."
if ! pip install --editable .
then
echo "Failed to pip install $PACKAGE_NAME. Exiting."
exit 1
fi
# If this is a developer install, then give nbdime setup instructions, see:
# https://nbdime.readthedocs.io/en/latest/#git-integration-quickstart
if [ "$1" == 1 ]
then
echo '------------------------------------------'
echo 'To set up git integration for nbdime, run:'
echo 'nbdime config-git --enable --global'
echo '------------------------------------------'
fi