Repository: NoRedInk/make-lambda-package

Issue:
Script breaks if --requirements-file is not given
- remove temporary `import click` statement from cli.py


Discussion:

Patch:
diff --git a/README.in b/README.in
index 2a4dc23..3a2a879 100644
--- a/README.in
+++ b/README.in
@@ -6,16 +6,20 @@ source code, configs, and dependencies with extension modules.
 
 # Installation
 
-If you don't use `pipsi`, you're missing out.
-Here are [installation instructions](https://github.com/mitsuhiko/pipsi#readme).
+With [pipsi](https://github.com/mitsuhiko/pipsi#readme):
 
-Simply run:
+    $ pipsi install make-lambda-package
 
-    $ pipsi install .
 
+Or pip:
 
-Packaging dependencies requires [the `docker` command](https://www.docker.com/)
-to be in your `$PATH`.
+    $ pip install make-lambda-package
+
+
+Packaging dependencies with the `--requirements-file` option requires
+[the `docker` command](https://www.docker.com/) to be in your `$PATH`.
+Dependencies will be built in a [lambci/lambda:build-python2.7](https://github.com/lambci/docker-lambda)
+container.
 
 
 # Usage
diff --git a/README.md b/README.md
index 1730484..1aa21ef 100644
--- a/README.md
+++ b/README.md
@@ -6,16 +6,20 @@ source code, configs, and dependencies with extension modules.
 
 # Installation
 
-If you don't use `pipsi`, you're missing out.
-Here are [installation instructions](https://github.com/mitsuhiko/pipsi#readme).
+With [pipsi](https://github.com/mitsuhiko/pipsi#readme):
 
-Simply run:
+    $ pipsi install make-lambda-package
 
-    $ pipsi install .
 
+Or pip:
 
-Packaging dependencies requires [the `docker` command](https://www.docker.com/)
-to be in your `$PATH`.
+    $ pip install make-lambda-package
+
+
+Packaging dependencies with the `--requirements-file` option requires
+[the `docker` command](https://www.docker.com/) to be in your `$PATH`.
+Dependencies will be built in a [lambci/lambda:build-python2.7](https://github.com/lambci/docker-lambda)
+container.
 
 
 # Usage
diff --git a/make_lambda_package/cli.py b/make_lambda_package/cli.py
index 4d87a7d..e600fdd 100644
--- a/make_lambda_package/cli.py
+++ b/make_lambda_package/cli.py
@@ -70,13 +70,20 @@ def main(
     paths = fsutil.decide_paths(scm_source, work_dir)
 
     if requirements_file:
-        import click
-        docker_retcode = subprocess.call(['docker', '--help'])
+        with open(os.devnull, 'w') as devnull:
+            docker_retcode = subprocess.call(['docker', '--help'], stdout=devnull)
         if docker_retcode != 0:
             raise click.UsageError(
                 "`docker` command doesn't seem to be available. "
                 "It's required to package dependencies.")
 
+    if not (requirements_file or repo_source_files or local_source_file):
+        click.secho(
+            'Warning: without --repo-source-files, --requirements-file, '
+            'or --local-source-file, nothing will be included in the zip file. '
+            'Assuming you have good reasons to do this and proceeding.',
+            fg='yellow')
+
     fsutil.ensure_dirs(paths)
 
     if isinstance(scm_source, fsutil.RemoteSource):
diff --git a/update_readme.py b/update_readme.py
old mode 100644
new mode 100755
index bb821e2..d735a59
--- a/update_readme.py
+++ b/update_readme.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python
 import os
 import sys
 import subprocess


Test patch:
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 55707e4..23a1fa6 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -11,7 +11,30 @@ def runner():
     return CliRunner()
 
 
-def test_end_to_end(tmpdir, runner):
+def test_with_no_source_options(tmpdir, runner):
+    cwd = os.getcwd()
+    work_dir = tmpdir.join('deploy_package')
+    args = [
+        cwd,
+        '--work-dir', str(work_dir),
+    ]
+
+    with tmpdir.as_cwd():
+        result = runner.invoke(cli.main, args)
+        assert not result.exception, result.output
+        assert result.exit_code == 0, result.output
+
+        zip_path = work_dir.join('dist', 'lambda-package.zip')
+        assert zip_path.isfile(), result.output
+
+        with ZipFile(str(zip_path)) as zipfile:
+            namelist = zipfile.namelist()
+            assert len(list(namelist)) == 0
+
+        assert 'Warning' in result.output
+
+
+def test_with_all_source_options(tmpdir, runner):
     cwd = os.getcwd()
     work_dir = tmpdir.join('deploy_package')
     args = [