language/python: setup_install_args

Add a helper like std_cmake_args that returns the correct incantation
for invoking setup.py in a consistent way and with our preferred
arguments. Replaces setup_install.
This commit is contained in:
Tim D. Smith 2014-12-09 23:17:11 -08:00
parent 720f13d8d5
commit 75535395ac

View File

@ -52,6 +52,7 @@ module Language
quiet_system python, "-c", script quiet_system python, "-c", script
end end
# deprecated; use system "python", *setup_install_args(prefix) instead
def self.setup_install python, prefix, *args def self.setup_install python, prefix, *args
# force-import setuptools, which monkey-patches distutils, to make # force-import setuptools, which monkey-patches distutils, to make
# sure that we always call a setuptools setup.py. trick borrowed from pip: # sure that we always call a setuptools setup.py. trick borrowed from pip:
@ -66,5 +67,22 @@ module Language
args << "--prefix=#{prefix}" args << "--prefix=#{prefix}"
system python, "-c", shim, "install", *args system python, "-c", shim, "install", *args
end end
def self.setup_install_args prefix
shim = <<-EOS.undent
import setuptools, tokenize
__file__ = 'setup.py'
exec(compile(getattr(tokenize, 'open', open)(__file__).read()
.replace('\\r\\n', '\\n'), __file__, 'exec'))
EOS
%W[
-c
#{shim}
install
--prefix=#{prefix}
--single-version-externally-managed
--record=installed.txt
]
end
end end
end end