├── README.md ├── python33.rb ├── python34.rb ├── python35.rb └── python36.rb /README.md: -------------------------------------------------------------------------------- 1 | # homebrew-python 2 | 3 | This [Homebrew](http://brew.sh) tap provides formulæ to install multiple Python versions. 4 | 5 | We currently support Python 3.3.6, Python 3.4.3, and Python 3.5.0. 6 | 7 | ## How do I install these formulæ? 8 | 9 | `brew install zoidbergwill/python/` 10 | 11 | Or `brew tap zoidbergwill/python` and then `brew install `. 12 | 13 | ## Usage 14 | 15 | ```sh 16 | $ brew install python34 17 | $ pip3.4 install -U pip setuptools 18 | ``` 19 | 20 | We don't ever install to `pip3`, `pyvenv`, or `python3`, since we don't know which Python version you want to use in general. Eventually I hope to add support for that somehow, though using [pyenv](https://github.com/yyuu/pyenv) might be a better solution. 21 | 22 | ## Troubleshooting 23 | Please check the main [Homebrew troubleshooting guide](https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Troubleshooting.md#troubleshooting) and then [open an issue in this tap](https://github.com/Homebrew/homebrew-python/issues/new). 24 | 25 | ## How to submit a new formula 26 | * Fork this repository on GitHub. 27 | * Clone to your Mac. 28 | * Read [Python for Formula Authors](https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Python-for-Formula-Authors.md) and look at the other formulæ here. 29 | * In your locally cloned `homebrew-python` repo, create a new branch: `git checkout --branch my_new_formula` 30 | * Write/edit your formula (ruby file). Check [Homebrew's documentation](https://github.com/Homebrew/homebrew/tree/master/share/doc/homebrew#readme) for details. 31 | * Test it locally! `brew install ./my-new-formula.rb`. Does it install? Note, `./.rb` will target the local file. 32 | * `git push --set-upstream origin my-new-formula` to get it into your GitHub fork as a new branch. 33 | * If you have to change something, add a commit and `git push`. 34 | * On GitHub, select your new branch and then click the "Pull Request" button. 35 | -------------------------------------------------------------------------------- /python33.rb: -------------------------------------------------------------------------------- 1 | class Python33 < Formula 2 | desc "Interpreted, interactive, object-oriented programming language" 3 | homepage "https://www.python.org/" 4 | url 'https://www.python.org/ftp/python/3.3.6/Python-3.3.6.tgz' 5 | sha256 '0a58ad1f1def4ecc90b18b0c410a3a0e1a48cf7692c75d1f83d0af080e5d2034' 6 | revision 2 7 | 8 | head "https://hg.python.org/cpython", :using => :hg, :branch => '3.3' 9 | 10 | option :universal 11 | option "with-tcl-tk", "Use Homebrew's Tk instead of OS X Tk (has optional Cocoa and threads support)" 12 | option "with-quicktest", "Run `make quicktest` after the build" 13 | 14 | deprecated_option "quicktest" => "with-quicktest" 15 | deprecated_option "with-brewed-tk" => "with-tcl-tk" 16 | 17 | depends_on "pkg-config" => :build 18 | depends_on "readline" => :recommended 19 | depends_on "sqlite" => :recommended 20 | depends_on "gdbm" => :recommended 21 | depends_on "openssl" 22 | depends_on "xz" => :recommended # for the lzma module added in 3.3 23 | depends_on "homebrew/dupes/tcl-tk" => :optional 24 | depends_on :x11 if build.with?("tcl-tk") && Tab.for_name("homebrew/dupes/tcl-tk").with?("x11") 25 | 26 | skip_clean "bin/pip3", "bin/pip-3.3" 27 | skip_clean "bin/easy_install3", "bin/easy_install-3.3" 28 | 29 | resource "setuptools" do 30 | url "https://pypi.python.org/packages/source/s/setuptools/setuptools-19.4.tar.gz" 31 | sha256 "214bf29933f47cf25e6faa569f710731728a07a19cae91ea64f826051f68a8cf" 32 | end 33 | 34 | resource "pip" do 35 | url "https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz" 36 | sha256 "46f4bd0d8dfd51125a554568d646fe4200a3c2c6c36b9f2d06d2212148439521" 37 | end 38 | 39 | resource "wheel" do 40 | url "https://pypi.python.org/packages/source/w/wheel/wheel-0.26.0.tar.gz" 41 | sha256 "eaad353805c180a47545a256e6508835b65a8e830ba1093ed8162f19a50a530c" 42 | end 43 | 44 | # Homebrew's tcl-tk is built in a standard unix fashion (due to link errors) 45 | # so we have to stop python from searching for frameworks and linking against 46 | # X11. 47 | patch :DATA if build.with? "tcl-tk" 48 | 49 | def lib_cellar 50 | prefix/"Frameworks/Python.framework/Versions/#{xy}/lib/python#{xy}" 51 | end 52 | 53 | def site_packages_cellar 54 | lib_cellar/"site-packages" 55 | end 56 | 57 | # The HOMEBREW_PREFIX location of site-packages. 58 | def site_packages 59 | HOMEBREW_PREFIX/"lib/python#{xy}/site-packages" 60 | end 61 | 62 | fails_with :llvm do 63 | build 2336 64 | cause <<-EOS.undent 65 | Could not find platform dependent libraries 66 | Consider setting $PYTHONHOME to [:] 67 | python.exe(14122) malloc: *** mmap(size=7310873954244194304) failed (error code=12) 68 | *** error: can't allocate region 69 | *** set a breakpoint in malloc_error_break to debug 70 | Could not import runpy module 71 | make: *** [pybuilddir.txt] Segmentation fault: 11 72 | EOS 73 | end 74 | 75 | # setuptools remembers the build flags python is built with and uses them to 76 | # build packages later. Xcode-only systems need different flags. 77 | def pour_bottle? 78 | MacOS::CLT.installed? 79 | end 80 | 81 | def install 82 | # Unset these so that installing pip and setuptools puts them where we want 83 | # and not into some other Python the user has installed. 84 | ENV["PYTHONHOME"] = nil 85 | ENV["PYTHONPATH"] = nil 86 | 87 | args = %W[ 88 | --prefix=#{prefix} 89 | --enable-ipv6 90 | --datarootdir=#{share} 91 | --datadir=#{share} 92 | --enable-framework=#{frameworks} 93 | --without-ensurepip 94 | ] 95 | 96 | args << "--without-gcc" if ENV.compiler == :clang 97 | 98 | unless MacOS::CLT.installed? 99 | # Help Python's build system (setuptools/pip) to build things on Xcode-only systems 100 | # The setup.py looks at "-isysroot" to get the sysroot (and not at --sysroot) 101 | cflags = "CFLAGS=-isysroot #{MacOS.sdk_path}" 102 | ldflags = "LDFLAGS=-isysroot #{MacOS.sdk_path}" 103 | args << "CPPFLAGS=-I#{MacOS.sdk_path}/usr/include" # find zlib 104 | if build.without? "tcl-tk" 105 | cflags += " -I#{MacOS.sdk_path}/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers" 106 | end 107 | args << cflags 108 | args << ldflags 109 | end 110 | # Avoid linking to libgcc http://code.activestate.com/lists/python-dev/112195/ 111 | args << "MACOSX_DEPLOYMENT_TARGET=#{MacOS.version}" 112 | 113 | # We want our readline and openssl! This is just to outsmart the detection code, 114 | # superenv makes cc always find includes/libs! 115 | inreplace "setup.py" do |s| 116 | s.gsub! "do_readline = self.compiler.find_library_file(lib_dirs, 'readline')", 117 | "do_readline = '#{Formula["readline"].opt_lib}/libhistory.dylib'" 118 | s.gsub! "/usr/local/ssl", Formula["openssl"].opt_prefix 119 | end 120 | 121 | if build.universal? 122 | ENV.universal_binary 123 | args << "--enable-universalsdk" << "--with-universal-archs=intel" 124 | end 125 | 126 | # Allow sqlite3 module to load extensions: http://docs.python.org/library/sqlite3.html#f1 127 | inreplace("setup.py", 'sqlite_defines.append(("SQLITE_OMIT_LOAD_EXTENSION", "1"))', "pass") if build.with? "sqlite" 128 | 129 | # Allow python modules to use ctypes.find_library to find homebrew's stuff 130 | # even if homebrew is not a /usr/local/lib. Try this with: 131 | # `brew install enchant && pip install pyenchant` 132 | inreplace "./Lib/ctypes/macholib/dyld.py" do |f| 133 | f.gsub! "DEFAULT_LIBRARY_FALLBACK = [", "DEFAULT_LIBRARY_FALLBACK = [ '#{HOMEBREW_PREFIX}/lib'," 134 | f.gsub! "DEFAULT_FRAMEWORK_FALLBACK = [", "DEFAULT_FRAMEWORK_FALLBACK = [ '#{HOMEBREW_PREFIX}/Frameworks'," 135 | end 136 | 137 | if build.with? "tcl-tk" 138 | tcl_tk = Formula["tcl-tk"].opt_prefix 139 | ENV.append "CPPFLAGS", "-I#{tcl_tk}/include" 140 | ENV.append "LDFLAGS", "-L#{tcl_tk}/lib" 141 | end 142 | 143 | system "./configure", *args 144 | 145 | system "make" 146 | 147 | ENV.deparallelize # Installs must be serialized 148 | # Tell Python not to install into /Applications (default for framework builds) 149 | system "make", "altinstall", "PYTHONAPPSDIR=#{prefix}" 150 | # Demos and Tools 151 | system "make", "frameworkinstallextras", "PYTHONAPPSDIR=#{share}/python3" 152 | system "make", "quicktest" if build.include? "quicktest" 153 | 154 | # Any .app get a " 3.3" attached, so it does not conflict with python 2.x, 155 | # and other python 3.x installations. 156 | Dir.glob("#{prefix}/*.app") { |app| mv app, app.sub(".app", " 3.3.app") } 157 | 158 | # A fix, because python and python3 both want to install Python.framework 159 | # and therefore we can't link both into HOMEBREW_PREFIX/Frameworks 160 | # https://github.com/Homebrew/homebrew/issues/15943 161 | ["Headers", "Python", "Resources"].each { |f| rm(prefix/"Frameworks/Python.framework/#{f}") } 162 | rm prefix/"Frameworks/Python.framework/Versions/Current" 163 | 164 | # Symlink the pkgconfig files into HOMEBREW_PREFIX so they're accessible. 165 | (lib/"pkgconfig").install_symlink Dir["#{frameworks}/Python.framework/Versions/#{xy}/lib/pkgconfig/*"] 166 | 167 | # Remove the site-packages that Python created in its Cellar. 168 | site_packages_cellar.rmtree 169 | 170 | # These makevars are available through distutils.sysconfig at runtime and 171 | # some third-party software packages depend on them 172 | inreplace frameworks/"Python.framework/Versions/#{xy}/lib/python#{xy}/config-#{xy}m/Makefile" do |s| 173 | s.change_make_var! "LINKFORSHARED", 174 | "-u _PyMac_Error #{opt_prefix}/Frameworks/Python.framework/Versions/#{xy}/Python" 175 | end 176 | 177 | %w[setuptools pip wheel].each do |r| 178 | (libexec/r).install resource(r) 179 | end 180 | end 181 | 182 | def post_install 183 | # Fix up the site-packages so that user-installed Python software survives 184 | # minor updates, such as going from 3.3.2 to 3.3.3: 185 | 186 | # Create a site-packages in HOMEBREW_PREFIX/lib/python#{xy}/site-packages 187 | site_packages.mkpath 188 | 189 | # Symlink the prefix site-packages into the cellar. 190 | site_packages_cellar.unlink if site_packages_cellar.exist? 191 | site_packages_cellar.parent.install_symlink site_packages 192 | 193 | # Write our sitecustomize.py 194 | rm_rf Dir["#{site_packages}/sitecustomize.py[co]"] 195 | (site_packages/"sitecustomize.py").atomic_write(sitecustomize) 196 | 197 | # Remove old setuptools installations that may still fly around and be 198 | # listed in the easy_install.pth. This can break setuptools build with 199 | # zipimport.ZipImportError: bad local file header 200 | # setuptools-0.9.8-py3.3.egg 201 | rm_rf Dir["#{site_packages}/setuptools*"] 202 | rm_rf Dir["#{site_packages}/distribute*"] 203 | rm_rf Dir["#{site_packages}/pip[-_.][0-9]*", "#{site_packages}/pip"] 204 | 205 | %w[setuptools pip wheel].each do |pkg| 206 | (libexec/pkg).cd do 207 | system bin/"python3.3", "-s", "setup.py", "install", 208 | "--force", "--verbose", "--install-scripts=#{bin}", 209 | "--install-lib=#{site_packages}", 210 | "--single-version-externally-managed", 211 | "--record=installed.txt" 212 | end 213 | end 214 | 215 | rm_rf [bin/"pip", bin/"easy_install", bin/"pyvenv"] 216 | mv bin/"wheel", bin/"wheel3.3" 217 | 218 | # post_install happens after link 219 | %W[pip#{xy} easy_install-#{xy} wheel#{xy}].each do |e| 220 | (HOMEBREW_PREFIX/"bin").install_symlink bin/e 221 | end 222 | 223 | # Help distutils find brewed stuff when building extensions 224 | include_dirs = [HOMEBREW_PREFIX/"include", Formula["openssl"].opt_include] 225 | library_dirs = [HOMEBREW_PREFIX/"lib", Formula["openssl"].opt_lib] 226 | 227 | if build.with? "sqlite" 228 | include_dirs << Formula["sqlite"].opt_include 229 | library_dirs << Formula["sqlite"].opt_lib 230 | end 231 | 232 | if build.with? "tcl-tk" 233 | include_dirs << Formula["homebrew/dupes/tcl-tk"].opt_include 234 | library_dirs << Formula["homebrew/dupes/tcl-tk"].opt_lib 235 | end 236 | 237 | cfg = lib_cellar/"distutils/distutils.cfg" 238 | cfg.atomic_write <<-EOF.undent 239 | [install] 240 | prefix=#{HOMEBREW_PREFIX} 241 | 242 | [build_ext] 243 | include_dirs=#{include_dirs.join ":"} 244 | library_dirs=#{library_dirs.join ":"} 245 | EOF 246 | end 247 | 248 | def xy 249 | version.to_s.slice(/(3.\d)/) || "3.6" 250 | end 251 | 252 | def sitecustomize 253 | <<-EOF.undent 254 | # This file is created by Homebrew and is executed on each python startup. 255 | # Don't print from here, or else python command line scripts may fail! 256 | # 257 | import re 258 | import os 259 | import sys 260 | 261 | if sys.version_info[0] != 3: 262 | # This can only happen if the user has set the PYTHONPATH for 3.x and run Python 2.x or vice versa. 263 | # Every Python looks at the PYTHONPATH variable and we can't fix it here in sitecustomize.py, 264 | # because the PYTHONPATH is evaluated after the sitecustomize.py. Many modules (e.g. PyQt4) are 265 | # built only for a specific version of Python and will fail with cryptic error messages. 266 | # In the end this means: Don't set the PYTHONPATH permanently if you use different Python versions. 267 | exit('Your PYTHONPATH points to a site-packages dir for Python 3.x but you are running Python ' + 268 | str(sys.version_info[0]) + '.x!\\n PYTHONPATH is currently: "' + str(os.environ['PYTHONPATH']) + '"\\n' + 269 | ' You should `unset PYTHONPATH` to fix this.') 270 | 271 | # Only do this for a brewed python: 272 | if os.path.realpath(sys.executable).startswith('#{rack}'): 273 | # Shuffle /Library site-packages to the end of sys.path 274 | library_site = '/Library/Python/#{xy}/site-packages' 275 | library_packages = [p for p in sys.path if p.startswith(library_site)] 276 | sys.path = [p for p in sys.path if not p.startswith(library_site)] 277 | # .pth files have already been processed so don't use addsitedir 278 | sys.path.extend(library_packages) 279 | 280 | # the Cellar site-packages is a symlink to the HOMEBREW_PREFIX 281 | # site_packages; prefer the shorter paths 282 | long_prefix = re.compile(r'#{rack}/[0-9\._abrc]+/Frameworks/Python\.framework/Versions/#{xy}/lib/python#{xy}/site-packages') 283 | sys.path = [long_prefix.sub('#{site_packages}', p) for p in sys.path] 284 | 285 | # Set the sys.executable to use the opt_prefix 286 | sys.executable = '#{opt_bin}/python#{xy}' 287 | EOF 288 | end 289 | 290 | def caveats 291 | text = <<-EOS.undent 292 | Pip and setuptools have been installed. To update them 293 | pip3.3 install --upgrade pip setuptools 294 | 295 | You can install Python packages with 296 | pip3.3 install 297 | 298 | They will install into the site-package directory 299 | #{site_packages} 300 | 301 | See: https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Homebrew-and-Python.md 302 | EOS 303 | 304 | # Tk warning only for 10.6 305 | tk_caveats = <<-EOS.undent 306 | 307 | Apple's Tcl/Tk is not recommended for use with Python on Mac OS X 10.6. 308 | For more information see: http://www.python.org/download/mac/tcltk/ 309 | EOS 310 | 311 | text += tk_caveats unless MacOS.version >= :lion 312 | text 313 | end 314 | 315 | test do 316 | # Check if sqlite is ok, because we build with --enable-loadable-sqlite-extensions 317 | # and it can occur that building sqlite silently fails if OSX's sqlite is used. 318 | system "#{bin}/python#{xy}", "-c", "import sqlite3" 319 | # Check if some other modules import. Then the linked libs are working. 320 | system "#{bin}/python#{xy}", "-c", "import tkinter; root = tkinter.Tk()" 321 | system bin/"pip3.3", "list" 322 | end 323 | end 324 | 325 | __END__ 326 | diff --git a/setup.py b/setup.py 327 | index 2779658..902d0eb 100644 328 | --- a/setup.py 329 | +++ b/setup.py 330 | @@ -1699,9 +1699,6 @@ class PyBuildExt(build_ext): 331 | # Rather than complicate the code below, detecting and building 332 | # AquaTk is a separate method. Only one Tkinter will be built on 333 | # Darwin - either AquaTk, if it is found, or X11 based Tk. 334 | - if (host_platform == 'darwin' and 335 | - self.detect_tkinter_darwin(inc_dirs, lib_dirs)): 336 | - return 337 | 338 | # Assume we haven't found any of the libraries or include files 339 | # The versions with dots are used on Unix, and the versions without 340 | @@ -1747,22 +1744,6 @@ class PyBuildExt(build_ext): 341 | if dir not in include_dirs: 342 | include_dirs.append(dir) 343 | 344 | - # Check for various platform-specific directories 345 | - if host_platform == 'sunos5': 346 | - include_dirs.append('/usr/openwin/include') 347 | - added_lib_dirs.append('/usr/openwin/lib') 348 | - elif os.path.exists('/usr/X11R6/include'): 349 | - include_dirs.append('/usr/X11R6/include') 350 | - added_lib_dirs.append('/usr/X11R6/lib64') 351 | - added_lib_dirs.append('/usr/X11R6/lib') 352 | - elif os.path.exists('/usr/X11R5/include'): 353 | - include_dirs.append('/usr/X11R5/include') 354 | - added_lib_dirs.append('/usr/X11R5/lib') 355 | - else: 356 | - # Assume default location for X11 357 | - include_dirs.append('/usr/X11/include') 358 | - added_lib_dirs.append('/usr/X11/lib') 359 | - 360 | # If Cygwin, then verify that X is installed before proceeding 361 | if host_platform == 'cygwin': 362 | x11_inc = find_file('X11/Xlib.h', [], include_dirs) 363 | @@ -1786,10 +1767,6 @@ class PyBuildExt(build_ext): 364 | if host_platform in ['aix3', 'aix4']: 365 | libs.append('ld') 366 | 367 | - # Finally, link with the X11 libraries (not appropriate on cygwin) 368 | - if host_platform != "cygwin": 369 | - libs.append('X11') 370 | - 371 | ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], 372 | define_macros=[('WITH_APPINIT', 1)] + defs, 373 | include_dirs = include_dirs, 374 | -------------------------------------------------------------------------------- /python34.rb: -------------------------------------------------------------------------------- 1 | class Python34 < Formula 2 | desc "Interpreted, interactive, object-oriented programming language" 3 | homepage "https://www.python.org/" 4 | head "https://hg.python.org/cpython", :using => :hg, :branch => "3.4" 5 | url "https://www.python.org/ftp/python/3.4.5/Python-3.4.5.tar.xz" 6 | sha256 "ee64b1c8a47461009abf25252332d29a4e587cb4f0c1c96aa793a3732e9d898a" 7 | 8 | option :universal 9 | option "with-tcl-tk", "Use Homebrew's Tk instead of OS X Tk (has optional Cocoa and threads support)" 10 | option "with-quicktest", "Run `make quicktest` after the build" 11 | 12 | deprecated_option "quicktest" => "with-quicktest" 13 | deprecated_option "with-brewed-tk" => "with-tcl-tk" 14 | 15 | depends_on "pkg-config" => :build 16 | depends_on "readline" => :recommended 17 | depends_on "sqlite" => :recommended 18 | depends_on "gdbm" => :recommended 19 | depends_on "openssl" 20 | depends_on "xz" => :recommended # for the lzma module added in 3.3 21 | depends_on "homebrew/dupes/tcl-tk" => :optional 22 | depends_on :x11 if build.with?("tcl-tk") && Tab.for_name("homebrew/dupes/tcl-tk").with?("x11") 23 | 24 | skip_clean "bin/pip3", "bin/pip-3.4" 25 | skip_clean "bin/easy_install3", "bin/easy_install-3.4" 26 | 27 | resource "setuptools" do 28 | url "https://pypi.python.org/packages/source/s/setuptools/setuptools-19.4.tar.gz" 29 | sha256 "214bf29933f47cf25e6faa569f710731728a07a19cae91ea64f826051f68a8cf" 30 | end 31 | 32 | resource "pip" do 33 | url "https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz" 34 | sha256 "46f4bd0d8dfd51125a554568d646fe4200a3c2c6c36b9f2d06d2212148439521" 35 | end 36 | 37 | resource "wheel" do 38 | url "https://pypi.python.org/packages/source/w/wheel/wheel-0.26.0.tar.gz" 39 | sha256 "eaad353805c180a47545a256e6508835b65a8e830ba1093ed8162f19a50a530c" 40 | end 41 | 42 | # Homebrew's tcl-tk is built in a standard unix fashion (due to link errors) 43 | # so we have to stop python from searching for frameworks and linking against 44 | # X11. 45 | patch :DATA if build.with? "tcl-tk" 46 | 47 | def lib_cellar 48 | prefix/"Frameworks/Python.framework/Versions/#{xy}/lib/python#{xy}" 49 | end 50 | 51 | def site_packages_cellar 52 | lib_cellar/"site-packages" 53 | end 54 | 55 | # The HOMEBREW_PREFIX location of site-packages. 56 | def site_packages 57 | HOMEBREW_PREFIX/"lib/python#{xy}/site-packages" 58 | end 59 | 60 | fails_with :llvm do 61 | build 2336 62 | cause <<-EOS.undent 63 | Could not find platform dependent libraries 64 | Consider setting $PYTHONHOME to [:] 65 | python.exe(14122) malloc: *** mmap(size=7310873954244194304) failed (error code=12) 66 | *** error: can't allocate region 67 | *** set a breakpoint in malloc_error_break to debug 68 | Could not import runpy module 69 | make: *** [pybuilddir.txt] Segmentation fault: 11 70 | EOS 71 | end 72 | 73 | # setuptools remembers the build flags python is built with and uses them to 74 | # build packages later. Xcode-only systems need different flags. 75 | def pour_bottle? 76 | MacOS::CLT.installed? 77 | end 78 | 79 | def install 80 | # Unset these so that installing pip and setuptools puts them where we want 81 | # and not into some other Python the user has installed. 82 | ENV["PYTHONHOME"] = nil 83 | ENV["PYTHONPATH"] = nil 84 | 85 | args = %W[ 86 | --prefix=#{prefix} 87 | --enable-ipv6 88 | --datarootdir=#{share} 89 | --datadir=#{share} 90 | --enable-framework=#{frameworks} 91 | --without-ensurepip 92 | ] 93 | 94 | args << "--without-gcc" if ENV.compiler == :clang 95 | 96 | unless MacOS::CLT.installed? 97 | # Help Python's build system (setuptools/pip) to build things on Xcode-only systems 98 | # The setup.py looks at "-isysroot" to get the sysroot (and not at --sysroot) 99 | cflags = "CFLAGS=-isysroot #{MacOS.sdk_path}" 100 | ldflags = "LDFLAGS=-isysroot #{MacOS.sdk_path}" 101 | args << "CPPFLAGS=-I#{MacOS.sdk_path}/usr/include" # find zlib 102 | if build.without? "tcl-tk" 103 | cflags += " -I#{MacOS.sdk_path}/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers" 104 | end 105 | args << cflags 106 | args << ldflags 107 | end 108 | # Avoid linking to libgcc http://code.activestate.com/lists/python-dev/112195/ 109 | args << "MACOSX_DEPLOYMENT_TARGET=#{MacOS.version}" 110 | 111 | # We want our readline and openssl! This is just to outsmart the detection code, 112 | # superenv makes cc always find includes/libs! 113 | inreplace "setup.py" do |s| 114 | s.gsub! "do_readline = self.compiler.find_library_file(lib_dirs, 'readline')", 115 | "do_readline = '#{Formula["readline"].opt_lib}/libhistory.dylib'" 116 | s.gsub! "/usr/local/ssl", Formula["openssl"].opt_prefix 117 | end 118 | 119 | if build.universal? 120 | ENV.universal_binary 121 | args << "--enable-universalsdk" << "--with-universal-archs=intel" 122 | end 123 | 124 | # Allow sqlite3 module to load extensions: http://docs.python.org/library/sqlite3.html#f1 125 | inreplace("setup.py", 'sqlite_defines.append(("SQLITE_OMIT_LOAD_EXTENSION", "1"))', "pass") if build.with? "sqlite" 126 | 127 | # Allow python modules to use ctypes.find_library to find homebrew's stuff 128 | # even if homebrew is not a /usr/local/lib. Try this with: 129 | # `brew install enchant && pip install pyenchant` 130 | inreplace "./Lib/ctypes/macholib/dyld.py" do |f| 131 | f.gsub! "DEFAULT_LIBRARY_FALLBACK = [", "DEFAULT_LIBRARY_FALLBACK = [ '#{HOMEBREW_PREFIX}/lib'," 132 | f.gsub! "DEFAULT_FRAMEWORK_FALLBACK = [", "DEFAULT_FRAMEWORK_FALLBACK = [ '#{HOMEBREW_PREFIX}/Frameworks'," 133 | end 134 | 135 | if build.with? "tcl-tk" 136 | tcl_tk = Formula["tcl-tk"].opt_prefix 137 | ENV.append "CPPFLAGS", "-I#{tcl_tk}/include" 138 | ENV.append "LDFLAGS", "-L#{tcl_tk}/lib" 139 | end 140 | 141 | system "./configure", *args 142 | 143 | system "make" 144 | 145 | ENV.deparallelize # Installs must be serialized 146 | # Tell Python not to install into /Applications (default for framework builds) 147 | system "make", "altinstall", "PYTHONAPPSDIR=#{prefix}" 148 | # Demos and Tools 149 | system "make", "frameworkinstallextras", "PYTHONAPPSDIR=#{share}/python3" 150 | system "make", "quicktest" if build.include? "quicktest" 151 | 152 | # Any .app get a " 3.4" attached, so it does not conflict with python 2.x, 153 | # and other python 3.x installations. 154 | Dir.glob("#{prefix}/*.app") { |app| mv app, app.sub(".app", " 3.4.app") } 155 | 156 | # A fix, because python and python3 both want to install Python.framework 157 | # and therefore we can't link both into HOMEBREW_PREFIX/Frameworks 158 | # https://github.com/Homebrew/homebrew/issues/15943 159 | ["Headers", "Python", "Resources"].each { |f| rm(prefix/"Frameworks/Python.framework/#{f}") } 160 | rm prefix/"Frameworks/Python.framework/Versions/Current" 161 | 162 | # Symlink the pkgconfig files into HOMEBREW_PREFIX so they're accessible. 163 | (lib/"pkgconfig").install_symlink Dir["#{frameworks}/Python.framework/Versions/#{xy}/lib/pkgconfig/*"] 164 | 165 | # Remove the site-packages that Python created in its Cellar. 166 | site_packages_cellar.rmtree 167 | 168 | # These makevars are available through distutils.sysconfig at runtime and 169 | # some third-party software packages depend on them 170 | inreplace frameworks/"Python.framework/Versions/#{xy}/lib/python#{xy}/config-#{xy}m/Makefile" do |s| 171 | s.change_make_var! "LINKFORSHARED", 172 | "-u _PyMac_Error #{opt_prefix}/Frameworks/Python.framework/Versions/#{xy}/Python" 173 | end 174 | 175 | %w[setuptools pip wheel].each do |r| 176 | (libexec/r).install resource(r) 177 | end 178 | end 179 | 180 | def post_install 181 | # Fix up the site-packages so that user-installed Python software survives 182 | # minor updates, such as going from 3.3.2 to 3.3.3: 183 | 184 | # Create a site-packages in HOMEBREW_PREFIX/lib/python#{xy}/site-packages 185 | site_packages.mkpath 186 | 187 | # Symlink the prefix site-packages into the cellar. 188 | site_packages_cellar.unlink if site_packages_cellar.exist? 189 | site_packages_cellar.parent.install_symlink site_packages 190 | 191 | # Write our sitecustomize.py 192 | rm_rf Dir["#{site_packages}/sitecustomize.py[co]"] 193 | (site_packages/"sitecustomize.py").atomic_write(sitecustomize) 194 | 195 | # Remove old setuptools installations that may still fly around and be 196 | # listed in the easy_install.pth. This can break setuptools build with 197 | # zipimport.ZipImportError: bad local file header 198 | # setuptools-0.9.8-py3.3.egg 199 | rm_rf Dir["#{site_packages}/setuptools*"] 200 | rm_rf Dir["#{site_packages}/distribute*"] 201 | rm_rf Dir["#{site_packages}/pip[-_.][0-9]*", "#{site_packages}/pip"] 202 | 203 | %w[setuptools pip wheel].each do |pkg| 204 | (libexec/pkg).cd do 205 | system bin/"python3.4", "-s", "setup.py", "--no-user-cfg", "install", 206 | "--force", "--verbose", "--install-scripts=#{bin}", 207 | "--install-lib=#{site_packages}", 208 | "--single-version-externally-managed", 209 | "--record=installed.txt" 210 | end 211 | end 212 | 213 | rm_rf [bin/"pip", bin/"easy_install", bin/"pyvenv"] 214 | mv bin/"wheel", bin/"wheel3.4" 215 | 216 | # post_install happens after link 217 | %W[pip#{xy} easy_install-#{xy} wheel3.4 pyvenv3.4].each do |e| 218 | (HOMEBREW_PREFIX/"bin").install_symlink bin/e 219 | end 220 | 221 | # Help distutils find brewed stuff when building extensions 222 | include_dirs = [HOMEBREW_PREFIX/"include", Formula["openssl"].opt_include] 223 | library_dirs = [HOMEBREW_PREFIX/"lib", Formula["openssl"].opt_lib] 224 | 225 | if build.with? "sqlite" 226 | include_dirs << Formula["sqlite"].opt_include 227 | library_dirs << Formula["sqlite"].opt_lib 228 | end 229 | 230 | if build.with? "tcl-tk" 231 | include_dirs << Formula["homebrew/dupes/tcl-tk"].opt_include 232 | library_dirs << Formula["homebrew/dupes/tcl-tk"].opt_lib 233 | end 234 | 235 | cfg = lib_cellar/"distutils/distutils.cfg" 236 | cfg.atomic_write <<-EOF.undent 237 | [install] 238 | prefix=#{HOMEBREW_PREFIX} 239 | 240 | [build_ext] 241 | include_dirs=#{include_dirs.join ":"} 242 | library_dirs=#{library_dirs.join ":"} 243 | EOF 244 | end 245 | 246 | def xy 247 | version.to_s.slice(/(3.\d)/) || "3.6" 248 | end 249 | 250 | def sitecustomize 251 | <<-EOF.undent 252 | # This file is created by Homebrew and is executed on each python startup. 253 | # Don't print from here, or else python command line scripts may fail! 254 | # 255 | import re 256 | import os 257 | import sys 258 | 259 | if sys.version_info[0] != 3: 260 | # This can only happen if the user has set the PYTHONPATH for 3.x and run Python 2.x or vice versa. 261 | # Every Python looks at the PYTHONPATH variable and we can't fix it here in sitecustomize.py, 262 | # because the PYTHONPATH is evaluated after the sitecustomize.py. Many modules (e.g. PyQt4) are 263 | # built only for a specific version of Python and will fail with cryptic error messages. 264 | # In the end this means: Don't set the PYTHONPATH permanently if you use different Python versions. 265 | exit('Your PYTHONPATH points to a site-packages dir for Python 3.x but you are running Python ' + 266 | str(sys.version_info[0]) + '.x!\\n PYTHONPATH is currently: "' + str(os.environ['PYTHONPATH']) + '"\\n' + 267 | ' You should `unset PYTHONPATH` to fix this.') 268 | 269 | # Only do this for a brewed python: 270 | if os.path.realpath(sys.executable).startswith('#{rack}'): 271 | # Shuffle /Library site-packages to the end of sys.path 272 | library_site = '/Library/Python/#{xy}/site-packages' 273 | library_packages = [p for p in sys.path if p.startswith(library_site)] 274 | sys.path = [p for p in sys.path if not p.startswith(library_site)] 275 | # .pth files have already been processed so don't use addsitedir 276 | sys.path.extend(library_packages) 277 | 278 | # the Cellar site-packages is a symlink to the HOMEBREW_PREFIX 279 | # site_packages; prefer the shorter paths 280 | long_prefix = re.compile(r'#{rack}/[0-9\._abrc]+/Frameworks/Python\.framework/Versions/#{xy}/lib/python#{xy}/site-packages') 281 | sys.path = [long_prefix.sub('#{site_packages}', p) for p in sys.path] 282 | 283 | # Set the sys.executable to use the opt_prefix 284 | sys.executable = '#{opt_bin}/python#{xy}' 285 | EOF 286 | end 287 | 288 | def caveats 289 | text = <<-EOS.undent 290 | Pip and setuptools have been installed. To update them 291 | pip3.4 install --upgrade pip setuptools 292 | 293 | You can install Python packages with 294 | pip3.4 install 295 | 296 | They will install into the site-package directory 297 | #{site_packages} 298 | 299 | See: https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Homebrew-and-Python.md 300 | EOS 301 | 302 | # Tk warning only for 10.6 303 | tk_caveats = <<-EOS.undent 304 | 305 | Apple's Tcl/Tk is not recommended for use with Python on Mac OS X 10.6. 306 | For more information see: http://www.python.org/download/mac/tcltk/ 307 | EOS 308 | 309 | text += tk_caveats unless MacOS.version >= :lion 310 | text 311 | end 312 | 313 | test do 314 | # Check if sqlite is ok, because we build with --enable-loadable-sqlite-extensions 315 | # and it can occur that building sqlite silently fails if OSX's sqlite is used. 316 | system "#{bin}/python#{xy}", "-c", "import sqlite3" 317 | # Check if some other modules import. Then the linked libs are working. 318 | system "#{bin}/python#{xy}", "-c", "import tkinter; root = tkinter.Tk()" 319 | system bin/"pip3.4", "list" 320 | end 321 | end 322 | 323 | __END__ 324 | diff --git a/setup.py b/setup.py 325 | index 2779658..902d0eb 100644 326 | --- a/setup.py 327 | +++ b/setup.py 328 | @@ -1699,9 +1699,6 @@ class PyBuildExt(build_ext): 329 | # Rather than complicate the code below, detecting and building 330 | # AquaTk is a separate method. Only one Tkinter will be built on 331 | # Darwin - either AquaTk, if it is found, or X11 based Tk. 332 | - if (host_platform == 'darwin' and 333 | - self.detect_tkinter_darwin(inc_dirs, lib_dirs)): 334 | - return 335 | 336 | # Assume we haven't found any of the libraries or include files 337 | # The versions with dots are used on Unix, and the versions without 338 | @@ -1747,22 +1744,6 @@ class PyBuildExt(build_ext): 339 | if dir not in include_dirs: 340 | include_dirs.append(dir) 341 | 342 | - # Check for various platform-specific directories 343 | - if host_platform == 'sunos5': 344 | - include_dirs.append('/usr/openwin/include') 345 | - added_lib_dirs.append('/usr/openwin/lib') 346 | - elif os.path.exists('/usr/X11R6/include'): 347 | - include_dirs.append('/usr/X11R6/include') 348 | - added_lib_dirs.append('/usr/X11R6/lib64') 349 | - added_lib_dirs.append('/usr/X11R6/lib') 350 | - elif os.path.exists('/usr/X11R5/include'): 351 | - include_dirs.append('/usr/X11R5/include') 352 | - added_lib_dirs.append('/usr/X11R5/lib') 353 | - else: 354 | - # Assume default location for X11 355 | - include_dirs.append('/usr/X11/include') 356 | - added_lib_dirs.append('/usr/X11/lib') 357 | - 358 | # If Cygwin, then verify that X is installed before proceeding 359 | if host_platform == 'cygwin': 360 | x11_inc = find_file('X11/Xlib.h', [], include_dirs) 361 | @@ -1786,10 +1767,6 @@ class PyBuildExt(build_ext): 362 | if host_platform in ['aix3', 'aix4']: 363 | libs.append('ld') 364 | 365 | - # Finally, link with the X11 libraries (not appropriate on cygwin) 366 | - if host_platform != "cygwin": 367 | - libs.append('X11') 368 | - 369 | ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], 370 | define_macros=[('WITH_APPINIT', 1)] + defs, 371 | include_dirs = include_dirs, 372 | -------------------------------------------------------------------------------- /python35.rb: -------------------------------------------------------------------------------- 1 | class Python35 < Formula 2 | desc "Interpreted, interactive, object-oriented programming language" 3 | homepage "https://www.python.org/" 4 | url "https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tar.xz" 5 | sha256 "0010f56100b9b74259ebcd5d4b295a32324b58b517403a10d1a2aa7cb22bca40" 6 | 7 | head "https://hg.python.org/cpython", :using => :hg 8 | 9 | option :universal 10 | option "with-tcl-tk", "Use Homebrew's Tk instead of OS X Tk (has optional Cocoa and threads support)" 11 | option "with-quicktest", "Run `make quicktest` after the build" 12 | 13 | deprecated_option "quicktest" => "with-quicktest" 14 | deprecated_option "with-brewed-tk" => "with-tcl-tk" 15 | 16 | depends_on "pkg-config" => :build 17 | depends_on "readline" => :recommended 18 | depends_on "sqlite" => :recommended 19 | depends_on "gdbm" => :recommended 20 | depends_on "openssl" 21 | depends_on "xz" => :recommended # for the lzma module added in 3.3 22 | depends_on "homebrew/dupes/tcl-tk" => :optional 23 | depends_on :x11 if build.with?("tcl-tk") && Tab.for_name("homebrew/dupes/tcl-tk").with?("x11") 24 | 25 | skip_clean "bin/pip3", "bin/pip-3.5", "bin/pip-3.6" 26 | skip_clean "bin/easy_install3", "bin/easy_install-3.5", "bin/easy_install-3.6" 27 | 28 | resource "setuptools" do 29 | url "https://pypi.python.org/packages/source/s/setuptools/setuptools-19.4.tar.gz" 30 | sha256 "214bf29933f47cf25e6faa569f710731728a07a19cae91ea64f826051f68a8cf" 31 | end 32 | 33 | resource "pip" do 34 | url "https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz" 35 | sha256 "46f4bd0d8dfd51125a554568d646fe4200a3c2c6c36b9f2d06d2212148439521" 36 | end 37 | 38 | resource "wheel" do 39 | url "https://pypi.python.org/packages/source/w/wheel/wheel-0.26.0.tar.gz" 40 | sha256 "eaad353805c180a47545a256e6508835b65a8e830ba1093ed8162f19a50a530c" 41 | end 42 | 43 | # Homebrew's tcl-tk is built in a standard unix fashion (due to link errors) 44 | # so we have to stop python from searching for frameworks and linking against 45 | # X11. 46 | patch :DATA if build.with? "tcl-tk" 47 | 48 | def lib_cellar 49 | prefix/"Frameworks/Python.framework/Versions/#{xy}/lib/python#{xy}" 50 | end 51 | 52 | def site_packages_cellar 53 | lib_cellar/"site-packages" 54 | end 55 | 56 | # The HOMEBREW_PREFIX location of site-packages. 57 | def site_packages 58 | HOMEBREW_PREFIX/"lib/python#{xy}/site-packages" 59 | end 60 | 61 | fails_with :llvm do 62 | build 2336 63 | cause <<-EOS.undent 64 | Could not find platform dependent libraries 65 | Consider setting $PYTHONHOME to [:] 66 | python.exe(14122) malloc: *** mmap(size=7310873954244194304) failed (error code=12) 67 | *** error: can't allocate region 68 | *** set a breakpoint in malloc_error_break to debug 69 | Could not import runpy module 70 | make: *** [pybuilddir.txt] Segmentation fault: 11 71 | EOS 72 | end 73 | 74 | # setuptools remembers the build flags python is built with and uses them to 75 | # build packages later. Xcode-only systems need different flags. 76 | def pour_bottle? 77 | MacOS::CLT.installed? 78 | end 79 | 80 | def install 81 | # Unset these so that installing pip and setuptools puts them where we want 82 | # and not into some other Python the user has installed. 83 | ENV["PYTHONHOME"] = nil 84 | ENV["PYTHONPATH"] = nil 85 | 86 | args = %W[ 87 | --prefix=#{prefix} 88 | --enable-ipv6 89 | --datarootdir=#{share} 90 | --datadir=#{share} 91 | --enable-framework=#{frameworks} 92 | --without-ensurepip 93 | ] 94 | 95 | args << "--without-gcc" if ENV.compiler == :clang 96 | 97 | unless MacOS::CLT.installed? 98 | # Help Python's build system (setuptools/pip) to build things on Xcode-only systems 99 | # The setup.py looks at "-isysroot" to get the sysroot (and not at --sysroot) 100 | cflags = "CFLAGS=-isysroot #{MacOS.sdk_path}" 101 | ldflags = "LDFLAGS=-isysroot #{MacOS.sdk_path}" 102 | args << "CPPFLAGS=-I#{MacOS.sdk_path}/usr/include" # find zlib 103 | if build.without? "tcl-tk" 104 | cflags += " -I#{MacOS.sdk_path}/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers" 105 | end 106 | args << cflags 107 | args << ldflags 108 | end 109 | # Avoid linking to libgcc http://code.activestate.com/lists/python-dev/112195/ 110 | args << "MACOSX_DEPLOYMENT_TARGET=#{MacOS.version}" 111 | 112 | # We want our readline and openssl! This is just to outsmart the detection code, 113 | # superenv makes cc always find includes/libs! 114 | inreplace "setup.py" do |s| 115 | s.gsub! "do_readline = self.compiler.find_library_file(lib_dirs, 'readline')", 116 | "do_readline = '#{Formula["readline"].opt_lib}/libhistory.dylib'" 117 | s.gsub! "/usr/local/ssl", Formula["openssl"].opt_prefix 118 | end 119 | 120 | if build.universal? 121 | ENV.universal_binary 122 | args << "--enable-universalsdk" << "--with-universal-archs=intel" 123 | end 124 | 125 | # Allow sqlite3 module to load extensions: http://docs.python.org/library/sqlite3.html#f1 126 | inreplace("setup.py", 'sqlite_defines.append(("SQLITE_OMIT_LOAD_EXTENSION", "1"))', "pass") if build.with? "sqlite" 127 | 128 | # Allow python modules to use ctypes.find_library to find homebrew's stuff 129 | # even if homebrew is not a /usr/local/lib. Try this with: 130 | # `brew install enchant && pip install pyenchant` 131 | inreplace "./Lib/ctypes/macholib/dyld.py" do |f| 132 | f.gsub! "DEFAULT_LIBRARY_FALLBACK = [", "DEFAULT_LIBRARY_FALLBACK = [ '#{HOMEBREW_PREFIX}/lib'," 133 | f.gsub! "DEFAULT_FRAMEWORK_FALLBACK = [", "DEFAULT_FRAMEWORK_FALLBACK = [ '#{HOMEBREW_PREFIX}/Frameworks'," 134 | end 135 | 136 | if build.with? "tcl-tk" 137 | tcl_tk = Formula["tcl-tk"].opt_prefix 138 | ENV.append "CPPFLAGS", "-I#{tcl_tk}/include" 139 | ENV.append "LDFLAGS", "-L#{tcl_tk}/lib" 140 | end 141 | 142 | system "./configure", *args 143 | 144 | system "make" 145 | 146 | ENV.deparallelize # Installs must be serialized 147 | # Tell Python not to install into /Applications (default for framework builds) 148 | system "make", "install", "PYTHONAPPSDIR=#{prefix}" 149 | # Demos and Tools 150 | system "make", "frameworkinstallextras", "PYTHONAPPSDIR=#{share}/python3" 151 | system "make", "quicktest" if build.include? "quicktest" 152 | 153 | # Any .app get a " 3.5" attached, so it does not conflict with python 2.x, 154 | # and other python 3.x installations. 155 | Dir.glob("#{prefix}/*.app") { |app| mv app, app.sub(".app", " 3.5.app") } 156 | 157 | # A fix, because python and python3 both want to install Python.framework 158 | # and therefore we can't link both into HOMEBREW_PREFIX/Frameworks 159 | # https://github.com/Homebrew/homebrew/issues/15943 160 | ["Headers", "Python", "Resources"].each { |f| rm(prefix/"Frameworks/Python.framework/#{f}") } 161 | rm prefix/"Frameworks/Python.framework/Versions/Current" 162 | 163 | # Symlink the pkgconfig files into HOMEBREW_PREFIX so they're accessible. 164 | (lib/"pkgconfig").install_symlink Dir["#{frameworks}/Python.framework/Versions/#{xy}/lib/pkgconfig/*"] 165 | 166 | # Remove 2to3 because python2 also installs it 167 | rm bin/"2to3" 168 | 169 | # Remove the site-packages that Python created in its Cellar. 170 | site_packages_cellar.rmtree 171 | 172 | # These makevars are available through distutils.sysconfig at runtime and 173 | # some third-party software packages depend on them 174 | inreplace frameworks/"Python.framework/Versions/#{xy}/lib/python#{xy}/config-#{xy}m/Makefile" do |s| 175 | s.change_make_var! "LINKFORSHARED", 176 | "-u _PyMac_Error #{opt_prefix}/Frameworks/Python.framework/Versions/#{xy}/Python" 177 | end 178 | 179 | %w[setuptools pip wheel].each do |r| 180 | (libexec/r).install resource(r) 181 | end 182 | end 183 | 184 | def post_install 185 | # Fix up the site-packages so that user-installed Python software survives 186 | # minor updates, such as going from 3.3.2 to 3.3.3: 187 | 188 | # Create a site-packages in HOMEBREW_PREFIX/lib/python#{xy}/site-packages 189 | site_packages.mkpath 190 | 191 | # Symlink the prefix site-packages into the cellar. 192 | site_packages_cellar.unlink if site_packages_cellar.exist? 193 | site_packages_cellar.parent.install_symlink site_packages 194 | 195 | # Write our sitecustomize.py 196 | rm_rf Dir["#{site_packages}/sitecustomize.py[co]"] 197 | (site_packages/"sitecustomize.py").atomic_write(sitecustomize) 198 | 199 | # Remove old setuptools installations that may still fly around and be 200 | # listed in the easy_install.pth. This can break setuptools build with 201 | # zipimport.ZipImportError: bad local file header 202 | # setuptools-0.9.8-py3.3.egg 203 | rm_rf Dir["#{site_packages}/setuptools*"] 204 | rm_rf Dir["#{site_packages}/distribute*"] 205 | rm_rf Dir["#{site_packages}/pip[-_.][0-9]*", "#{site_packages}/pip"] 206 | 207 | %w[setuptools pip wheel].each do |pkg| 208 | (libexec/pkg).cd do 209 | system bin/"python3.5", "-s", "setup.py", "--no-user-cfg", "install", 210 | "--force", "--verbose", "--install-scripts=#{bin}", 211 | "--install-lib=#{site_packages}", 212 | "--single-version-externally-managed", 213 | "--record=installed.txt" 214 | end 215 | end 216 | 217 | rm_rf [bin/"pip", bin/"easy_install", bin/"pyvenv"] 218 | mv bin/"wheel", bin/"wheel3.5" 219 | 220 | # post_install happens after link 221 | %W[pip#{xy} easy_install-#{xy} wheel3.5 pyvenv3.5].each do |e| 222 | (HOMEBREW_PREFIX/"bin").install_symlink bin/e 223 | end 224 | 225 | # Help distutils find brewed stuff when building extensions 226 | include_dirs = [HOMEBREW_PREFIX/"include", Formula["openssl"].opt_include] 227 | library_dirs = [HOMEBREW_PREFIX/"lib", Formula["openssl"].opt_lib] 228 | 229 | if build.with? "sqlite" 230 | include_dirs << Formula["sqlite"].opt_include 231 | library_dirs << Formula["sqlite"].opt_lib 232 | end 233 | 234 | if build.with? "tcl-tk" 235 | include_dirs << Formula["homebrew/dupes/tcl-tk"].opt_include 236 | library_dirs << Formula["homebrew/dupes/tcl-tk"].opt_lib 237 | end 238 | 239 | cfg = lib_cellar/"distutils/distutils.cfg" 240 | cfg.atomic_write <<-EOF.undent 241 | [install] 242 | prefix=#{HOMEBREW_PREFIX} 243 | 244 | [build_ext] 245 | include_dirs=#{include_dirs.join ":"} 246 | library_dirs=#{library_dirs.join ":"} 247 | EOF 248 | end 249 | 250 | def xy 251 | version.to_s.slice(/(3.\d)/) || "3.6" 252 | end 253 | 254 | def sitecustomize 255 | <<-EOF.undent 256 | # This file is created by Homebrew and is executed on each python startup. 257 | # Don't print from here, or else python command line scripts may fail! 258 | # 259 | import re 260 | import os 261 | import sys 262 | 263 | if sys.version_info[0] != 3: 264 | # This can only happen if the user has set the PYTHONPATH for 3.x and run Python 2.x or vice versa. 265 | # Every Python looks at the PYTHONPATH variable and we can't fix it here in sitecustomize.py, 266 | # because the PYTHONPATH is evaluated after the sitecustomize.py. Many modules (e.g. PyQt4) are 267 | # built only for a specific version of Python and will fail with cryptic error messages. 268 | # In the end this means: Don't set the PYTHONPATH permanently if you use different Python versions. 269 | exit('Your PYTHONPATH points to a site-packages dir for Python 3.x but you are running Python ' + 270 | str(sys.version_info[0]) + '.x!\\n PYTHONPATH is currently: "' + str(os.environ['PYTHONPATH']) + '"\\n' + 271 | ' You should `unset PYTHONPATH` to fix this.') 272 | 273 | # Only do this for a brewed python: 274 | if os.path.realpath(sys.executable).startswith('#{rack}'): 275 | # Shuffle /Library site-packages to the end of sys.path 276 | library_site = '/Library/Python/#{xy}/site-packages' 277 | library_packages = [p for p in sys.path if p.startswith(library_site)] 278 | sys.path = [p for p in sys.path if not p.startswith(library_site)] 279 | # .pth files have already been processed so don't use addsitedir 280 | sys.path.extend(library_packages) 281 | 282 | # the Cellar site-packages is a symlink to the HOMEBREW_PREFIX 283 | # site_packages; prefer the shorter paths 284 | long_prefix = re.compile(r'#{rack}/[0-9\._abrc]+/Frameworks/Python\.framework/Versions/#{xy}/lib/python#{xy}/site-packages') 285 | sys.path = [long_prefix.sub('#{site_packages}', p) for p in sys.path] 286 | 287 | # Set the sys.executable to use the opt_prefix 288 | sys.executable = '#{opt_bin}/python#{xy}' 289 | EOF 290 | end 291 | 292 | def caveats 293 | text = <<-EOS.undent 294 | Pip and setuptools have been installed. To update them 295 | pip3.5 install --upgrade pip setuptools 296 | 297 | You can install Python packages with 298 | pip3.5 install 299 | 300 | They will install into the site-package directory 301 | #{site_packages} 302 | 303 | See: https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Homebrew-and-Python.md 304 | EOS 305 | 306 | # Tk warning only for 10.6 307 | tk_caveats = <<-EOS.undent 308 | 309 | Apple's Tcl/Tk is not recommended for use with Python on Mac OS X 10.6. 310 | For more information see: http://www.python.org/download/mac/tcltk/ 311 | EOS 312 | 313 | text += tk_caveats unless MacOS.version >= :lion 314 | text 315 | end 316 | 317 | test do 318 | # Check if sqlite is ok, because we build with --enable-loadable-sqlite-extensions 319 | # and it can occur that building sqlite silently fails if OSX's sqlite is used. 320 | system "#{bin}/python#{xy}", "-c", "import sqlite3" 321 | # Check if some other modules import. Then the linked libs are working. 322 | system "#{bin}/python#{xy}", "-c", "import tkinter; root = tkinter.Tk()" 323 | system bin/"pip3.5", "list" 324 | end 325 | end 326 | 327 | __END__ 328 | diff --git a/setup.py b/setup.py 329 | index 2779658..902d0eb 100644 330 | --- a/setup.py 331 | +++ b/setup.py 332 | @@ -1699,9 +1699,6 @@ class PyBuildExt(build_ext): 333 | # Rather than complicate the code below, detecting and building 334 | # AquaTk is a separate method. Only one Tkinter will be built on 335 | # Darwin - either AquaTk, if it is found, or X11 based Tk. 336 | - if (host_platform == 'darwin' and 337 | - self.detect_tkinter_darwin(inc_dirs, lib_dirs)): 338 | - return 339 | 340 | # Assume we haven't found any of the libraries or include files 341 | # The versions with dots are used on Unix, and the versions without 342 | @@ -1747,22 +1744,6 @@ class PyBuildExt(build_ext): 343 | if dir not in include_dirs: 344 | include_dirs.append(dir) 345 | 346 | - # Check for various platform-specific directories 347 | - if host_platform == 'sunos5': 348 | - include_dirs.append('/usr/openwin/include') 349 | - added_lib_dirs.append('/usr/openwin/lib') 350 | - elif os.path.exists('/usr/X11R6/include'): 351 | - include_dirs.append('/usr/X11R6/include') 352 | - added_lib_dirs.append('/usr/X11R6/lib64') 353 | - added_lib_dirs.append('/usr/X11R6/lib') 354 | - elif os.path.exists('/usr/X11R5/include'): 355 | - include_dirs.append('/usr/X11R5/include') 356 | - added_lib_dirs.append('/usr/X11R5/lib') 357 | - else: 358 | - # Assume default location for X11 359 | - include_dirs.append('/usr/X11/include') 360 | - added_lib_dirs.append('/usr/X11/lib') 361 | - 362 | # If Cygwin, then verify that X is installed before proceeding 363 | if host_platform == 'cygwin': 364 | x11_inc = find_file('X11/Xlib.h', [], include_dirs) 365 | @@ -1786,10 +1767,6 @@ class PyBuildExt(build_ext): 366 | if host_platform in ['aix3', 'aix4']: 367 | libs.append('ld') 368 | 369 | - # Finally, link with the X11 libraries (not appropriate on cygwin) 370 | - if host_platform != "cygwin": 371 | - libs.append('X11') 372 | - 373 | ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], 374 | define_macros=[('WITH_APPINIT', 1)] + defs, 375 | include_dirs = include_dirs, 376 | -------------------------------------------------------------------------------- /python36.rb: -------------------------------------------------------------------------------- 1 | class Python36 < Formula 2 | desc "Interpreted, interactive, object-oriented programming language" 3 | homepage "https://www.python.org/" 4 | url "https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tar.xz" 5 | sha256 "b0c5f904f685e32d9232f7bdcbece9819a892929063b6e385414ad2dd6a23622" 6 | 7 | head "https://hg.python.org/cpython", :using => :hg 8 | 9 | option :universal 10 | option "with-tcl-tk", "Use Homebrew's Tk instead of OS X Tk (has optional Cocoa and threads support)" 11 | option "with-quicktest", "Run `make quicktest` after the build" 12 | 13 | deprecated_option "quicktest" => "with-quicktest" 14 | deprecated_option "with-brewed-tk" => "with-tcl-tk" 15 | 16 | depends_on "pkg-config" => :build 17 | depends_on "readline" => :recommended 18 | depends_on "sqlite" => :recommended 19 | depends_on "gdbm" => :recommended 20 | depends_on "openssl" 21 | depends_on "xz" => :recommended # for the lzma module added in 3.3 22 | depends_on "homebrew/dupes/tcl-tk" => :optional 23 | depends_on :x11 if build.with?("tcl-tk") && Tab.for_name("homebrew/dupes/tcl-tk").with?("x11") 24 | 25 | skip_clean "bin/pip3", "bin/pip-3.4", "bin/pip-3.5", "bin/pip-3.6" 26 | skip_clean "bin/easy_install3", "bin/easy_install-3.4", "bin/easy_install-3.5", "bin/easy_install-3.6" 27 | 28 | resource "setuptools" do 29 | url "https://pypi.python.org/packages/21/d7/3e7e4b42d40469d2b770e10aee5b49538ecf2853eb5635d2d2536b286e2d/setuptools-24.0.2.tar.gz" 30 | sha256 "efe010ea62504178246f6b3d98d588c2f67884403a7a0a99670dfbf8836ca973" 31 | end 32 | 33 | resource "pip" do 34 | url "https://pypi.python.org/packages/e7/a8/7556133689add8d1a54c0b14aeff0acb03c64707ce100ecd53934da1aa13/pip-8.1.2.tar.gz" 35 | sha256 "4d24b03ffa67638a3fa931c09fd9e0273ffa904e95ebebe7d4b1a54c93d7b732" 36 | end 37 | 38 | resource "wheel" do 39 | url "https://pypi.python.org/packages/source/w/wheel/wheel-0.29.0.tar.gz" 40 | sha256 "1ebb8ad7e26b448e9caa4773d2357849bf80ff9e313964bcaf79cbf0201a1648" 41 | end 42 | 43 | fails_with :clang do 44 | build 425 45 | cause "https://bugs.python.org/issue24844" 46 | end 47 | 48 | # Homebrew's tcl-tk is built in a standard unix fashion (due to link errors) 49 | # so we have to stop python from searching for frameworks and linking against 50 | # X11. 51 | patch :DATA if build.with? "tcl-tk" 52 | 53 | def lib_cellar 54 | prefix/"Frameworks/Python.framework/Versions/#{xy}/lib/python#{xy}" 55 | end 56 | 57 | def site_packages_cellar 58 | lib_cellar/"site-packages" 59 | end 60 | 61 | # The HOMEBREW_PREFIX location of site-packages. 62 | def site_packages 63 | HOMEBREW_PREFIX/"lib/python#{xy}/site-packages" 64 | end 65 | 66 | fails_with :llvm do 67 | build 2336 68 | cause <<-EOS.undent 69 | Could not find platform dependent libraries 70 | Consider setting $PYTHONHOME to [:] 71 | python.exe(14122) malloc: *** mmap(size=7310873954244194304) failed (error code=12) 72 | *** error: can't allocate region 73 | *** set a breakpoint in malloc_error_break to debug 74 | Could not import runpy module 75 | make: *** [pybuilddir.txt] Segmentation fault: 11 76 | EOS 77 | end 78 | 79 | # setuptools remembers the build flags python is built with and uses them to 80 | # build packages later. Xcode-only systems need different flags. 81 | pour_bottle? do 82 | reason <<-EOS.undent 83 | The bottle needs the Apple Command Line Tools to be installed. 84 | You can install them, if desired, with: 85 | xcode-select --install 86 | EOS 87 | satisfy { MacOS::CLT.installed? } 88 | end 89 | 90 | def install 91 | # Unset these so that installing pip and setuptools puts them where we want 92 | # and not into some other Python the user has installed. 93 | ENV["PYTHONHOME"] = nil 94 | ENV["PYTHONPATH"] = nil 95 | 96 | args = %W[ 97 | --prefix=#{prefix} 98 | --enable-ipv6 99 | --datarootdir=#{share} 100 | --datadir=#{share} 101 | --enable-framework=#{frameworks} 102 | --without-ensurepip 103 | ] 104 | 105 | args << "--without-gcc" if ENV.compiler == :clang 106 | 107 | cflags = [] 108 | ldflags = [] 109 | cppflags = [] 110 | 111 | unless MacOS::CLT.installed? 112 | # Help Python's build system (setuptools/pip) to build things on Xcode-only systems 113 | # The setup.py looks at "-isysroot" to get the sysroot (and not at --sysroot) 114 | cflags << "-isysroot #{MacOS.sdk_path}" 115 | ldflags << "-isysroot #{MacOS.sdk_path}" 116 | cppflags << "-I#{MacOS.sdk_path}/usr/include" # find zlib 117 | # For the Xlib.h, Python needs this header dir with the system Tk 118 | if build.without? "tcl-tk" 119 | cflags << "-I#{MacOS.sdk_path}/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers" 120 | end 121 | end 122 | # Avoid linking to libgcc https://mail.python.org/pipermail/python-dev/2012-February/116205.html 123 | args << "MACOSX_DEPLOYMENT_TARGET=#{MacOS.version}" 124 | 125 | # We want our readline and openssl! This is just to outsmart the detection code, 126 | # superenv makes cc always find includes/libs! 127 | inreplace "setup.py" do |s| 128 | s.gsub! "do_readline = self.compiler.find_library_file(lib_dirs, 'readline')", 129 | "do_readline = '#{Formula["readline"].opt_lib}/libhistory.dylib'" 130 | s.gsub! "/usr/local/ssl", Formula["openssl"].opt_prefix 131 | end 132 | 133 | if build.universal? 134 | ENV.universal_binary 135 | args << "--enable-universalsdk" << "--with-universal-archs=intel" 136 | end 137 | 138 | # Allow sqlite3 module to load extensions: https://docs.python.org/library/sqlite3.html#f1 139 | inreplace("setup.py", 'sqlite_defines.append(("SQLITE_OMIT_LOAD_EXTENSION", "1"))', "pass") if build.with? "sqlite" 140 | 141 | # Allow python modules to use ctypes.find_library to find homebrew's stuff 142 | # even if homebrew is not a /usr/local/lib. Try this with: 143 | # `brew install enchant && pip install pyenchant` 144 | inreplace "./Lib/ctypes/macholib/dyld.py" do |f| 145 | f.gsub! "DEFAULT_LIBRARY_FALLBACK = [", "DEFAULT_LIBRARY_FALLBACK = [ '#{HOMEBREW_PREFIX}/lib'," 146 | f.gsub! "DEFAULT_FRAMEWORK_FALLBACK = [", "DEFAULT_FRAMEWORK_FALLBACK = [ '#{HOMEBREW_PREFIX}/Frameworks'," 147 | end 148 | 149 | if build.with? "tcl-tk" 150 | tcl_tk = Formula["tcl-tk"].opt_prefix 151 | cppflags << "-I#{tcl_tk}/include" 152 | ldflags << "-L#{tcl_tk}/lib" 153 | end 154 | 155 | args << "CFLAGS=#{cflags.join(" ")}" unless cflags.empty? 156 | args << "LDFLAGS=#{ldflags.join(" ")}" unless ldflags.empty? 157 | args << "CPPFLAGS=#{cppflags.join(" ")}" unless cppflags.empty? 158 | 159 | system "./configure", *args 160 | 161 | system "make" 162 | 163 | ENV.deparallelize # Installs must be serialized 164 | # Tell Python not to install into /Applications (default for framework builds) 165 | system "make", "install", "PYTHONAPPSDIR=#{prefix}" 166 | # Demos and Tools 167 | system "make", "frameworkinstallextras", "PYTHONAPPSDIR=#{pkgshare}" 168 | system "make", "quicktest" if build.with? "quicktest" 169 | 170 | # Any .app get a " 3" attached, so it does not conflict with python 2.x. 171 | Dir.glob("#{prefix}/*.app") { |app| mv app, app.sub(/\.app$/, " 3.app") } 172 | 173 | # A fix, because python and python3 both want to install Python.framework 174 | # and therefore we can't link both into HOMEBREW_PREFIX/Frameworks 175 | # https://github.com/Homebrew/homebrew/issues/15943 176 | ["Headers", "Python", "Resources"].each { |f| rm(prefix/"Frameworks/Python.framework/#{f}") } 177 | rm prefix/"Frameworks/Python.framework/Versions/Current" 178 | 179 | # Symlink the pkgconfig files into HOMEBREW_PREFIX so they're accessible. 180 | (lib/"pkgconfig").install_symlink Dir["#{frameworks}/Python.framework/Versions/#{xy}/lib/pkgconfig/*"] 181 | 182 | # Remove 2to3 because python2 also installs it 183 | rm bin/"2to3" 184 | 185 | # Remove the site-packages that Python created in its Cellar. 186 | site_packages_cellar.rmtree 187 | 188 | # These makevars are available through distutils.sysconfig at runtime and 189 | # some third-party software packages depend on them 190 | inreplace Dir.glob(frameworks/"Python.framework/Versions/#{xy}/lib/python#{xy}/config-#{xy}*/Makefile") do |s| 191 | s.change_make_var! "LINKFORSHARED", 192 | "-u _PyMac_Error #{opt_prefix}/Frameworks/Python.framework/Versions/#{xy}/Python" 193 | end 194 | 195 | %w[setuptools pip wheel].each do |r| 196 | (libexec/r).install resource(r) 197 | end 198 | end 199 | 200 | def post_install 201 | # Fix up the site-packages so that user-installed Python software survives 202 | # minor updates, such as going from 3.3.2 to 3.3.3: 203 | 204 | # Create a site-packages in HOMEBREW_PREFIX/lib/python#{xy}/site-packages 205 | site_packages.mkpath 206 | 207 | # Symlink the prefix site-packages into the cellar. 208 | site_packages_cellar.unlink if site_packages_cellar.exist? 209 | site_packages_cellar.parent.install_symlink site_packages 210 | 211 | # Write our sitecustomize.py 212 | rm_rf Dir["#{site_packages}/sitecustomize.py[co]"] 213 | (site_packages/"sitecustomize.py").atomic_write(sitecustomize) 214 | 215 | # Remove old setuptools installations that may still fly around and be 216 | # listed in the easy_install.pth. This can break setuptools build with 217 | # zipimport.ZipImportError: bad local file header 218 | # setuptools-0.9.8-py3.3.egg 219 | rm_rf Dir["#{site_packages}/setuptools*"] 220 | rm_rf Dir["#{site_packages}/distribute*"] 221 | rm_rf Dir["#{site_packages}/pip[-_.][0-9]*", "#{site_packages}/pip"] 222 | 223 | %w[setuptools pip wheel].each do |pkg| 224 | (libexec/pkg).cd do 225 | system bin/"python3", "-s", "setup.py", "--no-user-cfg", "install", 226 | "--force", "--verbose", "--install-scripts=#{bin}", 227 | "--install-lib=#{site_packages}", 228 | "--single-version-externally-managed", 229 | "--record=installed.txt" 230 | end 231 | end 232 | 233 | rm_rf [bin/"pip", bin/"easy_install"] 234 | mv bin/"wheel", bin/"wheel3" 235 | 236 | # post_install happens after link 237 | %W[pip3 pip#{xy} easy_install-#{xy} wheel3].each do |e| 238 | (HOMEBREW_PREFIX/"bin").install_symlink bin/e 239 | end 240 | 241 | # Help distutils find brewed stuff when building extensions 242 | include_dirs = [HOMEBREW_PREFIX/"include", Formula["openssl"].opt_include] 243 | library_dirs = [HOMEBREW_PREFIX/"lib", Formula["openssl"].opt_lib] 244 | 245 | if build.with? "sqlite" 246 | include_dirs << Formula["sqlite"].opt_include 247 | library_dirs << Formula["sqlite"].opt_lib 248 | end 249 | 250 | if build.with? "tcl-tk" 251 | include_dirs << Formula["homebrew/dupes/tcl-tk"].opt_include 252 | library_dirs << Formula["homebrew/dupes/tcl-tk"].opt_lib 253 | end 254 | 255 | cfg = lib_cellar/"distutils/distutils.cfg" 256 | cfg.atomic_write <<-EOF.undent 257 | [install] 258 | prefix=#{HOMEBREW_PREFIX} 259 | 260 | [build_ext] 261 | include_dirs=#{include_dirs.join ":"} 262 | library_dirs=#{library_dirs.join ":"} 263 | EOF 264 | end 265 | 266 | def xy 267 | version.to_s.slice(/(3.\d)/) || "3.6" 268 | end 269 | 270 | def sitecustomize 271 | <<-EOF.undent 272 | # This file is created by Homebrew and is executed on each python startup. 273 | # Don't print from here, or else python command line scripts may fail! 274 | # 275 | import re 276 | import os 277 | import sys 278 | 279 | if sys.version_info[0] != 3: 280 | # This can only happen if the user has set the PYTHONPATH for 3.x and run Python 2.x or vice versa. 281 | # Every Python looks at the PYTHONPATH variable and we can't fix it here in sitecustomize.py, 282 | # because the PYTHONPATH is evaluated after the sitecustomize.py. Many modules (e.g. PyQt4) are 283 | # built only for a specific version of Python and will fail with cryptic error messages. 284 | # In the end this means: Don't set the PYTHONPATH permanently if you use different Python versions. 285 | exit('Your PYTHONPATH points to a site-packages dir for Python 3.x but you are running Python ' + 286 | str(sys.version_info[0]) + '.x!\\n PYTHONPATH is currently: "' + str(os.environ['PYTHONPATH']) + '"\\n' + 287 | ' You should `unset PYTHONPATH` to fix this.') 288 | 289 | # Only do this for a brewed python: 290 | if os.path.realpath(sys.executable).startswith('#{rack}'): 291 | # Shuffle /Library site-packages to the end of sys.path 292 | library_site = '/Library/Python/#{xy}/site-packages' 293 | library_packages = [p for p in sys.path if p.startswith(library_site)] 294 | sys.path = [p for p in sys.path if not p.startswith(library_site)] 295 | # .pth files have already been processed so don't use addsitedir 296 | sys.path.extend(library_packages) 297 | 298 | # the Cellar site-packages is a symlink to the HOMEBREW_PREFIX 299 | # site_packages; prefer the shorter paths 300 | long_prefix = re.compile(r'#{rack}/[0-9\._abrc]+/Frameworks/Python\.framework/Versions/#{xy}/lib/python#{xy}/site-packages') 301 | sys.path = [long_prefix.sub('#{site_packages}', p) for p in sys.path] 302 | 303 | # Set the sys.executable to use the opt_prefix 304 | sys.executable = '#{opt_bin}/python#{xy}' 305 | EOF 306 | end 307 | 308 | def caveats 309 | text = <<-EOS.undent 310 | Pip, setuptools, and wheel have been installed. To update them 311 | pip3 install --upgrade pip setuptools wheel 312 | 313 | You can install Python packages with 314 | pip3 install 315 | 316 | They will install into the site-package directory 317 | #{site_packages} 318 | 319 | See: https://github.com/Homebrew/brew/blob/master/share/doc/homebrew/Homebrew-and-Python.md 320 | EOS 321 | 322 | # Tk warning only for 10.6 323 | tk_caveats = <<-EOS.undent 324 | 325 | Apple's Tcl/Tk is not recommended for use with Python on Mac OS X 10.6. 326 | For more information see: https://www.python.org/download/mac/tcltk/ 327 | EOS 328 | 329 | text += tk_caveats unless MacOS.version >= :lion 330 | text 331 | end 332 | 333 | test do 334 | # Check if sqlite is ok, because we build with --enable-loadable-sqlite-extensions 335 | # and it can occur that building sqlite silently fails if OSX's sqlite is used. 336 | system "#{bin}/python#{xy}", "-c", "import sqlite3" 337 | # Check if some other modules import. Then the linked libs are working. 338 | system "#{bin}/python#{xy}", "-c", "import tkinter; root = tkinter.Tk()" 339 | system bin/"pip3", "list" 340 | end 341 | end 342 | 343 | __END__ 344 | diff --git a/setup.py b/setup.py 345 | index 2779658..902d0eb 100644 346 | --- a/setup.py 347 | +++ b/setup.py 348 | @@ -1699,9 +1699,6 @@ class PyBuildExt(build_ext): 349 | # Rather than complicate the code below, detecting and building 350 | # AquaTk is a separate method. Only one Tkinter will be built on 351 | # Darwin - either AquaTk, if it is found, or X11 based Tk. 352 | - if (host_platform == 'darwin' and 353 | - self.detect_tkinter_darwin(inc_dirs, lib_dirs)): 354 | - return 355 | 356 | # Assume we haven't found any of the libraries or include files 357 | # The versions with dots are used on Unix, and the versions without 358 | @@ -1747,22 +1744,6 @@ class PyBuildExt(build_ext): 359 | if dir not in include_dirs: 360 | include_dirs.append(dir) 361 | 362 | - # Check for various platform-specific directories 363 | - if host_platform == 'sunos5': 364 | - include_dirs.append('/usr/openwin/include') 365 | - added_lib_dirs.append('/usr/openwin/lib') 366 | - elif os.path.exists('/usr/X11R6/include'): 367 | - include_dirs.append('/usr/X11R6/include') 368 | - added_lib_dirs.append('/usr/X11R6/lib64') 369 | - added_lib_dirs.append('/usr/X11R6/lib') 370 | - elif os.path.exists('/usr/X11R5/include'): 371 | - include_dirs.append('/usr/X11R5/include') 372 | - added_lib_dirs.append('/usr/X11R5/lib') 373 | - else: 374 | - # Assume default location for X11 375 | - include_dirs.append('/usr/X11/include') 376 | - added_lib_dirs.append('/usr/X11/lib') 377 | - 378 | # If Cygwin, then verify that X is installed before proceeding 379 | if host_platform == 'cygwin': 380 | x11_inc = find_file('X11/Xlib.h', [], include_dirs) 381 | @@ -1786,10 +1767,6 @@ class PyBuildExt(build_ext): 382 | if host_platform in ['aix3', 'aix4']: 383 | libs.append('ld') 384 | 385 | - # Finally, link with the X11 libraries (not appropriate on cygwin) 386 | - if host_platform != "cygwin": 387 | - libs.append('X11') 388 | - 389 | ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], 390 | define_macros=[('WITH_APPINIT', 1)] + defs, 391 | include_dirs = include_dirs, 392 | --------------------------------------------------------------------------------