Doing a conda-build does not find any files

Viewed 836

I am trying to build a simple package for upload to anaconda cloud. I have gone a long way to get a small example working, but I am unable to use a package built by conda on the target machine (always giving me a ModuleNotFound-Error). However, I doubt that this is the fault of the target machine (more likely the build process is messed up) - so please bear with me and let me explain what I did.

My python code is just one file with one function in there

def plusone(number):
  return number+1

As already said, I want to do a build with conda-build and upload the package to my anaconda cloud channel. I have created a folder, named conda-recipe which contains the bld.bat, build.sh and meta.yaml files. So the complete structure looks like this:

conda test            (<- root folder)
    conda-recipe
        bld.bat
        build.sh
        meta.yaml
    dist
        <files created by running setup.py>
    plusone
        __init__py
        plusone.py
    plusone.egg-info
        <created info-files>
    README.md
    requirements.txt            (<- only contains a ".")
    setup.py

I change via Anaconda Command Line Tool into the project root, then run

conda build conda-recipe

Everything seems to work fine, also the upload to anaconda cloud is working (package is uploaded). If I change to another machine, I can even install the package via running

conda install -c <MYCHANNEL> <PACKAGENAME>

However, when I run the package from either a Jupyter Notebook or from within Pycharm I get a 'ModuleNotFound' Error concerning my package. First, I thought that this might have to do with my target system (i.e. where I use the package) and I have gone through several articles where I made sure that PYTHONPATH is set correctly and that the python installation really looks into the folder where the package is installed to. I know that the package really gets installed and the python installation looks into the corresponding directory. Also, conda list indicates that the package is installed.

After investing 1 1/2 days in this issue I have spend time in reviewing my build process and have done the following: If I do only run my setup.py file with the parameter sdist, a tar.gz file is created. I can upload this and anaconda cloud recognizes that the file is a pypi-Archive. I can even download and install this file on a target machine and succesfully use it there. So, generally, I'd say that my code is ok (surprise surprise) and the target machine's python installation is OK too. Hence I went back to the conda-build-command. And believe me, I have looked at the documentation not just one time.

However, the output of conda-build says towards the end the following:

Packaging plusone
INFO:conda_build.build:Packaging plusone
INFO conda_build.build:build(1571): Packaging plusone
Packaging plusone-12.0-0
INFO:conda_build.build:Packaging plusone-12.0-0
INFO conda_build.build:bundle_conda(891): Packaging plusone-12.0-0
No files or script found for output plusone
WARNING:conda_build.build:No files or script found for output plusone
WARNING conda_build.build:bundle_conda(971): No files or script found for output plusone
number of files: 0

For me this indicates that the conda build process is not really producing a viable output. So, I have tried several options for specifying the source-section in the meta.yaml: url, git_url, path. None has lead to a different output. Looking at my meta.yaml in its latest form:

package:
    name: "plusone"
    version: 12.0

requirements:
    host:
        - python=3.7
        - pip
        - setuptools
    run:
        - python

source:
    path: ../plusone

My bld.bat:

<ABSOLUTE path to python>\\python.exe "<ABSOLUTE path to setup>\\setup.py" install
if errorlevel 1 exit 1

My build.sh: $PYTHON setup.py install

No matter how I change my meta.yaml-File, I am always get the output that no files are found for output. However, when checking the anaconda build directory, I can see that there are non-empty folders named src_cache and git_cache, so I know that anaconda has at least access to the files.

So - can anybody tell my, why

  1. conda build tells me there are 0 files
  2. I cannot use my conda-module and it always gives me a ModuleNotFound Error?
2 Answers

After searching again, by accident, I have found this page here on S/O: enter link description here. Turns out that changing a few things fixes the issue for me. The meta.yaml was changed to include the followint source-section:

source:
  path: ../../

and my bld.bat was changed to

"%PYTHON%" ./conda_test/setup.py sdist install

I hope this helps anyone.

For me, my conda meta.yaml file was missing a build section. I managed to fix my 0 files found error by adding a build section containing just python (thanks @merv for putting me on the right track with your comment about the missing run section).

So now my recipe looks like

package:
  name: mypackage
  version: {{ GIT_DESCRIBE_TAG }}

source:
  path: ..

requirements:
  build:
    - python
  run:
    - astropy
    - ipywidgets
    - matplotlib
    - pooch
    - scipy
    - tifffile
Related