首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何沉默或压制gfortran (或clang?)在conda的后端?

如何沉默或压制gfortran (或clang?)在conda的后端?
EN

Stack Overflow用户
提问于 2018-02-26 19:33:26
回答 1查看 1.1K关注 0票数 10

我一直致力于构建一个非常特殊的conda环境,它是为pythonR设计的,使用rpy2进行相声对话。我想出的用于安装适当的R包的方法如下:

代码语言:javascript
复制
# install_main_environment.sh
now=$(date +"%T")
echo "Start Time: $now"

## Create Main Environment (OSX-64)
conda create -n python3 python=3 --yes
source activate python3

## Jupyter
conda install jupyterlab --yes

## R
conda install -c r r --yes
conda install -c r r-essentials --yes
conda install -c r rstudio --yes
conda install gfortran_osx-64 --yes
conda install -c anaconda clangxx_osx-64 --yes
conda install rpy2 --yes

## Install Python Packages
source ./install_python_packages.sh

## Install R Packages
RScript ./install_r_packages.r

# End
now=$(date +"%T")
echo "End Time: $now"

然而,其中一行使后端变得非常冗长,因此每当我源/停用环境或安装包时,我都会得到一个非常详细的后端。

如何抑制这种情况或永久关闭额外的文本?在我的bash配置文件中,当我激活我的环境时,我将stderr & stdout定向到/dev/null source activate python3 > /dev/null 2>&1,但这只是一个不通用的修补程序。

这种情况存在于我的工作计算机:OSX 10.11.6 (El Capitan)和个人计算机OSX Sierra

下面是我所指的输出的一个例子:

代码语言:javascript
复制
jespinozlt-osx:~ jespinoz$ source activate python3

INFO: activate-gfortran_osx-64.sh made the following environmental changes:
+DEBUG_FFLAGS=-march=nocona -mtune=core2 -ftree-vectorize -fPIC -fstack-protector -O2 -pipe -march=nocona -mtune=core2 -ftree-vectorize -fPIC -fstack-protector -O2 -pipe -Og -g -Wall -Wextra -fcheck=all -fbacktrace -fimplicit-none -fvar-tracking-assignments
+F95=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-gfortran
+FC=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-gfortran
+FFLAGS=-march=nocona -mtune=core2 -ftree-vectorize -fPIC -fstack-protector -O2 -pipe
+FORTRANFLAGS=-march=nocona -mtune=core2 -ftree-vectorize -fPIC -fstack-protector -O2 -pipe
+GFORTRAN=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-gfortran
INFO: activate_clang_osx-64.sh made the following environmental changes:
+AR=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-ar
+AS=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-as
+CC=x86_64-apple-darwin13.4.0-clang
+CFLAGS=-march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe
+CHECKSYMS=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-checksyms
+CLANG=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-clang
+CODESIGN_ALLOCATE=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-codesign_allocate
+CONDA_BUILD_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
+CPPFLAGS=-D_FORTIFY_SOURCE=2 -mmacosx-version-min=10.9
+DEBUG_CFLAGS=-march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -Og -g -Wall -Wextra
+INDR=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-indr
+INSTALL_NAME_TOOL=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-install_name_tool
+LD=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-ld
+LDFLAGS=-Wl,-pie -Wl,-headerpad_max_install_names -Wl,-dead_strip_dylibs
+LDFLAGS_LD=-pie -headerpad_max_install_names -dead_strip_dylibs
+LIBTOOL=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-libtool
+LIPO=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-lipo
+NM=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-nm
+NMEDIT=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-nmedit
+OTOOL=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-otool
+PAGESTUFF=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-pagestuff
+RANLIB=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-ranlib
+REDO_PREBINDING=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-redo_prebinding
+SEGEDIT=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-segedit
+SEG_ADDR_TABLE=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-seg_addr_table
+SEG_HACK=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-seg_hack
+SIZE=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-size
+STRINGS=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-strings
+STRIP=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-strip
+_PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_x86_64_apple_darwin13_4_0
INFO: activate_clangxx_osx-64.sh made the following environmental changes:
+CLANGXX=/Users/jespinoz/anaconda/envs/python3/bin/x86_64-apple-darwin13.4.0-clang++
+CXX=x86_64-apple-darwin13.4.0-clang++
+CXXFLAGS=-march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -std=c++14 -fmessage-length=0
+DEBUG_CXXFLAGS=-march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -std=c++14 -fmessage-length=0 -Og -g -Wall -Wextra

下面是请求的输出/脚本的pastebin链接:

正如Tarun Lalwani在评论中所建议的:

Stdout

output.o

斯泰尔

output.e

Trishansh Bhardwaj和Tarun Lalwani在评论中要求编写的脚本:

脚本

关联脚本

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-04-24 20:27:03

如果您查看下面的文件夹

代码语言:javascript
复制
/Users/jespinoz/anaconda/envs/python3/etc/conda

在同一个文件夹中有一个activate.ddeactivate.d文件夹,该文件夹在activatedeactivate期间执行。

这些文件有下面的代码部分

代码语言:javascript
复制
if [ $? -ne 0 ]; then
  echo "ERROR: $(_get_sourced_filename) failed, see above for details"
else
  if [ -f /tmp/new-env-$$.txt ]; then
    rm -f /tmp/new-env-$$.txt || true
  fi
  env > /tmp/new-env-$$.txt

  echo "INFO: $(_get_sourced_filename) made the following environmental changes:"
  diff -U 0 -rN /tmp/old-env-$$.txt /tmp/new-env-$$.txt | tail -n +4 | grep "^-.*\|^+.*" | grep -v "CONDA_BACKUP_" | sort
fi
rm -f /tmp/old-env-$$.txt /tmp/new-env-$$.txt || true

您需要对这些进行注释,以禁用详细的输出。这段代码基本上将当前的env保存到一个文件中,然后运行激活代码,再次捕获env并打印diff。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48995804

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档