This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

PythonInstalled: Adding a private_site_packages

that live in the `libexec` dir of a `Cellar`.
  • Loading branch information...
1 parent 36ff119 commit 9f7c616c1cb7b2301e790dde56fc2ce0107c39de @samueljohn samueljohn committed Sep 3, 2013
Showing with 10 additions and 7 deletions.
  1. +8 −7 Library/Homebrew/python_helper.rb
  2. +2 −0 Library/Homebrew/requirements/python_dependency.rb
@@ -51,22 +51,22 @@ def python_helper(options={:allowed_major_versions => [2, 3]}, &block)
filtered_python_reqs.sort_by{ |py| py.version }.map do |py|
# Now is the time to `site_packages` to the correct value in the Cellar.
py.site_packages = lib/py.xy/'site-packages'
+ py.private_site_packages = libexec/"lib"/py.xy/"site-packages"
return py if !block_given?
puts "brew: Python block (#{py.binary})..." if ARGV.verbose? && ARGV.debug?
- # Ensure env changes are only temporary
# Ensure env changes are only temporary:
begin
old_env = ENV.to_hash
- # In order to install into the Cellar, the dir must exist and be in the
- # PYTHONPATH. This will be executed in the context of the formula
- # so that lib points to the HOMEBREW_PREFIX/Cellar/<formula>/<version>/lib
- puts "brew: setting PYTHONPATH to: #{py.site_packages}" if ARGV.verbose?
# In order to install into the `Cellar`, the dir must exist and be in the
# `PYTHONPATH`. This will be executed in the context of the formula and
# lib points to the `HOMEBREW_PREFIX/Cellar/<formula>/<version>/lib`.
mkdir_p py.site_packages
- ENV['PYTHONPATH'] = py.site_packages
+ ENV.append_path 'PYTHONPATH', py.site_packages
+ # Allow to --prefix=libexec if a private site-packages is needed.
+ mkdir_p py.private_site_packages
+ ENV.append_path 'PYTHONPATH', py.private_site_packages
+ puts "brew: PYTHONPATH=#{ENV['PYTHONPATH']}" if ARGV.verbose?
ENV['PYTHON'] = py.binary
ENV.prepend_path 'CMAKE_INCLUDE_PATH', py.incdir
ENV.prepend_path 'PKG_CONFIG_PATH', py.pkg_config_path if py.pkg_config_path
@@ -76,13 +76,14 @@ def python_helper(options={:allowed_major_versions => [2, 3]}, &block)
# Track the state of the currently selected python for this block,
# so if this python_helper is called again _inside_ the block,
- # we can just return the right python
# we can just return the right python.
@current_python = py
res = instance_eval(&block)
@current_python = nil
res
ensure
+ # Clean up if the private_site_packages has not been used.
+ py.private_site_packages.rmdir if py.private_site_packages.children.empty?
ENV.replace(old_env)
end
end
@@ -19,6 +19,7 @@ class PythonInstalled < Requirement
attr_reader :imports
attr_reader :python
attr_accessor :site_packages
+ attr_accessor :private_site_packages
attr_writer :binary # The python.rb formula needs to set the binary
fatal true # you can still make Python optional by `depends_on :python => :optional`
@@ -70,6 +71,7 @@ def initialize(default_version="2.6", tags=[])
# will be set later by the python_helper, because it needs the
# formula prefix to set site_packages
@site_packages = nil
+ @private_site_packages = nil
super tags
end

0 comments on commit 9f7c616

Please sign in to comment.