32

I am building a Python package using conda-build. Right now, my structure looks like this:

- my_recipe/
    - meta.yaml
    - build.sh

And my meta.yaml reads thusly:

package:
  name: my_pkg
version: "0.2.0"

source:
  path: ../my_pkg

requirements:
  build:
    - python
    - setuptools
  run:
    - python
    - pandas
    - numpy
    - plotly
    - matplotlib
    - pyqtgraph
    - pyopengl
    - gdal
    - scipy
    - scikit-image

The package itself builds correctly when I run

conda-build my_recipe/

and it installs successfully when I run

conda install -n my_env --use-local ~/miniconda3/envs/my_env/conda-bld/linux-64/my_pkg-0.2.0-py36_0.tar.bz2

However, none of the dependencies listed under run seem to install along with the package. For example, when I import the package in Python it says that pandas could not be found.

Are my dependencies listed in the correct location? Do I also need to list the dependencies in setup.py? The documentation is not very clear on where this information should be.

Bryce Frank
  • 697
  • 10
  • 24
  • 5
    Rather that specifying the full path, the purpose of the `--use-local` is to go and look at the `conda-bld` folder. I suspect the cause is that you've listed the full path to the file rather than just the name of the package, since full paths to files don't install dependencies. Try with `conda install -n my_env --use-local my_pkg` – darthbith Apr 13 '18 at 19:11
  • 1
    @darthbith I can confirm the behavior and I'm not pointing to the directory. Like OP, when referencing a built package (located in `conda-bld` and built using `conda-build`), `conda install` does not install `run` dependencies. Why am I trying to use conda again? – medley56 Jul 21 '20 at 18:38
  • 2
    Did you manage to find a solution? I am experiencing the same issue. – jarandaf Jan 27 '21 at 09:20
  • I am also facing similar issue. Is there any known solution. The two solutions below doesnt work for me. – Naresh Oct 11 '21 at 09:38
  • Could you please accept/upvote an answer? This question should be used as the canonical one for this issue, but lack of upvoting prevents this. I believe the community wiki one I added is the proper answer, but I can’t upvote myself. – merv Dec 28 '21 at 17:56
  • My issue was that I was using the full filename, but you only need the *package name* My zip file is named `ipypdf-0+untagged.105.g7f64c9d.dirty-py_0.tar.bz2` So I `CD` into the directory it is stored in, then use this command to install it. `conda install --use-local ipypdf -c conda-forge` `-c conda-forge` is included for the dependencies – Joel Stansbury Jan 29 '22 at 04:32

4 Answers4

2

Specifying the channel works for me.

Actually, you don't even need to specify the full path. For instance, from the folder where the recipe is located (the meta.yaml and build.sh), I build my package with:

conda-build . --output-folder ./build

Then, I install the package with:

conda install my_package_name -c ./build

This will also install the dependencies specified in the meta.yaml. Here is how my meta.yaml looks like.

package:
  name: my_package_name
  version: 0.0.1

source:
  path: .

requirements:
  build:
    - python
    - setuptools

  run:
    - python
    - numpy
    - holopy
    - scikit-image
Miotto
  • 289
  • 2
  • 6
2

As commented by @darthbith, using the --use-local flag with the package name,

conda install -n my_env --use-local my_pkg

works as intended. Using a path to a tarball directly triggers Conda to install without dependencies.

merv
  • 67,214
  • 13
  • 180
  • 245
1

I've had luck telling conda to treat the local directory as a channel:

conda install my-package-name -c file:///FULL_PATH_TO_CONDA/envs/my_env/conda-bld/

I figured this out based on instructions here, although note I didn't have to run conda index first because conda build had already created repodata.json files.

Singularity
  • 485
  • 1
  • 4
  • 16
0

I found that using the --update-deps flag when installing a local package does install the package's dependencies, as expected. Like this:

conda install --use-local --update-deps my-package-name
RobinDunn
  • 6,116
  • 1
  • 15
  • 14