conda-tools / conda-build-all

BSD 3-Clause "New" or "Revised" License
30 stars 24 forks source link

AttributeError: 'Dist' object has no attribute 'fn' from rerender #76

Closed jakirkham closed 7 years ago

jakirkham commented 7 years ago

From @asmeurer on January 16, 2017 4:8

I tried to rerender sphinxcontrib-autoprogram and got this error:

$conda smithy rerender
No circle token.  Create a token at https://circleci.com/account/api and
put it in ~/.conda-smithy/circle.token
No appveyor token. Create a token at https://ci.appveyor.com/api-token and
Put one in ~/.conda-smithy/appveyor.token
No anaconda token. Create a token via
  anaconda auth --create --name conda-smithy --scopes "repos conda api"
and put it in ~/.conda-smithy/anaconda.token
Fetching package metadata .................
Traceback (most recent call last):
  File "/Users/aaronmeurer/anaconda3/bin/conda-smithy", line 6, in <module>
    sys.exit(conda_smithy.cli.main())
  File "/Users/aaronmeurer/anaconda3/lib/python3.5/site-packages/conda_smithy/cli.py", line 289, in main
    args.subcommand_func(args)
  File "/Users/aaronmeurer/anaconda3/lib/python3.5/site-packages/conda_smithy/cli.py", line 200, in __call__
    configure_feedstock.main(args.feedstock_directory)
  File "/Users/aaronmeurer/anaconda3/lib/python3.5/site-packages/conda_smithy/configure_feedstock.py", line 644, in main
    render_run_docker_build(env, config, forge_dir)
  File "/Users/aaronmeurer/anaconda3/lib/python3.5/site-packages/conda_smithy/configure_feedstock.py", line 77, in render_run_docker_build
    forge_config.get('channels', {}).get('sources', tuple())
  File "/Users/aaronmeurer/anaconda3/lib/python3.5/site-packages/conda_smithy/configure_feedstock.py", line 565, in compute_build_matrix
    mtx = special_case_version_matrix(meta, index)
  File "/Users/aaronmeurer/anaconda3/lib/python3.5/site-packages/conda_build_all/version_matrix.py", line 212, in special_case_version_matrix
    py_vn = minor_vn(index[python_pkg.fn]['version'])
AttributeError: 'Dist' object has no attribute 'fn'

Copied from original issue: conda-forge/conda-smithy#435

jakirkham commented 7 years ago

Also this example cropped up elsewhere. Looks like it is the same issue.

cc @synapticarbors

jakirkham commented 7 years ago

What does conda list -n root show, @asmeurer?

jakirkham commented 7 years ago

Should add this is pretty strange as a couple lines earlier it accesses fn. Since the traceback doesn't point there, we must have fn. However it is magically gone a few lines later.

jakirkham commented 7 years ago

FWICT this is a conda-build-all issue. Am going to move this over there and see what they think.

jakirkham commented 7 years ago

Would appreciate if both of you provide the conda version in use. I'm unable to reproduce this with 4.1 or 4.2. However, with 4.3 I do get this error. That being said, AFAIK conda-build doesn't even support 4.3. Given conda-build-all and conda-smithy are dependent on conda-build, I'm not sure how they could support 4.3 either until conda-build does. Would recommend downgrading to conda 4.2 until it can be sorted out.

jakirkham commented 7 years ago

Copying @msarahan and @kalefranz for awareness.

kalefranz commented 7 years ago

Looked at some of the code. Snippet from version_matrix.py line 229

    elif 'python' in requirement_specs:
        py_spec = requirement_specs.pop('python')
        for python_pkg in r.get_pkgs(py_spec):
            py_vn = minor_vn(index[python_pkg.fn]['version'])
            case = (('python', py_vn), )
            add_case_if_soluble(case)

The get_pkgs() method got renamed to get_dists_for_spec(), but get_pkgs() still exists for a while for backward compatibility. It now returns a Dist object though, which is the index key you want to use, not python_pkg.fn. So (for now), the only fix needed in this code snippet is to change

