Permalink
Browse files

control case of package name and its dependencies

Added the following two flags:
  --[no-]python-downcase-name
  (python only) Should the target package name be in lowercase? (default: true)
  --[no-]python-downcase-dependencies
  (python only) Should the package dependencies be in lowercase? (default: true)

fixes #326
  • Loading branch information...
jaybuff committed Jan 2, 2013
1 parent 65f6bb1 commit 5be1ac0e8abba5b05ba3aac85672d871091376f1
Showing with 52 additions and 24 deletions.
  1. +11 −0 lib/fpm/package/python.rb
  2. +2 −2 spec/fixtures/python/setup.py
  3. +39 −22 spec/fpm/package/python_spec.rb
View
@@ -43,6 +43,11 @@ class FPM::Package::Python < FPM::Package
option "--fix-dependencies", :flag, "Should the package dependencies be " \
"prefixed?", :default => true
+ option "--downcase-name", :flag, "Should the target package name be in " \
+ "lowercase?", :default => true
+ option "--downcase-dependencies", :flag, "Should the package dependencies " \
+ "be in lowercase?", :default => true
+
option "--install-bin", "BIN_PATH", "The path to where python scripts " \
"should be installed to.", :default => "/usr/bin"
option "--install-lib", "LIB_PATH", "The path to where python libs " \
@@ -169,6 +174,9 @@ def load_package_info(setup_py)
self.name = metadata["name"]
end
+ # convert python-Foo to python-foo if flag is set
+ self.name = self.name.downcase if attributes[:python_downcase_name?]
+
requirements_txt = File.join(setup_dir, "requirements.txt")
if File.exists?(requirements_txt)
@logger.info("Found requirements.txt, using it instead of setup.py " \
@@ -199,6 +207,9 @@ def load_package_info(setup_py)
# become 'python-foo' (depending on what the python_package_name_prefix
# is)
name = fix_name(name) if attributes[:python_fix_dependencies?]
+
+ # convert dependencies from python-Foo to python-foo
+ name = name.downcase if attributes[:python_downcase_dependencies?]
"#{name} #{cmp} #{version}"
end
end # def load_package_info
@@ -1,13 +1,13 @@
from distutils.core import setup
-setup(name="example",
+setup(name="Example",
version="1.0",
description="sample description",
author="sample author",
author_email="sample email",
url="sample url",
packages=[],
package_dir={},
- requires=["dependency1", "dependency2"],
+ requires=["Dependency1", "dependency2"],
)
@@ -19,37 +19,54 @@ def python_usable?
after :each do
subject.cleanup
end
-
- context "when :python_fix_name? is true" do
+
+ context "when :python_downcase_name? is false" do
before :each do
- subject.attributes[:python_fix_name?] = true
+ subject.attributes[:python_downcase_name?] = false
+ end
+
+ it "should leave the package name as is" do
+ subject.input(example_dir)
+ insist { subject.name } == "Example"
end
+ end
- context "and :python_package_name_prefix is nil/default" do
- it "should prefix the package with 'python-'" do
- subject.input(example_dir)
- insist { subject.name } == "python-example"
- end
+ context "when :python_downcase_name? is true" do
+ before :each do
+ subject.attributes[:python_downcase_name?] = true
end
- context "and :python_package_name_prefix is set" do
- it "should prefix the package name appropriately" do
- prefix = "whoa"
- subject.attributes[:python_package_name_prefix] = prefix
- subject.input(example_dir)
- insist { subject.name } == "#{prefix}-example"
+ context "when :python_fix_name? is true" do
+ before :each do
+ subject.attributes[:python_fix_name?] = true
end
- end
- end
- context "when :python_fix_name? is false" do
- before :each do
- subject.attributes[:python_fix_name?] = false
+ context "and :python_package_name_prefix is nil/default" do
+ it "should prefix the package with 'python-'" do
+ subject.input(example_dir)
+ insist { subject.name } == "python-example"
+ end
+ end
+
+ context "and :python_package_name_prefix is set" do
+ it "should prefix the package name appropriately" do
+ prefix = "whoa"
+ subject.attributes[:python_package_name_prefix] = prefix
+ subject.input(example_dir)
+ insist { subject.name } == "#{prefix}-example"
+ end
+ end
end
- it "it should not prefix the name at all" do
- subject.input(example_dir)
- insist { subject.name } == "example"
+ context "when :python_fix_name? is false" do
+ before :each do
+ subject.attributes[:python_fix_name?] = false
+ end
+
+ it "it should not prefix the name at all" do
+ subject.input(example_dir)
+ insist { subject.name } == "example"
+ end
end
end
end # describe FPM::Package::Python

0 comments on commit 5be1ac0

Please sign in to comment.