从本地 python 包构建 conda 包

2022-01-13 python conda package

问题描述

我找不到一个完整的示例,说明如何从我编写的 python 包创建 conda 包,以及如何使用 conda install 安装包,而它在我的计算机上而不是在 anaconda 云上.例如,我正在寻找不使用 pypi 的 conda 骨架,而是在我的 windows 机器上使用 python 包,源代码必须在我的 windows 机器上,而不是在 pypi 或其他云上.任何帮助都会很重要.非常感谢

I can't find a complete example of how to create a conda package from a python package that I wrote and also how to install the package using conda install, while it is on my computer and not on anaconda cloud. I'm looking for example that not using conda skeleton from pypi, but using a python package on my windows machine, the source code must be on my windows machine and not on pypi or other cloud. any help would be mostly appriciate. thanks very much


解决方案

可以在元数据文件 meta.yaml 中指定一个本地源目录,方法是:

A local source directory can be specified in the metadata file meta.yaml by using:

  source:
     path: ../src

https://docs.conda.io/projects/conda-build/en/latest/resources/define-metadata.html#source-from-a-local-path

此外,要打包您自己的程序,您必须定义构建和安装它所需的步骤(例如,为使用 setuptools 的 python 脚本运行 setup.py install:https://setuptools.readthedocs.io/en/latest/index.html) 文件 build.sh for linux 和用于 Windows 的 bld.bat.

Additionally, to package your own program you have to define the steps needed to build and install it (for instance, running setup.py install for a python script that uses setuptools: https://setuptools.readthedocs.io/en/latest/index.html) in the files build.sh for linux and bld.bat for windows.

相关文章