setup: fix up IPython Windows support

Summary:
Fix final pieces to make IPython work on Windows:
- Install `win_unicode_console`. `pip2 download ipython` running on Linux won't
  include it. But running on Windows will.
- Make `build_pyzip` command support `-i`.
- Make `Makefile` run `build_pyzip -i` so IPython.zip gets generated under
  mercurial/thirdparty properly.

As we're here, also clean up IPython.zip so it no longer contains `setup.pyc`.

Reviewed By: kulshrax

Differential Revision: D13426947

fbshipit-source-id: 91db6cb85de4c689a4e5c10043debbc26bb94c18
This commit is contained in:
Jun Wu 2018-12-11 17:32:11 -08:00 committed by Facebook Github Bot
parent 411ea54601
commit 8e98fa6a2c
2 changed files with 19 additions and 3 deletions

View File

@ -55,6 +55,7 @@ local:
build_clib $(COMPILERFLAG) \
build_ext $(COMPILERFLAG) -i \
build_rust_ext -i -l\
build_pyzip -i \
build_mo
ifeq ($(OS),Windows_NT)
cp build/scripts-2.7/hg.rust.exe hg.exe

View File

@ -656,6 +656,8 @@ class fetchbuilddeps(Command):
"https://files.pythonhosted.org/packages/16/2a/557af1181e6b4e30254d5a6163b18f5053791ca66e251e77ab08887e8fe3/scandir-1.9.0.tar.gz",
"https://files.pythonhosted.org/packages/fa/bc/9bd3b5c2b4774d5f33b2d544f1460be9df7df2fe42f352135381c347c69a/ipython_genutils-0.2.0-py2.py3-none-any.whl",
"https://files.pythonhosted.org/packages/c5/db/e56e6b4bbac7c4a06de1c50de6fe1ef3810018ae11732a50f15f62c7d050/enum34-1.1.6-py2-none-any.whl",
"https://files.pythonhosted.org/packages/89/8d/7aad74930380c8972ab282304a2ff45f3d4927108bb6693cabcc9fc6a099/win_unicode_console-0.5.zip",
"https://files.pythonhosted.org/packages/4f/a6/728666f39bfff1719fc94c481890b2106837da9318031f71a8424b662e12/colorama-0.4.1-py2.py3-none-any.whl",
]
]
@ -1117,7 +1119,15 @@ class hgbuildpy(build_py):
class buildpyzip(Command):
description = "generate zip for bundled dependent Python modules (ex. IPython)"
user_options = []
user_options = [
(
"inplace",
"i",
"ignore build-lib and put compiled extensions into the source "
+ "directory alongside your pure Python modules",
)
]
boolean_options = ["inplace"]
# Currently this only handles IPython. It avoids conflicts with the system
# IPython (which might be older and have GUI dependencies that we don't
@ -1125,7 +1135,7 @@ class buildpyzip(Command):
# as weel (i.e. some buildembedded logic will move here).
def initialize_options(self):
pass
self.inplace = None
def finalize_options(self):
pass
@ -1137,7 +1147,10 @@ class buildpyzip(Command):
depdirs = [pjoin(builddir, a.destdir) for a in fetchbuilddeps.ipythonassets]
# Perform a mtime check so we can skip building if possible
zippath = pjoin(builddir, "IPython.zip")
if self.inplace:
zippath = pjoin(scriptdir, "mercurial/thirdparty/IPython.zip")
else:
zippath = pjoin(builddir, "IPython.zip")
if os.path.exists(zippath):
depmtime = max(os.stat(d).st_mtime for d in depdirs)
zipmtime = os.stat(zippath).st_mtime
@ -1157,6 +1170,8 @@ class buildpyzip(Command):
# directories to get everything included.
extracteddir = pjoin(builddir, asset.destdir)
for name in os.listdir(extracteddir):
if name == "setup.py":
continue
path = pjoin(extracteddir, name)
if path.endswith(".py") or os.path.isdir(path):
f.writepy(path)