Skip to content
This repository has been archived by the owner on Dec 11, 2022. It is now read-only.

Add Python 3.7 #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions nonstandard_recipes/python-3.7/brand_python.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import argparse
import os
import re


platform_file = os.path.join('Lib', 'platform.py')
get_version_file = os.path.join('Python', 'getversion.c')


def patch_platform(msg):
with open(platform_file, 'r') as fh:
lines = list(fh)

lines_it = iter(lines)
with open(platform_file, 'w') as fh:
for line in lines_it:
fh.write(line)
if line.startswith('_sys_version_parser'):
next_line = next(lines_it)
fh.write(" r'([\w.+]+)\s*" +
re.escape(' ' + msg) + "\s*'\n")


def patch_get_version(msg):
with open(get_version_file, 'r') as fh:
content = list(fh)

lines = iter(content)
with open(get_version_file, 'w') as fh:
for line in lines:
if line.strip().startswith('PyOS_snprintf(version, sizeof(version)'):
fh.write(' PyOS_snprintf(version, sizeof(version),\n')
fh.write(' "%.80s ' + msg.replace('"',
'\\"') + ' (%.80s) %.80s",\n')
else:
fh.write(line)


msg = os.environ.get('python_branding', '<undefined>')
if msg == '<undefined>':
msg = "| packaged by rpi |"

patch_platform(msg)
patch_get_version(msg)
20 changes: 20 additions & 0 deletions nonstandard_recipes/python-3.7/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

python ${RECIPE_DIR}/brand_python.py

# Remove test data and ensurepip stubs to save space
rm -rf Lib/test Lib/*/test
rm -rf Lib/ensurepip

./configure --enable-shared --enable-ipv6 --with-ensurepip=no \
--enable-optimizations \
--prefix=$PREFIX \
--with-tcltk-includes="-I$PREFIX/include" \
--with-tcltk-libs="-L$PREFIX/lib -ltcl8.6 -ltk8.6" \
CPPFLAGS="-I$PREFIX/include" \
LDFLAGS="-L$PREFIX/lib -Wl,-rpath=$PREFIX/lib,--no-as-needed"

make -j${CPU_COUNT}
make install
ln -s $PREFIX/bin/python3.7 $PREFIX/bin/python
ln -s $PREFIX/bin/pydoc3.7 $PREFIX/bin/pydoc
55 changes: 55 additions & 0 deletions nonstandard_recipes/python-3.7/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{% set version = "3.7.0" %}

package:
name: python
version: {{ version }}

source:
fn: Python-{{ version }}.tgz
url: https://www.python.org/ftp/python/{{ version }}/Python-{{ version }}.tgz
md5: 41b6595deb4147a1ed517a7d9a580271

build:
number: 0
no_link:
- bin/python3.7
script_env:
- python_branding
skip_compile_pyc:
- lib/python3.7/test/*bad*.py
- lib/python3.7/lib2to3/tests/data/*.py
ignore_prefix_files:
- lib/libpython3.7m.so.1.0
- lib/python3.7/lib-dynload/*.so

requirements:
build:
- bzip2 1.0.*
- openssl 1.0.*
- readline 6.3*
- sqlite 3.15.*
- tk 8.6.*
- xz 5.2.*
- zlib 1.2.*
- libffi
run:
- openssl 1.0.*
- readline 6.3*
- sqlite 3.15.*
- tk 8.6.*
- xz 5.2.*
- zlib 1.2.*
- libffi

test:
commands:
- python -V
- python3 -V
- 2to3 -h
- pydoc -h
- python3-config --help

about:
home: http://www.python.org/
license: PSF
summary: General purpose programming language
109 changes: 109 additions & 0 deletions nonstandard_recipes/python-3.7/run_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import platform
import sys
import subprocess

aarch64 = bool(platform.machine() == 'aarch64')
armv6l = bool(platform.machine() == 'armv6l')
armv7l = bool(platform.machine() == 'armv7l')
ppc64le = bool(platform.machine() == 'ppc64le')
if sys.platform == 'darwin':
osx105 = b'10.5.' in subprocess.check_output('sw_vers')
else:
osx105 = False

print('sys.version:', sys.version)
print('sys.platform:', sys.platform)
print('tuple.__itemsize__:', tuple.__itemsize__)
if sys.platform == 'win32':
assert 'MSC v.1900' in sys.version
print('sys.maxunicode:', sys.maxunicode)
print('platform.architecture:', platform.architecture())
print('platform.machine:', platform.machine())
print('platform.python_version:', platform.python_version())

import _bisect
import _codecs_cn
import _codecs_hk
import _codecs_iso2022
import _codecs_jp
import _codecs_kr
import _codecs_tw
import _collections
import _csv
import _ctypes
import _ctypes_test
import _decimal
import _elementtree
import _functools
import _hashlib
import _heapq
import _io
import _json
import _locale
import _lsprof
import _lzma
import _multibytecodec
import _multiprocessing
import _random
import _socket
import _sqlite3
import _ssl
import _struct
import _testcapi
import array
import audioop
import binascii
import bz2
import cmath
import datetime
import itertools
import lzma
import math
import mmap
import operator
import parser
import pyexpat
import select
import time
import unicodedata
import zlib
from os import urandom

t = 100 * b'Foo '
assert lzma.decompress(lzma.compress(t)) == t

if sys.platform != 'win32':
if not ppc64le:
import _curses
import _curses_panel
import crypt
import fcntl
import grp
import nis
import readline
import resource
import syslog
import termios

from distutils import sysconfig
for var_name in 'LDSHARED', 'CC':
value = sysconfig.get_config_var(var_name)
assert value.split()[0] == 'gcc', value
for var_name in 'LDCXXSHARED', 'CXX':
value = sysconfig.get_config_var(var_name)
assert value.split()[0] == 'g++', value

if not (ppc64le or osx105):
import tkinter
import turtle
import _tkinter
print('TK_VERSION: %s' % _tkinter.TK_VERSION)
print('TCL_VERSION: %s' % _tkinter.TCL_VERSION)
if sys.platform == 'win32' or armv6l or armv7l or aarch64:
TCLTK_VER = '8.6'
else:
TCLTK_VER = '8.5'
assert _tkinter.TK_VERSION == _tkinter.TCL_VERSION == TCLTK_VER

import ssl
print('OPENSSL_VERSION:', ssl.OPENSSL_VERSION)