Building a package requires a recipe. A recipe is flat directory which
contains the following files:
meta.yaml (metadata file)
build.sh (Unix build script which is executed using bash)
bld.bat (Windows build script which is executed using cmd)
run_test.py (optional Python test file)
patches to the source (optional, see below)
other resources, which are not included in the source and cannot be
generated by the build scripts.
The same recipe should be used to build a package on all platforms.
When building a package, the following steps are invoked:
read the metadata
download the source (into a cache)
extract the source in a source directory
apply the patches
create a build environment (build dependencies are installed here)
run the actual build script. The current working directory is the source
directory with environment variables set. The build script installs into
the build environment
do some necessary post processing steps: shebang, rpath, etc.
add conda metadata to the build environment
package up the new files in the build environment into a conda package
test the new conda package:
create a test environment with the package (and its dependencies)
run the test scripts
There are example recipes for many conda packages in the conda-recipes
<https://github.com/continuumio/conda-recipes>_ repo.
The :ref:conda skeleton <skeleton_ref> command can help to make skeleton recipes for common
repositories, such as PyPI <https://pypi.python.org/pypi>_.
你可能想看看PEX:https://pex.readthedocs.io/en/stable/whatispex.html
扩展名为.pex的文件-“pex文件”或“.pex文件”是自包含的可执行Python虚拟环境。PEX文件使Python应用程序的部署变得容易:部署过程变得简单的scp
事实上,没有一种好的标准方法可以移植地安装软件包的依赖项。连续体有made conda for precisely this purpose。numpy的人在他们的包中编写了自己的distutils子模块来安装一些复杂的依赖项,现在是at least some of them advocate conda as a solution。不幸的是,您可能必须自己为这些依赖项制作conda包。在
如果没有可移植性,那么以目标机器的包管理器为目标显然是可行的。否则,对于便携式包管理器,conda是我所知的唯一选择。在
或者,从您的帖子(“动态编译不是一个选项”)听起来,可移植性对您来说可能不是问题,在这种情况下,您还可以将所有需求安装到前缀目录(我遇到的大多数安装程序都支持
configure prefix=/some/dir/
选项)。如果您有一个保证的单一体系结构,您可能可以将所有依赖项预先安装到一个目录中,然后像文件一样传递。conda方法可能会更简洁,但我已经使用了相当多的前缀安装,而且它们往往是最容易使用的解决方案之一。在编辑: 对于conda,它同时是一个包管理器和一个类似virtualenv的环境/python安装。虽然virtualenv是在现有python安装的基础上添加的,但conda会接管整个安装过程,因此您可以更确定所有依赖项都得到了考虑。与pip相比,它是为添加通用的非Python依赖项而设计的,而不是仅仅编译C/Cpp扩展。更多信息,我会看到:
至于如何将conda用于您的目的,the docs请解释如何创建配方:
然后,作为客户机,您将安装包similar to how you would install from pip
最后,docker可能对您也很感兴趣,尽管我还没有看到它在Python中有多少使用。在
相关问题 更多 >
编程相关推荐