Repository: conda/conda-build

Issue:
Error with conda skeleton (conda-build 2.x.x)
With `conda-build` version `2.0.0 to 2.0.3`, running

`conda skeleton pypi --python-version=2.7 planemo`

will result in the following error:

```
Applying patch: '/tmp/tmpxqqkr55xconda_skeleton_planemo-0.33.2.tar.gz/pypi-distutils.patch'
patching file core.py
Hunk #1 succeeded at 168 with fuzz 2 (offset 2 lines).
Traceback (most recent call last):
  File "/home/clemens/miniconda3/bin/conda-skeleton", line 6, in <module>
    sys.exit(conda_build.cli.main_skeleton.main())
  File "/home/clemens/miniconda3/lib/python3.5/site-packages/conda_build/cli/main_skeleton.py", line 65, in main
    return execute(sys.argv[1:])
  File "/home/clemens/miniconda3/lib/python3.5/site-packages/conda_build/cli/main_skeleton.py", line 61, in execute
    api.skeletonize(package, args.repo, config=config)
  File "/home/clemens/miniconda3/lib/python3.5/site-packages/conda_build/api.py", line 192, in skeletonize
    recursive=recursive, config=config, **kwargs)
  File "/home/clemens/miniconda3/lib/python3.5/site-packages/conda_build/skeletons/pypi.py", line 406, in skeletonize
    noprompt, packages, config=config, setup_options=setup_options)
  File "/home/clemens/miniconda3/lib/python3.5/site-packages/conda_build/skeletons/pypi.py", line 688, in get_package_metadata
    for section in config.sections():
AttributeError: 'Config' object has no attribute 'sections'

```

This command runs fine on `conda-build 1.21.14`. Additionally, there are multiple warnings beforehand at version `2.x.x`, but they might be related to the conda-forge repository, since they won't show up when using only the default channels (the same error still appears). Here is the full output:

```
Using 0.33.2
Use --version to specify a different version.
Using url https://pypi.python.org/packages/d9/56/074bc99330b3f3903125d183d5382abe27552a113f1a0f8fa53dce416a3d/planemo-0.33.2.tar.gz (315 KB) for planemo.
Downloading planemo
Using cached download
Unpacking planemo...
done
working in /tmp/tmp8vai2pkxconda_skeleton_planemo-0.33.2.tar.gz
Using Anaconda API: https://api.anaconda.org

The following NEW packages will be INSTALLED:

    ca-certificates: 2016.8.31-0      conda-forge
    certifi:         2016.8.31-py27_0 conda-forge
    ncurses:         5.9-9            conda-forge
    openssl:         1.0.2h-2         conda-forge
    pip:             8.1.2-py27_0     conda-forge
    python:          2.7.12-1         conda-forge
    pyyaml:          3.11-py27_0      conda-forge
    readline:        6.2-0            conda-forge
    setuptools:      26.1.1-py27_0    conda-forge
    sqlite:          3.13.0-1         conda-forge
    tk:              8.5.19-0         conda-forge
    wheel:           0.29.0-py27_0    conda-forge
    yaml:            0.1.6-0          conda-forge
    zlib:            1.2.8-3          conda-forge

WARNING:/home/clemens/miniconda3/lib/python3.5/site-packages/conda_build/build.py:Build prefix failed with prefix length 255
WARNING:/home/clemens/miniconda3/lib/python3.5/site-packages/conda_build/build.py:Error was: 
WARNING:/home/clemens/miniconda3/lib/python3.5/site-packages/conda_build/build.py:ERROR: placeholder '/opt/conda/envs/_build_placehold_placehold_placehold_placehold_placehold_placeho' too short in: conda-forge::ncurses-5.9-9

WARNING:/home/clemens/miniconda3/lib/python3.5/site-packages/conda_build/build.py:One or more of your package dependencies needs to be rebuilt with a longer prefix length.
WARNING:/home/clemens/miniconda3/lib/python3.5/site-packages/conda_build/build.py:Falling back to legacy prefix length of 80 characters.
WARNING:/home/clemens/miniconda3/lib/python3.5/site-packages/conda_build/build.py:Your package will not install into prefixes > 80 characters.

The following NEW packages will be INSTALLED:

    ca-certificates: 2016.8.31-0      conda-forge
    certifi:         2016.8.31-py27_0 conda-forge
    ncurses:         5.9-9            conda-forge
    openssl:         1.0.2h-2         conda-forge
    pip:             8.1.2-py27_0     conda-forge
    python:          2.7.12-1         conda-forge
    pyyaml:          3.11-py27_0      conda-forge
    readline:        6.2-0            conda-forge
    setuptools:      26.1.1-py27_0    conda-forge
    sqlite:          3.13.0-1         conda-forge
    tk:              8.5.19-0         conda-forge
    wheel:           0.29.0-py27_0    conda-forge
    yaml:            0.1.6-0          conda-forge
    zlib:            1.2.8-3          conda-forge

Applying patch: '/tmp/tmp8vai2pkxconda_skeleton_planemo-0.33.2.tar.gz/pypi-distutils.patch'
patching file core.py
Hunk #1 succeeded at 168 with fuzz 2 (offset 2 lines).
Traceback (most recent call last):
  File "/home/clemens/miniconda3/bin/conda-skeleton", line 6, in <module>
    sys.exit(conda_build.cli.main_skeleton.main())
  File "/home/clemens/miniconda3/lib/python3.5/site-packages/conda_build/cli/main_skeleton.py", line 65, in main
    return execute(sys.argv[1:])
  File "/home/clemens/miniconda3/lib/python3.5/site-packages/conda_build/cli/main_skeleton.py", line 61, in execute
    api.skeletonize(package, args.repo, config=config)
  File "/home/clemens/miniconda3/lib/python3.5/site-packages/conda_build/api.py", line 192, in skeletonize
    recursive=recursive, config=config, **kwargs)
  File "/home/clemens/miniconda3/lib/python3.5/site-packages/conda_build/skeletons/pypi.py", line 406, in skeletonize
    noprompt, packages, config=config, setup_options=setup_options)
  File "/home/clemens/miniconda3/lib/python3.5/site-packages/conda_build/skeletons/pypi.py", line 688, in get_package_metadata
    for section in config.sections():
AttributeError: 'Config' object has no attribute 'sections'

```



Discussion:
Thanks for the report. It's a bug. We'll fix it and get a new release out soon. 


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
@@ -685,10 +685,10 @@ def get_package_metadata(package, d, data, output_dir, python_version, all_extra
                 entry_points = pkginfo['entry_points']
             else:
                 setuptools_run = True
-                for section in config.sections():
+                for section in _config.sections():
                     if section in ['console_scripts', 'gui_scripts']:
                         value = ['%s=%s' % (option, _config.get(section, option))
-                                    for option in config.options(section)]
+                                    for option in _config.options(section)]
                         entry_points[section] = value
         if not isinstance(entry_points, dict):
             print("WARNING: Could not add entry points. They were:")


Test patch:
diff --git a/tests/test_api_skeleton.py b/tests/test_api_skeleton.py
--- a/tests/test_api_skeleton.py
+++ b/tests/test_api_skeleton.py
@@ -88,3 +88,8 @@ def test_pypi_version_sorting(testing_workdir, test_config):
 def test_list_skeletons():
     skeletons = api.list_skeletons()
     assert set(skeletons) == set(['pypi', 'cran', 'cpan', 'luarocks'])
+
+
+def test_pypi_with_entry_points(testing_workdir):
+    api.skeletonize('planemo', repo='pypi', python_version="2.7")
+    assert os.path.isdir('planemo')