# Tanım: Sonraki nesil python üst düzey betik dili
# URL: http://www.python.org
# Paketçi: milisarge
# Gerekler: sqlite libffi tk
# Grup: geliştirme

isim=python3
surum=3.7.0
devir=1

kaynak=(http://www.python.org/ftp/python/$surum/Python-$surum.tar.xz
		bpo34056-always-return-bytes-from-_HackedGetData.get_data.patch
        dont-make-libpython-readonly.patch)

derle() {
	_pybasever=${surum%.*}
	cd Python-$surum
	
	# https://bugs.python.org/issue34056
	patch -Np1 -i ../bpo34056-always-return-bytes-from-_HackedGetData.get_data.patch

	# FS#45809
	patch -p1 -i ../dont-make-libpython-readonly.patch

	# FS#23997
	sed -i -e "s|^#.* /usr/local/bin/python|#!/usr/bin/python3|" Lib/cgi.py

	# Ensure that we are using the system copy of various libraries (expat, libffi, and libmpdec),
	# rather than copies shipped in the tarball
	rm -r Modules/expat
	rm -r Modules/_ctypes/{darwin,libffi}*
	rm -r Modules/_decimal/libmpdec
	
	./configure --prefix=/usr \
              --enable-shared \
              --with-threads \
              --with-computed-gotos \
              --enable-optimizations \
              --with-lto \
              --enable-ipv6 \
              --with-system-expat \
              --with-dbmliborder=gdbm:ndbm \
              --with-system-ffi \
              --with-system-libmpdec \
              --enable-loadable-sqlite-extensions \
              --without-ensurepip
	make
	
	sed -i 's/^all:.*$/all: build_all/' Makefile

    make DESTDIR="${PKG}" EXTRA_CFLAGS="$CFLAGS" install
    
    install -dm755 "${PKG}"/usr/lib/python${_pybasever}/Tools/{i18n,scripts}
	install -m755 Tools/i18n/{msgfmt,pygettext}.py "${PKG}"/usr/lib/python${_pybasever}/Tools/i18n/
	install -m755 Tools/scripts/{README,*py} "${PKG}"/usr/lib/python${_pybasever}/Tools/scripts/

	# Lisans
	install -Dm644 LICENSE "${PKG}/usr/share/licenses/${isim}/LICENSE"

}
  
