从本地 C++ 程序构建 conda 包
Build conda package from a local C++ program
我正在尝试构建(并稍后上传)一个包含我用 C++ 开发的自定义程序的 conda 包。
简化问题,我有以下 meta.yaml
:
package:
name: CoolName
version: "1.0.0"
source:
path: ./source
requirements:
build:
- make
和以下 build.sh
:
make
我这里有两个问题:
1) 我应该如何以及在哪里复制 make
编译结果的二进制文件,以便它在环境激活时确实被识别?
2) 我应该如何将 g++ 指定为依赖项?我想让这个包稍后可用于 linux-64
和 osx-64
... 在构建过程中(在 Makefile 中)我只使用 g++。
编辑
我修改了我的构建脚本:
make
mkdir -p $PREFIX/bin
cp my_binary $PREFIX/bin/my_binary
现在 conda-build
成功了。但是,当我稍后尝试使用 conda install --use-local
在本地安装软件包时,我得到:
Collecting package metadata (current_repodata.json): done
Solving environment: done
# All requested packages already installed.
但这不是真的,我的二进制文件没有安装在任何地方,也无法识别...
- 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?
正如您在编辑中提到的,安装在 ${PREFIX}
中的某个位置
- How should I specify g++ as a dependancy?
要使用 conda 提供的编译器(而不是您的系统编译器),请使用:
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++.
注意:在 Mac 上,它将使用 clang++
,而不是 g++
。确保您的 Makefile 遵循 ${CXX}
环境变量而不是硬编码 g++
.
However, when I later try to install the package locally with conda install --use-local
I get:
这很奇怪。 conda install --use-local CoolName
应该做你想做的。但这里有一些尝试:
仔细检查您要安装它的环境的内容:
conda list
尝试安装到新环境:
conda create -n my-new-env --use-local CoolName
删除您在成功构建包之前可能创建的包的任何过时版本:
# 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
...然后再尝试 运行 conda install
。
我正在尝试构建(并稍后上传)一个包含我用 C++ 开发的自定义程序的 conda 包。
简化问题,我有以下 meta.yaml
:
package:
name: CoolName
version: "1.0.0"
source:
path: ./source
requirements:
build:
- make
和以下 build.sh
:
make
我这里有两个问题:
1) 我应该如何以及在哪里复制 make
编译结果的二进制文件,以便它在环境激活时确实被识别?
2) 我应该如何将 g++ 指定为依赖项?我想让这个包稍后可用于 linux-64
和 osx-64
... 在构建过程中(在 Makefile 中)我只使用 g++。
编辑
我修改了我的构建脚本:
make
mkdir -p $PREFIX/bin
cp my_binary $PREFIX/bin/my_binary
现在 conda-build
成功了。但是,当我稍后尝试使用 conda install --use-local
在本地安装软件包时,我得到:
Collecting package metadata (current_repodata.json): done
Solving environment: done
# All requested packages already installed.
但这不是真的,我的二进制文件没有安装在任何地方,也无法识别...
- 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?
正如您在编辑中提到的,安装在 ${PREFIX}
- How should I specify g++ as a dependancy?
要使用 conda 提供的编译器(而不是您的系统编译器),请使用:
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++.
注意:在 Mac 上,它将使用 clang++
,而不是 g++
。确保您的 Makefile 遵循 ${CXX}
环境变量而不是硬编码 g++
.
However, when I later try to install the package locally with
conda install --use-local
I get:
这很奇怪。 conda install --use-local CoolName
应该做你想做的。但这里有一些尝试:
仔细检查您要安装它的环境的内容:
conda list
尝试安装到新环境:
conda create -n my-new-env --use-local CoolName
删除您在成功构建包之前可能创建的包的任何过时版本:
# 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
...然后再尝试 运行 conda install
。