Skip to content

Commit

Permalink
Build the setup_requires list based on what's not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee Kamentsky committed Jan 14, 2016
1 parent 7f56275 commit d645c99
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import distutils
import glob
import importlib
import os
import shlex
import setuptools
Expand Down Expand Up @@ -30,17 +31,26 @@

assert not hasattr(site, "virtual_install_main_packages")

# We need some packages in order to properly prepare for setup, but
# setuptools.dist.Distribution seems to upgrade them willy-nilly
# So try importing and only ask for ones that are not present.
packages = []
for package_name, import_name in [
("clint", "clint"),
("javabridge", "javabridge"),
("matplotlib", "matplotlib"),
("numpy", "numpy"),
("pytest", "pytest"),
("pyzmq", "zmq"),
("requests", "requests"),
("scipy", "scipy")]:
try:
importlib.import_module(import_name)
except ImportError:
packages.append(package_name)

setuptools.dist.Distribution({
"setup_requires": [
"clint",
"javabridge",
"matplotlib",
"numpy",
"pytest",
"pyzmq",
"requests",
"scipy"
]
"setup_requires": packages
})

try:
Expand Down

0 comments on commit d645c99

Please sign in to comment.