Build conda package from a local C++ program

Viewed 1611

I am trying to build (and later upload) a conda package which would contain my custom program that I have developed in C++.
Simplifying the problem, I have a following meta.yaml:

package:
  name: CoolName
  version: "1.0.0"

source:
  path: ./source

requirements:
  build:
    - make

and the following build.sh:

make

I have two questions here:
1) How and where should I copy the binary which is a result of the make compilation so that it is indeed recognized upon environment activation?
2) How should I specify g++ as a dependancy? I would like to have this package be later available for linux-64 and osx-64... In the building process (in the Makefile) I am using only g++.


Edit

I have modified my build script to have:

make
mkdir -p $PREFIX/bin
cp my_binary $PREFIX/bin/my_binary

And now the conda-build is successful. However, when I later try to install the package locally with conda install --use-local I get:

Collecting package metadata (current_repodata.json): done
Solving environment: done

# All requested packages already installed.

But this is not true, my binary is not installed anywhere and is not recognized...

1 Answers
  1. How and where should I copy the binary which is a result of the make compilation so that it is indeed recognized upon environment activation?

As you mentioned in your edit, install somewhere within ${PREFIX}

  1. How should I specify g++ as a dependancy?

To use conda-supplied compilers (rather than your system compiler), use this:

requirements:
  build:
    - {{ compiler('cxx') }}

I would like to have this package be later available for linux-64 and osx-64... In the building process (in the Makefile) I am using only g++.

Note: On Mac, it will use clang++, not g++. Make sure your Makefile respects the ${CXX} environment variable instead of hard-coding g++.

However, when I later try to install the package locally with conda install --use-local I get:

That is strange. conda install --use-local CoolName should do what you want. But here are some things to try:

  • Double-check the contents of the environment you're trying to install it into:

      conda list
    
  • Try installing to a fresh environment:

      conda create -n my-new-env --use-local CoolName
    
  • Delete any obsolete versions of the package you might have created before you successfully built the package:

# Inspect the packages you've created,
# and consider deleting all but the most recent one.
ls $(conda info --base)/conda-bld/linux-64/CoolName*.tar.bz2

...then try running conda install again.

Related