ansible: 1.2.2 some fixes
- Install the Python module `ansible` into the usual prefix, but use `python.private_site_packages` (in `libexec`) for the deps. - In oder for the `ansible` module to be useful, the deps are needed and we insert the `python.private_site_packages` in the `ansible/__init__.py` as a `sitedir`, to the `egg`s are working. - Rewrote the `bin_wrapper` to be ready to be moved into `python_helper` or something. - With the brand new changes in the PythonInstalled dependency, it is not necessary to set the `PYTHONPATH` if you want to use the `python.private_site_packages` inside of the `libexec`. However, you have to put the calls to `system python` inside of a `python do … end` block (technical limitation of supporting Python 2.x and 3.x in general).
This commit is contained in:
parent
cd2e419601
commit
c0b3a4b666
1 changed files with 41 additions and 25 deletions
|
@ -1,10 +1,5 @@
|
|||
require 'formula'
|
||||
|
||||
class PyCrypto < Formula
|
||||
url 'https://pypi.python.org/packages/source/p/pycrypto/pycrypto-2.6.tar.gz'
|
||||
sha1 'c17e41a80b3fbf2ee4e8f2d8bb9e28c5d08bbb84'
|
||||
end
|
||||
|
||||
class PyYAML < Formula
|
||||
url 'https://pypi.python.org/packages/source/P/PyYAML/PyYAML-3.10.tar.gz'
|
||||
sha1 '476dcfbcc6f4ebf3c06186229e8e2bd7d7b20e73'
|
||||
|
@ -15,11 +10,21 @@ class Paramiko < Formula
|
|||
sha1 'fd925569b9f0b1bd32ce6575235d152616e64e46'
|
||||
end
|
||||
|
||||
class MarkupSafe < Formula
|
||||
url 'https://pypi.python.org/packages/source/M/MarkupSafe/MarkupSafe-0.18.tar.gz'
|
||||
sha1 '9fe11891773f922a8b92e83c8f48edeb2f68631e'
|
||||
end
|
||||
|
||||
class Jinja2 < Formula
|
||||
url 'https://pypi.python.org/packages/source/J/Jinja2/Jinja2-2.7.1.tar.gz'
|
||||
sha1 'a9b24d887f2be772921b3ee30a0b9d435cffadda'
|
||||
end
|
||||
|
||||
class PyCrypto < Formula
|
||||
url 'https://pypi.python.org/packages/source/p/pycrypto/pycrypto-2.6.tar.gz'
|
||||
sha1 'c17e41a80b3fbf2ee4e8f2d8bb9e28c5d08bbb84'
|
||||
end
|
||||
|
||||
class Ansible < Formula
|
||||
homepage 'http://ansible.github.com/'
|
||||
url 'https://github.com/ansible/ansible/archive/v1.2.2.tar.gz'
|
||||
|
@ -30,37 +35,48 @@ class Ansible < Formula
|
|||
depends_on :python
|
||||
depends_on 'libyaml'
|
||||
|
||||
def bin_wrapper bin_file; <<-EOS.undent
|
||||
#!/bin/sh
|
||||
PYTHONPATH="#{libexec}/lib/#{python.xy}/site-packages:$PYTHONPATH" "#{libexec}/bin/#{bin_file}" "$@"
|
||||
def wrap script, pythonpath, place_original="#{libexec}/bin"
|
||||
script = Pathname.new(script)
|
||||
place_original = Pathname.new(place_original)
|
||||
place_original.mkpath
|
||||
mv script, "#{place_original}/"
|
||||
script.write <<-EOS.undent
|
||||
#!/bin/sh
|
||||
PYTHONPATH="#{pythonpath}:$PYTHONPATH" "#{place_original}/#{script.basename}" "$@"
|
||||
EOS
|
||||
end
|
||||
|
||||
def install
|
||||
ENV['PYTHONPATH'] = "#{libexec}/lib/#{python.xy}/site-packages"
|
||||
# installing into private sitepackages inside of the Cellar (in libexec)
|
||||
install_args = [ "setup.py", "install", "--prefix=#{libexec}" ]
|
||||
|
||||
PyCrypto.new.brew { system python, *install_args }
|
||||
PyYAML.new.brew { system python, *install_args }
|
||||
Paramiko.new.brew { system python, *install_args }
|
||||
Jinja2.new.brew { system python, *install_args }
|
||||
python do
|
||||
PyCrypto.new.brew { system python, *install_args }
|
||||
PyYAML.new.brew { system python, *install_args }
|
||||
Paramiko.new.brew { system python, *install_args }
|
||||
MarkupSafe.new.brew { system python, *install_args }
|
||||
Jinja2.new.brew { system python, *install_args }
|
||||
|
||||
inreplace 'lib/ansible/constants.py' do |s|
|
||||
s.gsub! '/usr/share/ansible', share+'ansible'
|
||||
s.gsub! '/etc/ansible', etc+'ansible'
|
||||
inreplace 'lib/ansible/constants.py' do |s|
|
||||
s.gsub! '/usr/share/ansible', share+'ansible'
|
||||
s.gsub! '/etc/ansible', etc+'ansible'
|
||||
end
|
||||
|
||||
# The "main" ansible module is installed in the default location and
|
||||
# in order for it to be usable, we add the private_site_packages
|
||||
# to the __init__.py of ansible so the deps (PyYAML etc) are found.
|
||||
# Because of egg files,
|
||||
inreplace 'lib/ansible/__init__.py',
|
||||
"__author__ = 'Michael DeHaan'",
|
||||
"__author__ = 'Michael DeHaan'; import site; site.addsitedir('#{python.private_site_packages}')"
|
||||
|
||||
system python, "setup.py", "install", "--prefix=#{prefix}"
|
||||
end
|
||||
|
||||
system python, "setup.py", "install", "--prefix=#{prefix}"
|
||||
|
||||
man1.install Dir['docs/man/man1/*.1']
|
||||
|
||||
(libexec/'bin').mkpath
|
||||
|
||||
Dir["#{bin}/*"].each do |bin_path|
|
||||
bin_path = Pathname.new(bin_path)
|
||||
bin_file = bin_path.basename
|
||||
mv bin_path, libexec/"bin/#{bin_file}"
|
||||
bin_path.write(bin_wrapper(bin_file))
|
||||
Dir["#{bin}/*"].each do |script|
|
||||
wrap script, pythonpath=python.private_site_packages
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue