Repository: conda/conda-build

Issue:
Command line options dropped in transition to 2.0
The options `--setup-options` and `--pin-numpy` added in #680 were inadvertently dropped in the refactor of the command line options. The underlying code to implement them is still there; I can do a PR this weekend to fix.

Command line options dropped in transition to 2.0
The options `--setup-options` and `--pin-numpy` added in #680 were inadvertently dropped in the refactor of the command line options. The underlying code to implement them is still there; I can do a PR this weekend to fix.



Discussion:
Argh, sorry about that.  Merge conflicts and such.  I think it's better if I do it, unless you just want to.  In particular, we should add tests in test_cli.py to ensure that these options are available.

Looking back, I probably changed the tests to use the API, but did not keep the CLI integration test part of it.  Sorry again.

@msarahan -- no worries! You are right about the tests -- they check the API (which works) but not the cli. Completely fine with me if you want to take care of it.

I will have time this weekend though..so if it gets to Sunday afternoon and you haven't had a chance, I'll open PR.

https://github.com/conda/conda-build/pull/1384  <- this is the region of code that appears to be causing the issue. Let me know whether accessing the attributes of the config object is an appropriate patch strategy - alternatively the entire config object would need to be passed into the skeletonize function and CLI options extracted in there.

I think #1384 is addressing a separate problem. The issue here is that some options available in `api.skeletonize` are not recognized as command line arguments.

Hey @mwcraig - Whoops - you're right. The PR addresses the CLI arguments being ignored. Apologies! I've commented on the correct issue :)

Argh, sorry about that.  Merge conflicts and such.  I think it's better if I do it, unless you just want to.  In particular, we should add tests in test_cli.py to ensure that these options are available.

Looking back, I probably changed the tests to use the API, but did not keep the CLI integration test part of it.  Sorry again.

@msarahan -- no worries! You are right about the tests -- they check the API (which works) but not the cli. Completely fine with me if you want to take care of it.

I will have time this weekend though..so if it gets to Sunday afternoon and you haven't had a chance, I'll open PR.

https://github.com/conda/conda-build/pull/1384  <- this is the region of code that appears to be causing the issue. Let me know whether accessing the attributes of the config object is an appropriate patch strategy - alternatively the entire config object would need to be passed into the skeletonize function and CLI options extracted in there.

I think #1384 is addressing a separate problem. The issue here is that some options available in `api.skeletonize` are not recognized as command line arguments.

Hey @mwcraig - Whoops - you're right. The PR addresses the CLI arguments being ignored. Apologies! I've commented on the correct issue :)


Resolving patch:
diff --git a/conda_build/skeletons/pypi.py b/conda_build/skeletons/pypi.py
--- a/conda_build/skeletons/pypi.py
+++ b/conda_build/skeletons/pypi.py
@@ -533,6 +533,25 @@ def add_parser(repos):
         help="Creates recipe as noarch python"
     )
 
+    pypi.add_argument(
+        "--setup-options",
+        action='append',
+        default=[],
+        help='Options to be added to setup.py install in the recipe. '
+             'The same options are passed to setup.py install in both '
+             'the construction of the recipe and in the recipe itself.'
+             'For options that include a double-hypen or to pass multiple '
+             'options, use the syntax '
+             '--setup-options="--option1 --option-with-arg arg"'
+    )
+
+    pypi.add_argument(
+        "--pin-numpy",
+        action='store_true',
+        help="Ensure that the generated recipe pins the version of numpy"
+             "to CONDA_NPY."
+    )
+
 
 def get_xmlrpc_client(pypi_url):
     return ServerProxy(pypi_url, transport=RequestsTransport())


Test patch:
diff --git a/tests/test_cli.py b/tests/test_cli.py
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -5,6 +5,7 @@
 import json
 import os
 import sys
+import yaml
 
 import pytest
 
@@ -139,6 +140,41 @@ def test_skeleton_pypi(testing_workdir, test_config):
     main_build.execute(args)
 
 
+def test_skeleton_pypi_arguments_work(testing_workdir, test_config):
+    """
+    These checks whether skeleton executes without error when these
+    options are specified on the command line AND whether the underlying
+    functionality works as a regression test for:
+
+    https://github.com/conda/conda-build/pull/1384
+    """
+    args = ['pypi', 'msumastro', '--pin-numpy']
+    main_skeleton.execute(args)
+    assert os.path.isdir('msumastro')
+
+    # Deliberately bypass metadata reading in conda build to get as
+    # close to the "ground truth" as possible.
+    with open('msumastro/meta.yaml') as f:
+        actual = yaml.load(f)
+
+    assert 'numpy x.x' in actual['requirements']['run']
+    assert 'numpy x.x' in actual['requirements']['build']
+
+    args = ['pypi', 'photutils', '--version=0.2', '--setup-options=--offline']
+    main_skeleton.execute(args)
+    assert os.path.isdir('photutils')
+    # Check that the setup option occurs in bld.bat and build.sh.
+    for script in ['bld.bat', 'build.sh']:
+        with open('photutils/{}'.format(script)) as f:
+            content = f.read()
+            assert '--offline' in content
+
+    with open(os.path.join('photutils', 'meta.yaml')) as f:
+        content = f.read()
+        assert 'version: "0.2"' in content
+
+
+
 def test_metapackage(test_config, testing_workdir):
     """the metapackage command creates a package with runtime dependencies specified on the CLI"""
     args = ['metapackage_test', '1.0', '-d', 'bzip2']