|
1 | | -#!/usr/bin/env bash |
| 1 | +#!/usr/bin/env sh |
2 | 2 | # This script aims to wrap pip-tools through Docker in order to ensure portability across systems (Windows, Linux, Mac) |
3 | 3 |
|
4 | 4 | set -eu |
5 | 5 |
|
6 | | -SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P) |
| 6 | +SCRIPT_DIR=$(cd "$(dirname "$0")" > /dev/null 2>&1 && pwd -P) |
7 | 7 |
|
8 | | -# Path conversion is required on Windows so that Docker volume mount will work |
9 | | -# However, it shall be done in a controlled manner to avoid issues |
10 | | -# Using Cygwin effectively with Windows: https://cygwin.com/cygwin-ug-net/using-effectively.html |
11 | | -# Kernel detection is done based on the recommendation found here: https://stackoverflow.com/questions/3466166/how-to-check-if-running-in-cygwin-mac-or-linux |
12 | | -if [[ "$(uname)" =~ (CYGWIN.*)|(MINGW.*)|(MSYS.*) ]]; then |
13 | | - # We disable automatic path conversion to avoid unexpected side effects |
14 | | - export MSYS_NO_PATHCONV=1 |
15 | | - # We manually enforce a Windows path to prevent issues with Docker volume mounts |
16 | | - SCRIPT_DIR="$(cygpath --windows "${SCRIPT_DIR}")" |
17 | | -fi |
| 8 | +# On Windows environments (Cygwin, MinGW, MSYS), Docker volume mounts require Windows-style paths. |
| 9 | +# However, automatic path conversion by MSYS can cause unexpected issues, |
| 10 | +# so we disable it and convert paths explicitly and deliberately. |
| 11 | +# See: https://cygwin.com/cygwin-ug-net/using-effectively.html |
| 12 | +# Kernel detection approach based on recommendations from: |
| 13 | +# https://stackoverflow.com/questions/3466166/how-to-check-if-running-in-cygwin-mac-or-linux |
| 14 | +case "$(uname)" in |
| 15 | + CYGWIN*|MINGW*|MSYS*) |
| 16 | + # We disable automatic path conversion to avoid unexpected side effects |
| 17 | + export MSYS_NO_PATHCONV=1 |
| 18 | + # We manually enforce a Windows path to prevent issues with Docker volume mounts |
| 19 | + SCRIPT_DIR="$(cygpath --windows "${SCRIPT_DIR}")" |
| 20 | + ;; |
| 21 | +esac |
18 | 22 |
|
19 | 23 | docker build -t pip-tools -f Dockerfile.pip-tools "${SCRIPT_DIR}" |
20 | 24 |
|
|
0 commit comments