How do I fix conda UnsatisfiableError of my custom conda package?

Viewed 430

I'm trying to package my python code to publish in on Anaconda cloud. The folder structure looks like this:

.
├── conda-recipe
│   ├── build.bat
│   ├── build.sh
│   └── meta.yaml
├── demos
│   ├── datasets
│   │   ├── com-amazon.all.dedup.cmty.txt
│   │   ├── com-amazon.ungraph.txt
│   │   ├── email-Eu-core-department-labels.txt
│   │   └── email-Eu-core.txt
│   ├── directed_example.ipynb
│   ├── email_eu_core_network_evaluation-Copy1.ipynb
│   ├── node_classification.ipynb
│   └── zacharys_karate_club_evaluation.ipynb
├── LICENSE.txt
├── README.md
├── setup.py
├── sten
│   ├── embedding.py
│   └── __init__.py
├── test
│   ├── __init__.py
│   └── test_system.py
├── zachary_computed.png
└── zachary_expected.png

The meta.yaml file:

package:
  name: sten
  version: "0.1.0"

source:
  path: ..

build:
  number: 0
  noarch: generic

requirements:
  build:
    - python >=3.7
    - setuptools
  run:
    - python >=3.7
    - pypardiso >=0.2.2
    - numpy >=1.18.1
    - networkx >=2.4
    - scipy >=1.4.1
    - markdown


test:
  imports:
    - sten.embedding

about:
  home: https://github.com/monomonedula/simple-graph-embedding
  license: Apache License 2.0
  license_file: LICENSE.txt
  summary: Simple deterministic algorithm for generating graph nodes topological embeddings.

Command I am using to build the package (haasad is the name of the channel of the pypardiso package): conda build conda-recipe -c haasad The build is successful and I have uploaded it here: https://anaconda.org/monomonedula/sten

However, after installation using both local build like so: conda install sten --use-local -c haasad and the build uploaded to the cloud conda install -c monomonedula sten -c haasad I am encountering several problems.

  • When using python 3.7 I am unable to import my package even though it is listed in conda list (I have double checked everything, I am using the correct interpreter).
  • When using python 3.8 I am able to import and use it, but I am unable to install stellargraph for an unknown reason. The error message:
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: \ 
Found conflicts! Looking for incompatible packages.
This can take several minutes.  Press CTRL-C to abort.
failed                                                                                                                                                       

UnsatisfiableError: The following specifications were found to be incompatible with each other:

Output in format: Requested package -> Available versions

Output of conda search sten -c monomonedula --info:

sten 0.1.0 py38_0
-----------------
file name   : sten-0.1.0-py38_0.tar.bz2
name        : sten
version     : 0.1.0
build       : py38_0
build number: 0
size        : 16 KB
license     : Apache License 2.0
subdir      : noarch
url         : https://conda.anaconda.org/monomonedula/noarch/sten-0.1.0-py38_0.tar.bz2
md5         : 53661562513861f9433b252c8ae7b5f4
timestamp   : 2020-05-23 19:24:36 UTC
dependencies: 
  - markdown
  - networkx >=2.4
  - numpy >=1.18.1
  - pypardiso >=0.2.2
  - python >=3.7
  - scipy >=1.4.1

sten 0.1.0 py38_0
-----------------
file name   : sten-0.1.0-py38_0.tar.bz2
name        : sten
version     : 0.1.0
build       : py38_0
build number: 0
size        : 16 KB
license     : Apache License 2.0
subdir      : noarch
url         : https://conda.anaconda.org/monomonedula/noarch/sten-0.1.0-py38_0.tar.bz2
md5         : 53661562513861f9433b252c8ae7b5f4
timestamp   : 2020-05-23 19:24:36 UTC
dependencies: 
  - markdown
  - networkx >=2.4
  - numpy >=1.18.1
  - pypardiso >=0.2.2
  - python >=3.7
  - scipy >=1.4.1

Output of conda search stellargraph -c stellargraph --info:

stellargraph 1.0.0 py_0
-----------------------
file name   : stellargraph-1.0.0-py_0.tar.bz2
name        : stellargraph
version     : 1.0.0
build       : py_0
build number: 0
size        : 7.8 MB
license     : Apache Software
subdir      : noarch
url         : https://conda.anaconda.org/stellargraph/noarch/stellargraph-1.0.0-py_0.tar.bz2
md5         : e62b9c897d0a5481159c1e7cb8024717
timestamp   : 2020-05-05 07:54:44 UTC
dependencies: 
  - gensim >=3.4.0
  - ipykernel
  - ipython
  - matplotlib >=2.2
  - networkx >=2.2
  - numpy >=1.14
  - pandas >=0.24
  - python >=3.6
  - scikit-learn >=0.20
  - scipy >=1.1.0
  - tensorflow >=2.1.0

The repo

What am I missing here and how do I package it properly?

1 Answers

The problem is in your meta.yaml file. According to an Anaconda blog post:

Noarch generic packages allow users to distribute docs, datasets, and source code in conda packages

and

Noarch Python packages cut down on the overhead of building multiple different pure Python packages on different architectures and Python versions by sorting out platform and Python version-specific differences at install time

Because you want to distribute a pure python package, you should use noarch: python. Also, you don't need to set the python versions in build and run. I have included an updated meta.yaml below. It also includes the build script within it, so you no longer need the build.sh and build.bat files. It also fixes the license part to something that conda will accept (it's still Apache 2.0).

package:
  name: sten
  version: "0.1.0"

source:
  path: ..

build:
  number: 0
  noarch: python
  script: {{ PYTHON }} setup.py install

requirements:
  build:
    - python
    - setuptools
  run:
    - python
    - pypardiso >=0.2.2
    - numpy >=1.18.1
    - networkx >=2.4
    - scipy >=1.4.1
    - markdown

test:
  imports:
    - sten.embedding

about:
  home: https://github.com/monomonedula/simple-graph-embedding
  license: Apache-2.0
  license_family: Apache
  license_file: LICENSE.txt
  summary: Simple deterministic algorithm for generating graph nodes topological embeddings.

Here are the steps I used to build and install this package using the above meta.yaml file:

git clone https://github.com/monomonedula/simple-graph-embedding
cd simple-graph-embedding/
git checkout 'refactor&cleanup'
# Replace contents of `meta.yaml`
rm conda-recipe/build.sh conda-recipe/build.bat
conda create --yes -n testing python=3.7 conda-build conda-verify
conda activate testing
conda-build --channel haasad .

And here is what I did to install the package in the 3.7 environment. You will find the full path to the sten-0.1.0-py_0.tar.bz2 towards the bottom of the conda-build log output.

conda install -n testing /home/jakub/miniconda3/envs/testing/conda-bld/noarch/sten-0.1.0-py_0.tar.bz2
conda activate testing
$CONDA_PREFIX/bin/python -c "import sten"

I also tested the installation in a python 3.8 environment.

conda create --yes -n testing3.8 python=3.8
conda install -n testing3.8 /home/jakub/miniconda3/envs/testing/conda-bld/noarch/sten-0.1.0-py_0.tar.bz2
conda activate testing3.8
$CONDA_PREFIX/bin/python -c "import sten"

conda install --use-local sten isn't working for me -- there is a GitHub issue about it.

Related