forked from tuna/tunasync-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pypi.sh
executable file
·72 lines (64 loc) · 1.35 KB
/
pypi.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
#!/bin/bash
set -e
BANDERSNATCH=${BANDERSNATCH:-"/usr/local/bin/bandersnatch"}
PYPI_MASTER="https://pypi.org/"
TUNASYNC_UPSTREAM=${TUNASYNC_UPSTREAM_URL:-$PYPI_MASTER}
CONF="/tmp/bandersnatch.conf"
INIT=${INIT:-"0"}
if [ ! -d "$TUNASYNC_WORKING_DIR" ]; then
mkdir -p $TUNASYNC_WORKING_DIR
INIT="1"
fi
echo "Syncing to $TUNASYNC_WORKING_DIR"
DOWNLOAD_MIRROR=""
if [[ $TUNASYNC_UPSTREAM != $PYPI_MASTER ]]; then
# see https://github.com/pypa/bandersnatch/pull/928 for more info
DOWNLOAD_MIRROR="download-mirror = ${TUNASYNC_UPSTREAM}"
fi
if [[ $INIT == "0" ]]; then
(
cat << EOF
[mirror]
directory = ${TUNASYNC_WORKING_DIR}
storage-backend = filesystem
master = ${PYPI_MASTER}
${DOWNLOAD_MIRROR}
json = true
timeout = 300
workers = 5
hash-index = false
stop-on-error = false
delete-packages = true
compare-method = stat
[plugins]
enabled =
blocklist_project
[blocklist]
packages =
tf-nightly-gpu
tf-nightly
tensorflow-io-nightly
tf-nightly-cpu
pyagrum-nightly
uselesscapitalquiz
EOF
for i in $PYPI_EXCLUDE; do
echo " $i"
done
) > $CONF
exec $BANDERSNATCH -c $CONF mirror
else
cat > $CONF << EOF
[mirror]
directory = ${TUNASYNC_WORKING_DIR}
master = ${PYPI_MASTER}
${DOWNLOAD_MIRROR}
json = true
timeout = 15
workers = 10
hash-index = false
stop-on-error = false
delete-packages = false
EOF
exec $BANDERSNATCH -c $CONF mirror
fi