python3.rb 2.92 KB
Newer Older
Ben Fayers's avatar
Ben Fayers committed
1 2
require 'package'

Ben Fayers's avatar
Ben Fayers committed
3
class Python3 < Package
4 5
  description 'Python is a programming language that lets you work quickly and integrate systems more effectively.'
  homepage 'https://www.python.org/'
Ben Fayers's avatar
Ben Fayers committed
6
  version '3.6.0'
7
  source_url 'https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz'
8
  source_sha256 'aa472515800d25a3739833f76ca3735d9f4b2fe77c3cb21f69275e0cce30cb2b'
Ben Fayers's avatar
Ben Fayers committed
9

10 11
  depends_on 'bz2' => :build
  depends_on 'xzutils' => :build
Ben Fayers's avatar
Ben Fayers committed
12
  depends_on 'ncurses'
13 14
  depends_on 'openssl' => :build
  depends_on 'sqlite' => :build
Jan Baudisch's avatar
Jan Baudisch committed
15
  depends_on 'zlibpkg'
Ben Fayers's avatar
Ben Fayers committed
16

17
  def self.build
18
    # python requires to use /usr/local/lib, so leave as is but specify -rpath
19
    system "./configure", "CPPFLAGS=-I/usr/local/include/ncurses -I/usr/local/include/ncursesw",
20
      "LDFLAGS=-Wl,-rpath,#{CREW_PREFIX}/lib",
21
      "--with-ensurepip=install", "--enable-shared"
22
    system "make"
Ben Fayers's avatar
Ben Fayers committed
23 24
  end

25 26
  def self.install
    system "make", "DESTDIR=#{CREW_DEST_DIR}", "install"
27 28

    # remove static library
29 30 31 32 33 34 35
    system "find #{CREW_DEST_DIR}/usr/local -name 'libpython*.a' -print | xargs -r rm"

    # create symbolic links in lib64 for other applications which use libpython
    unless Dir.exist? "#{CREW_DEST_DIR}#{CREW_LIB_PREFIX}"
      system "mkdir -p #{CREW_DEST_DIR}#{CREW_LIB_PREFIX}"
      system "cd #{CREW_DEST_DIR}#{CREW_LIB_PREFIX}; ln -s ../lib/libpython*.so* ."
    end
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
  end

  def self.check
    # Chromebook doesn't allow SIGHUP, so disable SIGHUP test
    system "sed", "-i", "Lib/test/test_asyncio/test_events.py", "-e", "/Don't have SIGHUP/s/win32/linux/"
    system "sed", "-i", "Lib/test/test_asyncio/test_subprocess.py", "-e", "/Don't have SIGHUP/s/win32/linux/"

    # Chromebook returns EINVAL for F_NOTIFY DN_MULTISHOT, so disable test_fcntl_64_bit
    system "sed", "-i", "Lib/test/test_fcntl.py", "-e", '/ARM Linux returns EINVAL for F_NOTIFY DN_MULTISHOT/s/$/\
    @unittest.skipIf(platform.system() == '"'Linux'"', "Chromeos returns EINVAL for F_NOTIFY DN_MULTISHOT")/'

    # imaplib test used to use a kind of security hole on a server in university and the hole is closed now.
    # See https://bugs.python.org/issue30175 and https://github.com/python/cpython/pull/1320/files for details.
    system "sed", "-i", "Lib/test/test_imaplib.py",
        "-e", '/test_logincapa_with_client_certfile/i\ \ \ \ @unittest.skipIf(True,\
                     "bpo-30175: FIXME: cyrus.andrew.cmu.edu doesn\'t accept "\
                     "our randomly generated client x509 certificate anymore")',
        "-e", '/test_logincapa_with_client_ssl_context/i\ \ \ \ @unittest.skipIf(True,\
                     "bpo-30175: FIXME: cyrus.andrew.cmu.edu doesn\'t accept "\
                     "our randomly generated client x509 certificate anymore")'

    # Using /tmp breaks test_distutils, test_subprocess
    # Proxy setting breaks test_httpservers, test_ssl,
    # test_urllib, test_urllib2, test_urllib2_localnet
    system "TMPDIR=/usr/local/tmp http_proxy= https_proxy= ftp_proxy= make test"
Ben Fayers's avatar
Ben Fayers committed
61 62
  end
end