Last active
December 23, 2016 20:24
-
-
Save yarko/0023b25781cdb16098790ebd288ed34a to your computer and use it in GitHub Desktop.
Build Python v3.6.0 release on os/x from github sources, where brew has installed (co-reside w/ your other pythons)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
# NOTE: keeping this gist for 3.6.0 release, because I want to keep 3.5 around for a bit too; | |
# Here is how I built Python v3.6.0b1...onward | |
# on OS/X, where brew is installed | |
# (and python2.7 and python3.5 installed by brew): | |
# make sure you have openssl installed (this is for installing pip) | |
# and a recent tcl-tk, if you're going to use idle | |
# (see https://www.python.org/download/mac/tcltk/ for more info) | |
# If you have them installed, you might want to `brew upgrade` them. | |
# (uncomment if needed): | |
# brew install openssl | |
# brew install tcl-tk | |
# now, get python from either python.org - source zip - | |
# or github mirror; I do the later: | |
# git clone [email protected]:python/cpython.git | |
# or | |
git fetch | |
git checkout 3.6 # or, git checkout -f ... the 3.6 branch | |
# if fetched / updated: | |
git pull | |
# search https://ht.python.org/cpython/tags | |
# for the changeset to tag in the git mirror | |
# note: the changesets are numbered differently; I id manually like this: | |
# git log # search for "Added tag v3.6.0b..." whatever the appropriate tag is | |
#git tag -a v3.6.0b1 4ce9f3c002bb598a203867aa084faf1914c76e73 | |
#git checkout v3.6.0b1 | |
#git tag -a v3.6.0b2 1ebb1d03bb17ad786a6e0751ca89336671ee694f | |
#git checkout v3.6.0b2 | |
#git tag -a v3.6.0b3 a6a13f3b9b3a0bc4d832f6c8d292efa90dfb2549 | |
#git checkout v3.6.0b3 | |
#git tag -a v3.6.0b4 1ebb1d03bb17ad786a6e0751ca89336671ee694f | |
#git checkout v3.6.0b4 | |
#git tag -a v3.6.0rc1 bb265131bf01ccc09f77991408fb7c92b013e324 | |
#git checkout v3.6.0rc1 | |
#git tag -a v3.6.0rc2 84f054c425e0636c4baf244718877e5d204140b0 | |
#git checkout v3.6.0.rc2 | |
git tag -a v3.6.0 21feef2e7b32cf469f2846ed602e7e19733d8d89 | |
git checkout v3.6.0 | |
# to build w/ brew built tcl-tk, modify setup.py to not look for | |
# usual Apple system locations for X11 | |
# - this will allow a successful build of idle3.6 | |
patch -b setup.py setup.patch | |
# now - configure to use the brew'd openssl: | |
# get the command line options to use the brew openssl: | |
# brew info openssl | |
# or this should give you the pattern for what you'll need: | |
# - I've tried to find what will get the brew-built tcl-tk to link, for idle3.6; | |
# on at least one mac exporting the vars before running configure seemed to work, but not on another. | |
# Here's the latest change for you to try: | |
# combine output of two brew-info calls into one pipeline, then python for the output strings: | |
# - if you're not using brew installed sqlite3, comment that out: | |
{ brew info openssl | grep -A 99 'build variables:'; | |
brew info tcl-tk | grep -A 99 'build variables:'; | |
brew info sqlite3 | grep -A 99 'build variables:'; | |
} | python -c ' | |
import sys | |
cmds = {} | |
for line in sys.stdin: | |
l = line.strip() | |
if not l or line.startswith("build variables:"): | |
continue | |
k, v = l.split(maxsplit=1) | |
k = k.rstrip(":") | |
if not k in cmds: | |
cmds[k] = [] | |
cmds[k].append(v) | |
mortar = " " | |
for k in cmds: | |
if k.startswith("PKG_CONFIG_PATH"): | |
continue | |
print("export {}=\"{}\"".format( k, mortar.join(cmds[k]) )) | |
' | pbcopy # this will put it in your paste-buffer; CMD-V paste into your shell | |
# end of script for env vars; | |
# My result, pasted in shell: | |
# these are used by ./configure, and then picked up by make - double entering each. | |
# You might want to unset these before make; my idle builds still work on one mac, not another; | |
export LDFLAGS="-L/usr/local/opt/openssl/lib -L/usr/local/opt/tcl-tk/lib" | |
export CPPFLAGS="-I/usr/local/opt/openssl/include -I/usr/local/opt/tcl-tk/include" | |
./configure | |
# or this - but it will run compilations on installation also: | |
#./configure --enable-optimizations | |
# so these flags don't show twice in the compilations - once from config file, once from env: | |
unset CPPFLAGS LDFLAGS | |
# build python: | |
make | |
make test | |
# you can get pip before you install: | |
curl -O https://bootstrap.pypa.io/get-pip.py | |
./python.exe get-pip.py | |
# This will install in /usr/local/bin as python3.6, etc. | |
# so the commands won't collide with or replace any | |
# homebrew installed python3.5 | |
make altinstall | |
# check what was installed: | |
ls -lrt /usr/local/bin | |
# now, go play with v3.6.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*** a/setup.py 2016-12-08 17:02:31.000000000 -0600 | |
--- b/setup.py 2016-12-08 17:06:42.000000000 -0600 | |
*************** | |
*** 1774,1782 **** | |
# Rather than complicate the code below, detecting and building | |
# AquaTk is a separate method. Only one Tkinter will be built on | |
# Darwin - either AquaTk, if it is found, or X11 based Tk. | |
- if (host_platform == 'darwin' and | |
- self.detect_tkinter_darwin(inc_dirs, lib_dirs)): | |
- return | |
# Assume we haven't found any of the libraries or include files | |
# The versions with dots are used on Unix, and the versions without | |
--- 1774,1779 ---- | |
*************** | |
*** 1822,1843 **** | |
if dir not in include_dirs: | |
include_dirs.append(dir) | |
- # Check for various platform-specific directories | |
- if host_platform == 'sunos5': | |
- include_dirs.append('/usr/openwin/include') | |
- added_lib_dirs.append('/usr/openwin/lib') | |
- elif os.path.exists('/usr/X11R6/include'): | |
- include_dirs.append('/usr/X11R6/include') | |
- added_lib_dirs.append('/usr/X11R6/lib64') | |
- added_lib_dirs.append('/usr/X11R6/lib') | |
- elif os.path.exists('/usr/X11R5/include'): | |
- include_dirs.append('/usr/X11R5/include') | |
- added_lib_dirs.append('/usr/X11R5/lib') | |
- else: | |
- # Assume default location for X11 | |
- include_dirs.append('/usr/X11/include') | |
- added_lib_dirs.append('/usr/X11/lib') | |
- | |
# If Cygwin, then verify that X is installed before proceeding | |
if host_platform == 'cygwin': | |
x11_inc = find_file('X11/Xlib.h', [], include_dirs) | |
--- 1819,1824 ---- | |
*************** | |
*** 1861,1870 **** | |
if host_platform in ['aix3', 'aix4']: | |
libs.append('ld') | |
- # Finally, link with the X11 libraries (not appropriate on cygwin) | |
- if host_platform != "cygwin": | |
- libs.append('X11') | |
- | |
ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], | |
define_macros=[('WITH_APPINIT', 1)] + defs, | |
include_dirs = include_dirs, | |
--- 1842,1847 ---- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fixed matplotlib and idle issues, by patching setup.py;
With a pip3.6
ptpython
install/update, I've noticed that all links toptpython
command are updated to point topython3.6
;I have to edit the top line in the following (I want mine to point to release
python3
; I have a separateptpython2
):ptpython, ptipython
ptpython3, ptipython3
ptpython3.5, ptipython3.5