diff options
| author | samueljohn | 2012-09-04 13:31:42 +0200 | 
|---|---|---|
| committer | Adam Vandenberg | 2012-09-04 07:50:14 -0700 | 
| commit | f20d35ac2f94c4bcb87dcd748ed46c18cabdc8f5 (patch) | |
| tree | 20a712621af5cb4684a0d040b3e20215a7613f43 /Library/Formula/python.rb | |
| parent | d04431664a6116bf37665b6a3ddb486c2d90b036 (diff) | |
| download | homebrew-f20d35ac2f94c4bcb87dcd748ed46c18cabdc8f5.tar.bz2 | |
python2/3: Harden against other pythons. Pip 1.2
- Unset PYTHONPATH and PYTHONHOME which would lead to install distribute and
  pip into the wrong python.
- For NCLT: Add to CPPFLAGS the path to zlib via -I because python's setup.py
  scans only these flags.
- '-Qunused-arguments' can be added after ENV.enable_warnings to reduce
  noise. The only thing which we must not add is the "-w" switch!
- For python.rb only: Pass "--no-user-cfg" to python setup.py and add --force
  when installing distribute and pip to ensure overwriting with the new ones.
Closes #14689.
Closes #14686.
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
Diffstat (limited to 'Library/Formula/python.rb')
| -rw-r--r-- | Library/Formula/python.rb | 20 | 
1 files changed, 16 insertions, 4 deletions
diff --git a/Library/Formula/python.rb b/Library/Formula/python.rb index e7ef09b3a..49c3c3bde 100644 --- a/Library/Formula/python.rb +++ b/Library/Formula/python.rb @@ -21,8 +21,8 @@ class Distribute < Formula  end  class Pip < Formula -  url 'http://pypi.python.org/packages/source/p/pip/pip-1.1.tar.gz' -  sha1 '842c4e2aff3f016feea3c6e992c7fa96e49c9aa0' +  url 'http://pypi.python.org/packages/source/p/pip/pip-1.2.tar.gz' +  sha1 '7876f943cfbb0bbb725c2761879de2889c1fe93b'  end  class Python < Formula @@ -62,6 +62,11 @@ class Python < Formula    end    def install +    # Unset these so that installing pip and distribute puts them where we want +    # and not into some other Python the user has installed. +    ENV['PYTHONPATH'] = nil +    ENV['PYTHONHOME'] = nil +      args = %W[               --prefix=#{prefix}               --enable-ipv6 @@ -72,6 +77,12 @@ class Python < Formula      args << '--without-gcc' if ENV.compiler == :clang +    # Further, 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 @@ -85,6 +96,7 @@ class Python < Formula        # 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' +      ENV.append_to_cflags '-Qunused-arguments'      end      if build.universal? @@ -128,8 +140,8 @@ class Python < Formula      EOF      # Install distribute and pip -    Distribute.new.brew { system "#{bin}/python", "setup.py", "install" } -    Pip.new.brew { system "#{bin}/python", "setup.py", "install" } +    Distribute.new.brew { system "#{bin}/python", "setup.py", "--no-user-cfg", "install", "--force" } +    Pip.new.brew { system "#{bin}/python", "setup.py", "--no-user-cfg", "install", "--force" }    end    def caveats  | 