py_vn = minor_vn(index[python_pkg.fn]['version'])

to

py_vn = minor_vn(index[python_pkg]['version'])
dfroger commented 7 years ago

I have the same problem here https://github.com/conda-forge/mayavi-feedstock/pull/2

dfroger commented 7 years ago
conda --version
conda 4.3.4

After downgrading to conda to 4.2.15, conda smithy rerender works.

Good to know that conda-build does not support conda 4.3!

dfroger commented 7 years ago

I think that my problem is that my ~/.condarc is:

channels:
  - defaults
  - conda-forge

as a result, I have a mix of package from defaults and conda-forge:

$ conda list --show-channel-urls conda
# packages in environment at /home/dfroger/miniconda3:
#
anaconda-client           1.6.0                    py35_0    defaults
conda                     4.3.4                    py35_0    defaults
conda-build               2.1.1                    py35_0    defaults
conda-build-all           1.0.1                    py35_1    conda-forge
conda-env                 2.6.0                         0    defaults
conda-smithy              2.0.0                    py35_0    conda-forge
conda-verify              2.0.0                    py35_0    defaults

I'll change my ~/.condarc with:

channels:
  - conda-forge
  - defaults

and reinstally my root env.

The conda-build from conda-forge should prevent me to update conda to 4.3.

dfroger commented 7 years ago

My root env is now:

# packages in environment at /home/dfroger/miniconda3:
#
anaconda-client           1.5.1                    py35_0    conda-forge
conda                     4.2.13                   py35_0    conda-forge
conda-build               2.1.1                    py35_0    conda-forge
conda-build-all           1.0.1                    py35_1    conda-forge
conda-env                 2.6.0                         0    conda-forge
conda-smithy              2.0.0                    py35_0    conda-forge
conda-verify              2.0.0                    py35_0    defaults

and conda update conda no more update to 4.3.

jakirkham commented 7 years ago

Thanks for the pointer, @kalefranz. Seems simple enough.

jakirkham commented 7 years ago

As of conda-build 2.1.2, conda 4.3 is supported. So this is now a conda-build-all issue alone.

jakirkham commented 7 years ago

cc-ing @jjhelmus for awareness.

kalefranz commented 7 years ago

fix 'Dist' object has no attribute 'fn'

https://github.com/conda/conda/pull/4424

kalefranz commented 7 years ago

Didn't realize the problem was that trivial. There will likely be other things you encounter though before you have full compatibility with conda 4.3.

PierreKiwi commented 7 years ago

Hello, Thanks for the fix in conda 4.3! Any ETA to make conda-build-all works with conda 4.3?

FYI In order to make conda-build-all works I have to pin conda to version to 4.2.13 (using latest conda-build is OK then install conda-build-all (not from a conda-forge 1.0.2 but from a private channel where I have published conda-forge to).

jakirkham commented 7 years ago

I think the first thing we need to do is adding a CI matrix item that tests against conda 4.3.x to see what the current issues are.

marscher commented 7 years ago

https://travis-ci.org/SciTools/conda-build-all/jobs/214380561

@kalefranz I think you're the man to ping here. In version_matrix:129 there is a call to conda.resolve.Resolve(index), which expects apparently another type, than what is passed in conda-build-all. Can you please point me into the right direction here?

kalefranz commented 7 years ago

For this particular stack trace I'm seeing, https://github.com/conda/conda/pull/4931 will fix it. Apparently conda-build-all is creating an index dict, or adding items to an index dict, with str keys. In conda 4.3, the key changed from a str to a conda.models.dist.Dist object. In addition to the PR in conda, you could figure out in the conda-build-all code where the index dict is being built and mutated, and then ensure the keys are wrapped with the Dist object.

marscher commented 7 years ago

Thank you @kalefranz. Your hints helped me to fix all tests.

jakirkham commented 7 years ago

The latest version of conda-build-all (1.0.4) has conda 4.3 support. Thanks everyone for their work in making this happen.