Skip to content
This repository was archived by the owner on Dec 2, 2020. It is now read-only.

Added support for allow_external and allow_unverified arguments on pip #30

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 19 additions & 45 deletions files/brews/python.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
require "formula"

class Python < Formula
homepage "http://www.python.org"
head "http://hg.python.org/cpython", :using => :hg, :branch => "2.7"
url "http://www.python.org/ftp/python/2.7.8/Python-2.7.8.tgz"
sha1 "511960dd78451a06c9df76509635aeec05b2051a"
version '2.7.8-boxen1'
homepage "https://www.python.org"
head "https://hg.python.org/cpython", :using => :hg, :branch => "2.7"
url "https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tgz"
sha1 "7a191bcccb598ccbf2fa6a0edce24a97df3fc0ad"
version '2.7.9-boxen1'

bottle do
revision 2
sha1 "f1244c117036a733742f128f8a168dcb0568675d" => :mavericks
sha1 "41f27fc515410ff728316e994be6f471520e5c90" => :mountain_lion
sha1 "cab018e86b60e5a8a8115581a2aa3390b18b3080" => :lion
revision 7
sha1 "a81d7c350cebe4e50cfaa7bcfebec8174fc0d83a" => :yosemite
sha1 "f25fcc726f9fee63d9450da2788c71d76a4337b3" => :mavericks
sha1 "903b4cd31563b3bbf6beea3ecce95ae35689d5e1" => :mountain_lion
end

# Please don't add a wide/ucs4 option as it won't be accepted.
# More details in: https://github.com/Homebrew/homebrew/pull/32368
option :universal
option "quicktest", "Run `make quicktest` after the build (for devs; may fail)"
option "with-brewed-tk", "Use Homebrew's Tk (has optional Cocoa and threads support)"
option "with-poll", "Enable select.poll, which is not fully implemented on OS X (http://bugs.python.org/issue5154)"
option "with-dtrace", "Experimental DTrace support (http://bugs.python.org/issue13405)"

depends_on "pkg-config" => :build
depends_on "readline" => :recommended
Expand All @@ -32,13 +33,13 @@ class Python < Formula
skip_clean "bin/easy_install", "bin/easy_install-2.7"

resource "setuptools" do
url "https://pypi.python.org/packages/source/s/setuptools/setuptools-5.4.2.tar.gz"
sha1 "a681ba56c30c0eb66528215842d3e3fcb5157614"
url "https://pypi.python.org/packages/source/s/setuptools/setuptools-9.1.tar.gz"
sha1 "b068a670c84df7b961730c6a0d00cd06c7b767f0"
end

resource "pip" do
url "https://pypi.python.org/packages/source/p/pip/pip-1.5.6.tar.gz"
sha1 "e6cd9e6f2fd8d28c9976313632ef8aa8ac31249e"
url "https://pypi.python.org/packages/source/p/pip/pip-6.0.3.tar.gz"
sha1 "67d4affd83ee2f3514ac1386bee59f10f672517c"
end

# Patch for pyport.h macro issue
Expand Down Expand Up @@ -91,13 +92,8 @@ def install
]

args << "--without-gcc" if ENV.compiler == :clang
args << "--with-dtrace" if build.with? "dtrace"

if superenv?
distutils_fix_superenv(args)
else
distutils_fix_stdenv
end
distutils_fix_superenv(args)

if build.universal?
ENV.universal_binary
Expand Down Expand Up @@ -234,30 +230,7 @@ def distutils_fix_superenv(args)
# superenv handles that cc finds includes/libs!
inreplace "setup.py",
"do_readline = self.compiler.find_library_file(lib_dirs, 'readline')",
"do_readline = '#{HOMEBREW_PREFIX}/opt/readline/lib/libhistory.dylib'"
end

def distutils_fix_stdenv
# Python scans all "-I" dirs but not "-isysroot", so we add
# the needed includes with "-I" here to avoid this err:
# building dbm using ndbm
# error: /usr/include/zlib.h: No such file or directory
ENV.append "CPPFLAGS", "-I#{MacOS.sdk_path}/usr/include" unless MacOS::CLT.installed?

# Don't use optimizations other than "-Os" here, because Python's distutils
# remembers (hint: `python-config --cflags`) and reuses them for C
# extensions which can break software (such as scipy 0.11 fails when
# "-msse4" is present.)
ENV.minimal_optimization

# We need to enable warnings because the configure.in uses -Werror to detect
# "whether gcc supports ParseTuple" (https://github.com/Homebrew/homebrew/issues/12194)
ENV.enable_warnings
if ENV.compiler == :clang
# http://docs.python.org/devguide/setup.html#id8 suggests to disable some Warnings.
ENV.append_to_cflags "-Wno-unused-value"
ENV.append_to_cflags "-Wno-empty-body"
end
"do_readline = '#{Formula["readline"].opt_lib}/libhistory.dylib'"
end

def sitecustomize
Expand Down Expand Up @@ -321,7 +294,7 @@ def caveats; <<-EOS.undent
They will install into the site-package directory
#{site_packages}

See: https://github.com/Homebrew/homebrew/wiki/Homebrew-and-Python
See: https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Homebrew-and-Python.md
EOS
end

Expand All @@ -331,6 +304,7 @@ def caveats; <<-EOS.undent
system "#{bin}/python", "-c", "import sqlite3"
# Check if some other modules import. Then the linked libs are working.
system "#{bin}/python", "-c", "import Tkinter; root = Tkinter.Tk()"
system bin/"pip", "list"
end
end

Expand Down
2 changes: 1 addition & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
include xquartz
include python::config

$version = '2.7.8-boxen1'
$version = '2.7.9-boxen1'

homebrew::formula { 'python':
before => Package['boxen/brews/python']
Expand Down
16 changes: 14 additions & 2 deletions manifests/pip.pp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
define python::pip (
$virtualenv,
$ensure = present,
$proxy = false
$proxy = false,
$allow_external = false,
$allow_unverified = false,
) {
require python

Expand All @@ -46,10 +48,20 @@
default => "^${name}==",
}

$allow_external_flag = $allow_external ? {
false => '',
default => "--allow-external ${name}",
}

$allow_unverified_flag = $allow_unverified ? {
false => '',
default => "--allow-unverified ${name}",
}

case $ensure {
present: {
exec { "pip_install_${name}":
command => "${virtualenv}/bin/pip install ${proxy_flag} ${name}",
command => "${virtualenv}/bin/pip install ${proxy_flag} ${allow_external_flag} ${allow_unverified_flag} ${name}",
unless => "${virtualenv}/bin/pip freeze | grep -i -e ${grep_regex}",
}
}
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/python_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
should contain_homebrew__formula('python').with(
:before => 'Package[boxen/brews/python]'
)
should contain_package('boxen/brews/python').with_ensure('2.7.8-boxen1')
should contain_package('boxen/brews/python').with_ensure('2.7.9-boxen1')

should contain_file('/opt/boxen/env.d/python.sh').with(
:source => 'puppet:///modules/python/python.sh'
Expand Down