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 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890
|
#!/usr/bin/env bats
load test_helper
export PYTHON_BUILD_CACHE_PATH="$TMP/cache"
export MAKE=make
export MAKE_OPTS="-j 2"
export CC=cc
export -n PYTHON_CONFIGURE_OPTS
setup() {
mkdir -p "$INSTALL_ROOT"
stub md5 false
stub curl false
}
executable() {
local file="$1"
mkdir -p "${file%/*}"
cat > "$file"
chmod +x "$file"
}
cached_tarball() {
mkdir -p "$PYTHON_BUILD_CACHE_PATH"
pushd "$PYTHON_BUILD_CACHE_PATH" >/dev/null
tarball "$@"
popd >/dev/null
}
tarball() {
local name="$1"
local path="$PWD/$name"
local configure="$path/${2:-configure}"
shift 1
executable "$configure" <<OUT
#!$BASH
echo "$name: CFLAGS=\\"\$CFLAGS\\" CPPFLAGS=\\"\$CPPFLAGS\\" LDFLAGS=\\"\$LDFLAGS\\" PKG_CONFIG_PATH=\\"\$PKG_CONFIG_PATH\\"" >> build.log
echo "$name: \$@" \${PYTHONOPT:+PYTHONOPT=\$PYTHONOPT} >> build.log
OUT
for file; do
mkdir -p "$(dirname "${path}/${file}")"
touch "${path}/${file}"
done
tar czf "${path}.tar.gz" -C "${path%/*}" "$name"
}
stub_make_install() {
stub "$MAKE" \
" : echo \"$MAKE \$@\" >> build.log" \
"${1:-install} : echo \"$MAKE \$@\" >> build.log && cat build.log >> '$INSTALL_ROOT/build.log'"
}
assert_build_log() {
run cat "$INSTALL_ROOT/build.log"
assert_output
}
@test "yaml is installed for python" {
cached_tarball "yaml-0.1.6"
cached_tarball "Python-3.6.2"
for i in {1..10}; do stub uname '-s : echo Linux'; done
stub brew false
stub_make_install
stub_make_install
install_fixture definitions/needs-yaml
assert_success
unstub uname
unstub make
assert_build_log <<OUT
yaml-0.1.6: CFLAGS="" CPPFLAGS="-I${TMP}/install/include" LDFLAGS="-L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib" PKG_CONFIG_PATH=""
yaml-0.1.6: --prefix=$INSTALL_ROOT
make -j 2
make install
Python-3.6.2: CFLAGS="" CPPFLAGS="-I${TMP}/install/include" LDFLAGS="-L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib" PKG_CONFIG_PATH=""
Python-3.6.2: --prefix=$INSTALL_ROOT --enable-shared --libdir=$INSTALL_ROOT/lib
make -j 2
make install
OUT
}
@test "apply global and package-specific flags, package flags come later to have precedence" {
local yaml_configure="yaml_configure"
export YAML_CONFIGURE="./$yaml_configure"
export YAML_PREFIX_PATH=yaml_prefix_path
export YAML_CONFIGURE_OPTS="yaml_configure_opt1 yaml_configure_opt2"
export YAML_MAKE_OPTS="yaml_make_opt1 yaml_make_opt2"
export YAML_CFLAGS="yaml_cflag1 yaml_cflag2"
export YAML_CPPFLAGS="yaml_cppflag1 yaml_cppflag2"
export YAML_LDFLAGS="yaml_ldflag1 yaml_ldflag2"
export CONFIGURE_OPTS="configure_opt1 configure_opt2"
export MAKE_OPTS="make_opt1 make_opt2"
export MAKE_INSTALL_OPTS="make_install_opt1 make_install_opt2"
export PYTHON_MAKE_INSTALL_OPTS="python_make_install_opt1 python_make_install_opt2"
export PYTHON_MAKE_INSTALL_TARGET="python_make_install_target"
cached_tarball "yaml-0.1.6" "$yaml_configure"
cached_tarball "Python-3.6.2"
for i in {1..10}; do stub uname '-s : echo Linux'; done
stub brew false
stub_make_install
stub_make_install "$PYTHON_MAKE_INSTALL_TARGET"
install_fixture definitions/needs-yaml
assert_success
unstub uname
unstub make
assert_build_log <<OUT
yaml-0.1.6: CFLAGS="yaml_cflag1 yaml_cflag2" CPPFLAGS="-I${TMP}/install/include yaml_cppflag1 yaml_cppflag2" LDFLAGS="-L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib yaml_ldflag1 yaml_ldflag2" PKG_CONFIG_PATH=""
yaml-0.1.6: --prefix=yaml_prefix_path configure_opt1 configure_opt2 yaml_configure_opt1 yaml_configure_opt2
make make_opt1 make_opt2 yaml_make_opt1 yaml_make_opt2
make install make_install_opt1 make_install_opt2
Python-3.6.2: CFLAGS="" CPPFLAGS="-I${TMP}/install/include" LDFLAGS="-L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib" PKG_CONFIG_PATH=""
Python-3.6.2: --prefix=$INSTALL_ROOT --enable-shared --libdir=$INSTALL_ROOT/lib configure_opt1 configure_opt2
make make_opt1 make_opt2
make python_make_install_target make_install_opt1 make_install_opt2 python_make_install_opt1 python_make_install_opt2
OUT
}
@test "apply python patch before building" {
cached_tarball "yaml-0.1.6"
cached_tarball "Python-3.6.2"
for i in {1..10}; do stub uname '-s : echo Linux'; done
stub brew false
stub_make_install
stub_make_install
stub patch ' : echo patch "$@" | sed -E "s/\.[[:alnum:]]+$/.XXX/" >> build.log'
TMPDIR="$TMP" install_fixture --patch definitions/needs-yaml <<<""
assert_success
unstub uname
unstub make
unstub patch
assert_build_log <<OUT
yaml-0.1.6: CFLAGS="" CPPFLAGS="-I${TMP}/install/include" LDFLAGS="-L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib" PKG_CONFIG_PATH=""
yaml-0.1.6: --prefix=$INSTALL_ROOT
make -j 2
make install
patch -p0 --force -i $TMP/python-patch.XXX
Python-3.6.2: CFLAGS="" CPPFLAGS="-I${TMP}/install/include" LDFLAGS="-L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib" PKG_CONFIG_PATH=""
Python-3.6.2: --prefix=$INSTALL_ROOT --enable-shared --libdir=$INSTALL_ROOT/lib
make -j 2
make install
OUT
}
@test "apply python patch from git diff before building" {
cached_tarball "yaml-0.1.6"
cached_tarball "Python-3.6.2"
for i in {1..10}; do stub uname '-s : echo Linux'; done
stub brew false
stub_make_install
stub_make_install
stub patch ' : echo patch "$@" | sed -E "s/\.[[:alnum:]]+$/.XXX/" >> build.log'
TMPDIR="$TMP" install_fixture --patch definitions/needs-yaml <<<"diff --git a/script.py"
assert_success
unstub uname
unstub make
unstub patch
assert_build_log <<OUT
yaml-0.1.6: CFLAGS="" CPPFLAGS="-I${TMP}/install/include" LDFLAGS="-L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib" PKG_CONFIG_PATH=""
yaml-0.1.6: --prefix=$INSTALL_ROOT
make -j 2
make install
patch -p1 --force -i $TMP/python-patch.XXX
Python-3.6.2: CFLAGS="" CPPFLAGS="-I${TMP}/install/include" LDFLAGS="-L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib" PKG_CONFIG_PATH=""
Python-3.6.2: --prefix=$INSTALL_ROOT --enable-shared --libdir=$INSTALL_ROOT/lib
make -j 2
make install
OUT
}
@test "homebrew with uncommon prefix is added to search path" {
cached_tarball "Python-3.6.2"
BREW_PREFIX="$TMP/homebrew-prefix"
mkdir -p "$BREW_PREFIX"
for i in {1..9}; do stub uname '-s : echo Darwin'; done
for i in {1..2}; do stub sw_vers '-productVersion : echo 1010'; done
stub brew "--prefix : echo '$BREW_PREFIX'" false
stub_make_install
run_inline_definition <<DEF
install_package "Python-3.6.2" "http://python.org/ftp/python/3.6.2/Python-3.6.2.tar.gz"
DEF
assert_success
unstub uname
unstub sw_vers
unstub make
assert_build_log <<OUT
Python-3.6.2: CFLAGS="" CPPFLAGS="-I${TMP}/install/include -I$BREW_PREFIX/include" LDFLAGS="-L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib -L$BREW_PREFIX/lib -Wl,-rpath,$BREW_PREFIX/lib" PKG_CONFIG_PATH=""
Python-3.6.2: --prefix=$INSTALL_ROOT --enable-shared --libdir=$INSTALL_ROOT/lib
make -j 2
make install
OUT
}
@test "yaml is linked from Homebrew" {
cached_tarball "Python-3.6.2"
brew_libdir="$TMP/homebrew-yaml"
mkdir -p "$brew_libdir"
for i in {1..10}; do stub uname '-s : echo Darwin'; done
for i in {1..2}; do stub sw_vers '-productVersion : echo 1010'; done
stub brew "--prefix libyaml : echo '$brew_libdir'"
for i in {1..6}; do stub brew false; done
stub_make_install
install_fixture definitions/needs-yaml
assert_success
unstub uname
unstub sw_vers
unstub brew
unstub make
assert_build_log <<OUT
Python-3.6.2: CFLAGS="" CPPFLAGS="-I$brew_libdir/include -I${TMP}/install/include" LDFLAGS="-L$brew_libdir/lib -L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib" PKG_CONFIG_PATH=""
Python-3.6.2: --prefix=$INSTALL_ROOT --enable-shared --libdir=$INSTALL_ROOT/lib
make -j 2
make install
OUT
}
@test "readline is linked from Homebrew" {
cached_tarball "Python-3.6.2"
readline_libdir="$TMP/homebrew-readline"
mkdir -p "$readline_libdir"
for i in {1..8}; do stub uname '-s : echo Darwin'; done
for i in {1..2}; do stub sw_vers '-productVersion : echo 1010'; done
for i in {1..3}; do stub brew false; done
stub brew "--prefix readline : echo '$readline_libdir'"
for i in {1..2}; do stub brew false; done
stub_make_install
run_inline_definition <<DEF
install_package "Python-3.6.2" "http://python.org/ftp/python/3.6.2/Python-3.6.2.tar.gz"
DEF
assert_success
unstub uname
unstub sw_vers
unstub brew
unstub make
assert_build_log <<OUT
Python-3.6.2: CFLAGS="" CPPFLAGS="-I$readline_libdir/include -I${TMP}/install/include" LDFLAGS="-L$readline_libdir/lib -L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib" PKG_CONFIG_PATH=""
Python-3.6.2: --prefix=$INSTALL_ROOT --enable-shared --libdir=$INSTALL_ROOT/lib
make -j 2
make install
OUT
}
@test "ncurses is linked from Homebrew" {
cached_tarball "Python-3.6.2"
ncurses_libdir="$TMP/homebrew-ncurses"
mkdir -p "$ncurses_libdir"
for i in {1..9}; do stub uname '-s : echo Darwin'; done
for i in {1..2}; do stub sw_vers '-productVersion : echo 1010'; done
for i in {1..4}; do stub brew false; done
stub brew "--prefix ncurses : echo '$ncurses_libdir'"
stub brew false
stub_make_install
run_inline_definition <<DEF
install_package "Python-3.6.2" "http://python.org/ftp/python/3.6.2/Python-3.6.2.tar.gz"
DEF
assert_success
unstub uname
unstub sw_vers
unstub brew
unstub make
assert_build_log <<OUT
Python-3.6.2: CFLAGS="" CPPFLAGS="-I$ncurses_libdir/include -I${TMP}/install/include" LDFLAGS="-L$ncurses_libdir/lib -L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib" PKG_CONFIG_PATH=""
Python-3.6.2: --prefix=$INSTALL_ROOT --enable-shared --libdir=$INSTALL_ROOT/lib
make -j 2
make install
OUT
}
@test "openssl is linked from Ports in FreeBSD if present" {
cached_tarball "Python-3.6.2"
for i in {1..7}; do stub uname '-s : echo FreeBSD'; done
stub uname '-r : echo 11.0-RELEASE'
for i in {1..3}; do stub uname '-s : echo FreeBSD'; done
stub sysctl '-n hw.ncpu : echo 1'
stub pkg "info -e openssl : true"
for in in {1..2}; do stub pkg false; done
stub_make_install
export -n MAKE_OPTS
run_inline_definition <<DEF
install_package "Python-3.6.2" "http://python.org/ftp/python/3.6.2/Python-3.6.2.tar.gz"
DEF
assert_success
unstub uname
unstub make
unstub pkg
unstub sysctl
assert_build_log <<OUT
Python-3.6.2: CFLAGS="" CPPFLAGS="-I${TMP}/install/include" LDFLAGS="-L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib" PKG_CONFIG_PATH=""
Python-3.6.2: --prefix=$INSTALL_ROOT --enable-shared --libdir=$INSTALL_ROOT/lib --with-openssl=/usr/local
make -j 1
make install
OUT
}
@test "readline and sqlite3 are linked from Ports in FreeBSD" {
cached_tarball "Python-3.6.2"
for lib in readline sqlite3; do
for i in {1..7}; do stub uname '-s : echo FreeBSD'; done
stub uname '-r : echo 11.0-RELEASE'
for i in {1..3}; do stub uname '-s : echo FreeBSD'; done
stub sysctl '-n hw.ncpu : echo 1'
stub pkg false
stub pkg "$([[ $lib == readline ]] && echo "info -e $lib : true" || echo false)"
if [[ $lib == sqlite3 ]]; then stub pkg "info -e $lib : true"; fi
stub_make_install
export -n MAKE_OPTS
run_inline_definition <<DEF
install_package "Python-3.6.2" "http://python.org/ftp/python/3.6.2/Python-3.6.2.tar.gz"
DEF
assert_success
unstub uname
unstub make
unstub pkg
unstub sysctl
assert_build_log <<OUT
Python-3.6.2: CFLAGS="" CPPFLAGS="-I${TMP}/install/include -I/usr/local/include" LDFLAGS="-L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib -L/usr/local/lib -Wl,-rpath,/usr/local/lib" PKG_CONFIG_PATH=""
Python-3.6.2: --prefix=$INSTALL_ROOT --enable-shared --libdir=$INSTALL_ROOT/lib
make -j 1
make install
OUT
rm "$INSTALL_ROOT/build.log"
done
}
@test "homebrew is not touched if PYTHON_BUILD_SKIP_HOMEBREW is set" {
cached_tarball "Python-3.6.2"
for i in {1..4}; do stub uname '-s : echo Darwin'; done
for i in {1..2}; do stub sw_vers '-productVersion : echo 1010'; done
stub brew true; brew
stub_make_install
export PYTHON_BUILD_SKIP_HOMEBREW=1
run_inline_definition <<DEF
install_package "Python-3.6.2" "http://python.org/ftp/python/3.6.2/Python-3.6.2.tar.gz"
DEF
assert_success
unstub uname
unstub brew
unstub make
assert_build_log <<OUT
Python-3.6.2: CFLAGS="" CPPFLAGS="-I${TMP}/install/include" LDFLAGS="-L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib" PKG_CONFIG_PATH=""
Python-3.6.2: --prefix=$INSTALL_ROOT --enable-shared --libdir=$INSTALL_ROOT/lib
make -j 2
make install
OUT
}
@test "homebrew is used in Linux if PYTHON_BUILD_USE_HOMEBREW is set" {
cached_tarball "Python-3.6.2"
BREW_PREFIX="$TMP/homebrew-prefix"
mkdir -p "$BREW_PREFIX"
for i in {1..4}; do stub uname '-s : echo Linux'; done
stub brew "--prefix : echo '$BREW_PREFIX'"
for i in {1..5}; do stub brew false; done
stub_make_install
export PYTHON_BUILD_USE_HOMEBREW=1
run_inline_definition <<DEF
install_package "Python-3.6.2" "http://python.org/ftp/python/3.6.2/Python-3.6.2.tar.gz"
DEF
assert_success
unstub uname
unstub brew
unstub make
assert_build_log <<OUT
Python-3.6.2: CFLAGS="" CPPFLAGS="-I${TMP}/install/include -I$BREW_PREFIX/include" LDFLAGS="-L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib -L$BREW_PREFIX/lib -Wl,-rpath,$BREW_PREFIX/lib" PKG_CONFIG_PATH=""
Python-3.6.2: --prefix=$INSTALL_ROOT --enable-shared --libdir=$INSTALL_ROOT/lib
make -j 2
make install
OUT
}
@test "homebrew is used in Linux if Pyenv is installed with Homebrew" {
cached_tarball "Python-3.6.2"
BREW_PREFIX="$(type -p python-build)"
BREW_PREFIX="${BREW_PREFIX%/*}"
BREW_PREFIX="${BREW_PREFIX%/*}"
for i in {1..4}; do stub uname '-s : echo Linux'; done
stub brew "--prefix : echo '$BREW_PREFIX'"
for i in {1..5}; do stub brew false; done
stub_make_install
export PYTHON_BUILD_USE_HOMEBREW=1
run_inline_definition <<DEF
install_package "Python-3.6.2" "http://python.org/ftp/python/3.6.2/Python-3.6.2.tar.gz"
DEF
assert_success
unstub uname
unstub brew
unstub make
assert_build_log <<OUT
Python-3.6.2: CFLAGS="" CPPFLAGS="-I${TMP}/install/include -I$BREW_PREFIX/include" LDFLAGS="-L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib -L$BREW_PREFIX/lib -Wl,-rpath,$BREW_PREFIX/lib" PKG_CONFIG_PATH=""
Python-3.6.2: --prefix=$INSTALL_ROOT --enable-shared --libdir=$INSTALL_ROOT/lib
make -j 2
make install
OUT
}
@test "homebrew is not used in Linux if Pyenv is not installed with Homebrew" {
cached_tarball "Python-3.6.2"
BREW_PREFIX="$TMP/homebrew-prefix"
mkdir -p "$BREW_PREFIX"
for i in {1..9}; do stub uname '-s : echo Linux'; done
for i in {1..5}; do stub brew "--prefix : echo '$BREW_PREFIX'"; done
stub_make_install
run_inline_definition <<DEF
install_package "Python-3.6.2" "http://python.org/ftp/python/3.6.2/Python-3.6.2.tar.gz"
DEF
assert_success
unstub uname
unstub brew
unstub make
assert_build_log <<OUT
Python-3.6.2: CFLAGS="" CPPFLAGS="-I${TMP}/install/include" LDFLAGS="-L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib" PKG_CONFIG_PATH=""
Python-3.6.2: --prefix=$INSTALL_ROOT --enable-shared --libdir=$INSTALL_ROOT/lib
make -j 2
make install
OUT
}
@test "readline is not linked from Homebrew when explicitly defined" {
cached_tarball "Python-3.6.2"
# python-build
readline_libdir="$TMP/custom"
mkdir -p "$readline_libdir/include/readline"
touch "$readline_libdir/include/readline/rlconf.h"
for i in {1..8}; do stub uname '-s : echo Darwin'; done
for i in {1..2}; do stub sw_vers '-productVersion : echo 1010'; done
for i in {1..5}; do stub brew false; done
stub_make_install
export PYTHON_CONFIGURE_OPTS="CPPFLAGS=-I$readline_libdir/include LDFLAGS=-L$readline_libdir/lib"
run_inline_definition <<DEF
install_package "Python-3.6.2" "http://python.org/ftp/python/3.6.2/Python-3.6.2.tar.gz"
DEF
assert_success
unstub uname
unstub sw_vers
unstub brew
unstub make
assert_build_log <<OUT
Python-3.6.2: CFLAGS="" CPPFLAGS="-I${TMP}/install/include" LDFLAGS="-L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib" PKG_CONFIG_PATH=""
Python-3.6.2: --prefix=$INSTALL_ROOT --enable-shared --libdir=$INSTALL_ROOT/lib CPPFLAGS=-I$readline_libdir/include LDFLAGS=-L$readline_libdir/lib
make -j 2
make install
OUT
}
@test "tcl-tk is linked from Homebrew" {
cached_tarball "Python-3.6.2"
tcl_tk_version=8.6
tcl_tk_libdir="$TMP/homebrew-tcl-tk"
mkdir -p "$tcl_tk_libdir/lib"
echo "TCL_VERSION='$tcl_tk_version'" >>"$tcl_tk_libdir/lib/tclConfig.sh"
for i in {1..9}; do stub uname '-s : echo Darwin'; done
for i in {1..2}; do stub sw_vers '-productVersion : echo 1010'; done
stub brew false
stub brew "--prefix tcl-tk@8 : echo '$tcl_tk_libdir'"
for i in {1..3}; do stub brew false; done
stub_make_install
run_inline_definition <<DEF
install_package "Python-3.6.2" "http://python.org/ftp/python/3.6.2/Python-3.6.2.tar.gz"
DEF
assert_success
unstub uname
unstub sw_vers
unstub brew
unstub make
assert_build_log <<OUT
Python-3.6.2: CFLAGS="" CPPFLAGS="-I${TMP}/install/include" LDFLAGS="-L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib" PKG_CONFIG_PATH="${TMP}/homebrew-tcl-tk/lib/pkgconfig"
Python-3.6.2: --prefix=${TMP}/install --enable-shared --libdir=${TMP}/install/lib --with-tcltk-libs=-L${TMP}/homebrew-tcl-tk/lib -ltcl$tcl_tk_version -ltk$tcl_tk_version --with-tcltk-includes=-I${TMP}/homebrew-tcl-tk/include
make -j 2
make install
OUT
}
@test "tcl-tk is not linked from Homebrew when explicitly defined" {
cached_tarball "Python-3.6.2"
# python build
tcl_tk_version_long="8.6.10"
tcl_tk_version="${tcl_tk_version_long%.*}"
for i in {1..8}; do stub uname '-s : echo Darwin'; done
for i in {1..2}; do stub sw_vers '-productVersion : echo 1010'; done
for i in {1..4}; do stub brew false; done
stub_make_install
export PYTHON_CONFIGURE_OPTS="--with-tcltk-libs='-L${TMP}/custom-tcl-tk/lib -ltcl$tcl_tk_version -ltk$tcl_tk_version'"
run_inline_definition <<DEF
install_package "Python-3.6.2" "http://python.org/ftp/python/3.6.2/Python-3.6.2.tar.gz"
DEF
assert_success
unstub uname
unstub sw_vers
unstub brew
unstub make
assert_build_log <<OUT
Python-3.6.2: CFLAGS="" CPPFLAGS="-I${TMP}/install/include" LDFLAGS="-L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib" PKG_CONFIG_PATH=""
Python-3.6.2: --prefix=$INSTALL_ROOT --enable-shared --libdir=$INSTALL_ROOT/lib --with-tcltk-libs=-L${TMP}/custom-tcl-tk/lib -ltcl8.6 -ltk8.6
make -j 2
make install
OUT
}
@test "tcl-tk is linked from Homebrew via pkgconfig only when envvar is set" {
cached_tarball "Python-3.6.2"
for i in {1..9}; do stub uname '-s : echo Darwin'; done
for i in {1..2}; do stub sw_vers '-productVersion : echo 1010'; done
tcl_tk_libdir="$TMP/homebrew-tcl-tk"
mkdir -p "$tcl_tk_libdir/lib"
stub brew false
stub brew "--prefix tcl-tk@8 : echo '${tcl_tk_libdir}'"
for i in {1..3}; do stub brew false; done
stub_make_install
run_inline_definition <<DEF
export PYTHON_BUILD_TCLTK_USE_PKGCONFIG=1
install_package "Python-3.6.2" "http://python.org/ftp/python/3.6.2/Python-3.6.2.tar.gz"
DEF
assert_success
unstub uname
unstub sw_vers
unstub brew
unstub make
assert_build_log <<OUT
Python-3.6.2: CFLAGS="" CPPFLAGS="-I${TMP}/install/include" LDFLAGS="-L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib" PKG_CONFIG_PATH="${TMP}/homebrew-tcl-tk/lib/pkgconfig"
Python-3.6.2: --prefix=${TMP}/install --enable-shared --libdir=${TMP}/install/lib
make -j 2
make install
OUT
}
@test "number of CPU cores defaults to 2" {
cached_tarball "Python-3.6.2"
for i in {1..10}; do stub uname '-s : echo Darwin'; done
for i in {1..2}; do stub sw_vers '-productVersion : echo 10.10'; done
stub sysctl false
stub_make_install
export -n MAKE_OPTS
run_inline_definition <<DEF
install_package "Python-3.6.2" "http://python.org/ftp/python/3.6.2/Python-3.6.2.tar.gz"
DEF
assert_success
unstub uname
unstub sw_vers
unstub make
assert_build_log <<OUT
Python-3.6.2: CFLAGS="" CPPFLAGS="-I${TMP}/install/include" LDFLAGS="-L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib" PKG_CONFIG_PATH=""
Python-3.6.2: --prefix=$INSTALL_ROOT --enable-shared --libdir=$INSTALL_ROOT/lib
make -j 2
make install
OUT
}
@test "number of CPU cores is detected on Mac" {
cached_tarball "Python-3.6.2"
for i in {1..10}; do stub uname '-s : echo Darwin'; done
for i in {1..2}; do stub sw_vers '-productVersion : echo 10.10'; done
stub sysctl '-n hw.ncpu : echo 4'
stub_make_install
export -n MAKE_OPTS
run_inline_definition <<DEF
install_package "Python-3.6.2" "http://python.org/ftp/python/3.6.2/Python-3.6.2.tar.gz"
DEF
assert_success
unstub uname
unstub sw_vers
unstub sysctl
unstub make
assert_build_log <<OUT
Python-3.6.2: CFLAGS="" CPPFLAGS="-I${TMP}/install/include" LDFLAGS="-L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib" PKG_CONFIG_PATH=""
Python-3.6.2: --prefix=$INSTALL_ROOT --enable-shared --libdir=$INSTALL_ROOT/lib
make -j 4
make install
OUT
}
@test "number of CPU cores is detected on FreeBSD" {
cached_tarball "Python-3.6.2"
for i in {1..7}; do stub uname '-s : echo FreeBSD'; done
stub uname '-r : echo 11.0-RELEASE'
for i in {1..3}; do stub uname '-s : echo FreeBSD'; done
for i in {1..3}; do stub pkg false; done
stub sysctl '-n hw.ncpu : echo 1'
stub_make_install
export -n MAKE_OPTS
run_inline_definition <<DEF
install_package "Python-3.6.2" "http://python.org/ftp/python/3.6.2/Python-3.6.2.tar.gz"
DEF
assert_success
unstub uname
unstub sysctl
unstub make
assert_build_log <<OUT
Python-3.6.2: CFLAGS="" CPPFLAGS="-I${TMP}/install/include" LDFLAGS="-L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib" PKG_CONFIG_PATH=""
Python-3.6.2: --prefix=$INSTALL_ROOT --enable-shared --libdir=$INSTALL_ROOT/lib
make -j 1
make install
OUT
}
@test "setting PYTHON_MAKE_INSTALL_OPTS to a multi-word string" {
cached_tarball "Python-3.6.2"
for i in {1..9}; do stub uname '-s : echo Linux'; done
stub_make_install
export PYTHON_MAKE_INSTALL_OPTS="DOGE=\"such wow\""
run_inline_definition <<DEF
install_package "Python-3.6.2" "http://python.org/ftp/python/3.6.2/Python-3.6.2.tar.gz"
DEF
assert_success
unstub uname
unstub make
assert_build_log <<OUT
Python-3.6.2: CFLAGS="" CPPFLAGS="-I${TMP}/install/include" LDFLAGS="-L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib" PKG_CONFIG_PATH=""
Python-3.6.2: --prefix=$INSTALL_ROOT --enable-shared --libdir=$INSTALL_ROOT/lib
make -j 2
make install DOGE="such wow"
OUT
}
@test "--enable-shared is not added if --disable-shared is passed" {
cached_tarball "Python-3.6.2"
for i in {1..9}; do stub uname '-s : echo Linux'; done
stub_make_install
export PYTHON_CONFIGURE_OPTS='--disable-shared'
run_inline_definition <<DEF
install_package "Python-3.6.2" "http://python.org/ftp/python/3.6.2/Python-3.6.2.tar.gz"
DEF
assert_success
unstub uname
unstub make
assert_build_log <<OUT
Python-3.6.2: CFLAGS="" CPPFLAGS="-I${TMP}/install/include" LDFLAGS="-L${TMP}/install/lib" PKG_CONFIG_PATH=""
Python-3.6.2: --prefix=$INSTALL_ROOT --libdir=$INSTALL_ROOT/lib --disable-shared
make -j 2
make install
OUT
}
@test "configuring with dSYM in MacOS" {
cached_tarball "Python-3.6.2"
for i in {1..10}; do stub uname '-s : echo Darwin'; done
for i in {1..2}; do stub sw_vers '-productVersion : echo 1010'; done
for i in {1..6}; do stub brew false; done
stub_make_install
run_inline_definition <<DEF
export PYTHON_BUILD_CONFIGURE_WITH_DSYMUTIL=1
install_package "Python-3.6.2" "http://python.org/ftp/python/3.6.2/Python-3.6.2.tar.gz"
DEF
assert_success
unstub sw_vers
unstub uname
unstub brew
unstub make
assert_build_log <<OUT
Python-3.6.2: CFLAGS="" CPPFLAGS="-I${TMP}/install/include" LDFLAGS="-L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib" PKG_CONFIG_PATH=""
Python-3.6.2: --prefix=$INSTALL_ROOT --enable-shared --libdir=${TMP}/install/lib --with-dsymutil
make -j 2
make install
OUT
}
@test "configuring with dSYM has no effect in non-MacOS" {
cached_tarball "Python-3.6.2"
for i in {1..10}; do stub uname '-s : echo Linux'; done
stub_make_install
run_inline_definition <<DEF
export PYTHON_BUILD_CONFIGURE_WITH_DSYMUTIL=1
install_package "Python-3.6.2" "http://python.org/ftp/python/3.6.2/Python-3.6.2.tar.gz"
DEF
assert_success
unstub uname
unstub make
assert_build_log <<OUT
Python-3.6.2: CFLAGS="" CPPFLAGS="-I${TMP}/install/include" LDFLAGS="-L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib" PKG_CONFIG_PATH=""
Python-3.6.2: --prefix=$INSTALL_ROOT --enable-shared --libdir=${TMP}/install/lib
make -j 2
make install
OUT
}
@test "custom relative install destination" {
export PYTHON_BUILD_CACHE_PATH="$FIXTURE_ROOT"
cd "$TMP"
install_fixture definitions/without-checksum ./here
assert_success
assert [ -x ./here/bin/package ]
}
@test "make on FreeBSD 9 defaults to gmake" {
cached_tarball "Python-3.6.2"
stub uname "-s : echo FreeBSD" "-r : echo 9.1"
for i in {1..6}; do stub uname "-s : echo FreeBSD"; done
stub uname "-r : echo 9.1"
for i in {1..3}; do stub uname "-s : echo FreeBSD"; done
MAKE=gmake stub_make_install
MAKE= install_fixture definitions/vanilla-python
assert_success
unstub gmake
unstub uname
}
@test "make on FreeBSD 10" {
cached_tarball "Python-3.6.2"
stub uname "-s : echo FreeBSD" "-r : echo 10.0-RELEASE"
for i in {1..6}; do stub uname "-s : echo FreeBSD"; done
stub uname "-r : echo 10.0-RELEASE"
for i in {1..3}; do stub uname "-s : echo FreeBSD"; done
stub_make_install
MAKE= install_fixture definitions/vanilla-python
assert_success
unstub uname
}
@test "make on FreeBSD 11" {
cached_tarball "Python-3.6.2"
stub uname "-s : echo FreeBSD" "-r : echo 11.0-RELEASE"
for i in {1..6}; do stub uname "-s : echo FreeBSD"; done
stub uname "-r : echo 11.0-RELEASE"
for i in {1..3}; do stub uname "-s : echo FreeBSD"; done
stub_make_install
MAKE= install_fixture definitions/vanilla-python
assert_success
unstub uname
}
@test "can use PYTHON_CONFIGURE to apply a patch" {
cached_tarball "Python-3.6.2"
executable "${TMP}/custom-configure" <<CONF
#!$BASH
apply -p1 -i /my/patch.diff
exec ./configure "\$@"
CONF
for i in {1..9}; do stub uname '-s : echo Linux'; done
stub apply 'echo apply "$@" >> build.log'
stub_make_install
export PYTHON_CONFIGURE="${TMP}/custom-configure"
run_inline_definition <<DEF
install_package "Python-3.6.2" "http://python.org/ftp/python/3.6.2/Python-3.6.2.tar.gz"
DEF
assert_success
unstub uname
unstub make
unstub apply
assert_build_log <<OUT
apply -p1 -i /my/patch.diff
Python-3.6.2: CFLAGS="" CPPFLAGS="-I${TMP}/install/include" LDFLAGS="-L${TMP}/install/lib -Wl,-rpath,${TMP}/install/lib" PKG_CONFIG_PATH=""
Python-3.6.2: --prefix=$INSTALL_ROOT --enable-shared --libdir=$INSTALL_ROOT/lib
make -j 2
make install
OUT
}
|