Permalink
Browse files

- python: only specify --install-{scripts,lib,data} if the

  attributes/flags are set in fpm.

  This should fix #273 without breaking prior behavior.
  • Loading branch information...
1 parent 32edfef commit ebd133a32de930664b106c1cc05299a989d415dd @jordansissel committed Oct 5, 2012
Showing with 11 additions and 19 deletions.
  1. +11 −19 lib/fpm/package/python.rb
@@ -181,28 +181,20 @@ def install_to_staging(setup_py)
prefix = "/"
prefix = attributes[:prefix] unless attributes[:prefix].nil?
- # Set the default install library location (like
- # /usr/lib/python2.7/site-packages) if it is not given
- if attributes[:python_install_lib].nil?
- # Ask python where libraries are installed to.
- # This line is unusually long because I don't have a shorter way to express it.
- attributes[:python_install_lib] = %x{
- #{attributes[:python_bin]} -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())'
- }.chomp
- @logger.info("Setting default :python_install_lib attribute",
- :value => attributes[:python_install_lib])
- end
- if attributes[:python_install_data].nil?
- attributes[:python_install_data] = attributes[:python_install_lib]
- end
# Some setup.py's assume $PWD == current directory of setup.py, so let's
# chdir first.
::Dir.chdir(project_dir) do
- safesystem(attributes[:python_bin], "setup.py", "install",
- "--root", staging_path,
- "--install-lib", File.join(prefix, attributes[:python_install_lib]),
- "--install-data", File.join(prefix, attributes[:python_install_data]),
- "--install-scripts", File.join(prefix, attributes[:python_install_bin]))
+ flags = [ "--root", staging_path ]
+ if !attributes[:python_install_lib].nil?
+ flags += [ "--install-lib", File.join(prefix, attributes[:python_install_lib]) ]
+ end
+ if !attributes[:python_install_data].nil?
+ flags += [ "--install-data", File.join(prefix, attributes[:python_install_data]) ]
+ end
+ if !attributes[:python_install_bin].nil?
+ flags += [ "--install-scripts", File.join(prefix, attributes[:python_install_bin]) ]
+ end
+ safesystem(attributes[:python_bin], "setup.py", "install", *flags)
end
end # def install_to_staging

0 comments on commit ebd133a

Please sign in to comment.