PageRenderTime 50ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/Library/Formula/pypy.rb

https://bitbucket.org/JoshHagins/homebrew
Ruby | 139 lines | 98 code | 21 blank | 20 comment | 0 complexity | 1dff2c6f9b05f04f05d43cae02be3b8d MD5 | raw file
  1. require "formula"
  2. class Pypy < Formula
  3. homepage "http://pypy.org/"
  4. url "https://bitbucket.org/pypy/pypy/downloads/pypy-2.4.0-src.tar.bz2"
  5. sha1 "e2e0bcf8457c0ae5a24f126a60aa921dabfe60fb"
  6. revision 2
  7. bottle do
  8. cellar :any
  9. revision 6
  10. sha1 "16fe931416b3b2a22618dc8279623099895dd795" => :yosemite
  11. sha1 "341e674f2e2f27d4fca54155ed1247b7b43c7fa9" => :mavericks
  12. sha1 "7f085dc680a416d4f5c0788ffa024487d16ebabd" => :mountain_lion
  13. end
  14. depends_on :arch => :x86_64
  15. depends_on "pkg-config" => :build
  16. depends_on "openssl"
  17. resource "setuptools" do
  18. url "https://pypi.python.org/packages/source/s/setuptools/setuptools-9.1.tar.gz"
  19. sha1 "b068a670c84df7b961730c6a0d00cd06c7b767f0"
  20. end
  21. resource "pip" do
  22. url "https://pypi.python.org/packages/source/p/pip/pip-6.0.3.tar.gz"
  23. sha1 "67d4affd83ee2f3514ac1386bee59f10f672517c"
  24. end
  25. # https://bugs.launchpad.net/ubuntu/+source/gcc-4.2/+bug/187391
  26. fails_with :gcc
  27. def install
  28. # Having PYTHONPATH set can cause the build to fail if another
  29. # Python is present, e.g. a Homebrew-provided Python 2.x
  30. # See https://github.com/Homebrew/homebrew/issues/24364
  31. ENV["PYTHONPATH"] = ""
  32. ENV["PYPY_USESSION_DIR"] = buildpath
  33. Dir.chdir "pypy/goal" do
  34. system "python", buildpath/"rpython/bin/rpython",
  35. "-Ojit", "--shared", "--cc", ENV.cc, "--translation-verbose",
  36. "--make-jobs", ENV.make_jobs, "targetpypystandalone.py"
  37. system "install_name_tool", "-change", "libpypy-c.dylib", libexec/"lib/libpypy-c.dylib", "pypy-c"
  38. system "install_name_tool", "-id", opt_libexec/"lib/libpypy-c.dylib", "libpypy-c.dylib"
  39. (libexec/"bin").install "pypy-c" => "pypy"
  40. (libexec/"lib").install "libpypy-c.dylib"
  41. end
  42. (libexec/"lib-python").install "lib-python/2.7"
  43. libexec.install %w[include lib_pypy]
  44. # The PyPy binary install instructions suggest installing somewhere
  45. # (like /opt) and symlinking in binaries as needed. Specifically,
  46. # we want to avoid putting PyPy's Python.h somewhere that configure
  47. # scripts will find it.
  48. bin.install_symlink libexec/"bin/pypy"
  49. lib.install_symlink libexec/"lib/libpypy-c.dylib"
  50. %w[setuptools pip].each do |r|
  51. (libexec/r).install resource(r)
  52. end
  53. end
  54. def post_install
  55. # Precompile cffi extensions in lib_pypy
  56. # list from create_cffi_import_libraries in pypy/tool/release/package.py
  57. %w[_sqlite3 _curses syslog gdbm _tkinter].each do |module_name|
  58. quiet_system bin/"pypy", "-c", "import #{module_name}"
  59. end
  60. # Post-install, fix up the site-packages and install-scripts folders
  61. # so that user-installed Python software survives minor updates, such
  62. # as going from 1.7.0 to 1.7.1.
  63. # Create a site-packages in the prefix.
  64. prefix_site_packages.mkpath
  65. # Symlink the prefix site-packages into the cellar.
  66. libexec.install_symlink prefix_site_packages
  67. # Tell distutils-based installers where to put scripts
  68. scripts_folder.mkpath
  69. (distutils+"distutils.cfg").atomic_write <<-EOF.undent
  70. [install]
  71. install-scripts=#{scripts_folder}
  72. EOF
  73. %w[setuptools pip].each do |pkg|
  74. (libexec/pkg).cd do
  75. system bin/"pypy", "-s", "setup.py", "--no-user-cfg", "install",
  76. "--force", "--verbose"
  77. end
  78. end
  79. # Symlinks to easy_install_pypy and pip_pypy
  80. bin.install_symlink scripts_folder/"easy_install" => "easy_install_pypy"
  81. bin.install_symlink scripts_folder/"pip" => "pip_pypy"
  82. # post_install happens after linking
  83. %w[easy_install_pypy pip_pypy].each { |e| (HOMEBREW_PREFIX/"bin").install_symlink bin/e }
  84. end
  85. def caveats; <<-EOS.undent
  86. A "distutils.cfg" has been written to:
  87. #{distutils}
  88. specifying the install-scripts folder as:
  89. #{scripts_folder}
  90. If you install Python packages via "pypy setup.py install", easy_install_pypy,
  91. or pip_pypy, any provided scripts will go into the install-scripts folder
  92. above, so you may want to add it to your PATH *after* #{HOMEBREW_PREFIX}/bin
  93. so you don't overwrite tools from CPython.
  94. Setuptools and pip have been installed, so you can use easy_install_pypy and
  95. pip_pypy.
  96. To update setuptools and pip between pypy releases, run:
  97. #{scripts_folder}/pip install --upgrade setuptools
  98. See: https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Homebrew-and-Python.md
  99. EOS
  100. end
  101. # The HOMEBREW_PREFIX location of site-packages
  102. def prefix_site_packages
  103. HOMEBREW_PREFIX+"lib/pypy/site-packages"
  104. end
  105. # Where setuptools will install executable scripts
  106. def scripts_folder
  107. HOMEBREW_PREFIX+"share/pypy"
  108. end
  109. # The Cellar location of distutils
  110. def distutils
  111. libexec+"lib-python/2.7/distutils"
  112. end
  113. end