我有一个使用ruby-filemagic
的rails 4应用,因此需要在系统上安装filemagic
。
我尝试通过模仿this question的解决方案在Heroku上安装它,但它无法正常工作。我尝试了很多东西,但我认为最有希望的是通过apt-get
安装,这要归功于(修改过的)apt-get,config和ruby的组合buildpacks。
在配置中,我使用BUNDLE_BUILD__RUBY-FILEMAGIC: --with-magic-dir=/app/.apt/usr/ --with-magic-include=/app/.apt/usr/include --with-magic-lib=/app/.apt/usr/lib
最终,我仍然得到了这个:
/tmp/build_29e629f8a00379850ab44096c10f1afc/vendor/ruby-2.0.0/bin/ruby extconf.rb --with-magic-dir=/tmp/build_29e629f8a00379850ab44096c10f1afc/.apt/usr/ --with-magic-include=/tmp/build_29e629f8a00379850ab44096c10f1afc/.apt/usr/include --with-magic-lib=/tmp/build_29e629f8a`00379850ab44096c10f1afc/.apt/usr/lib
checking for main() in -lgnurx... no
checking for magic_open() in -lmagic... no
*** ERROR: missing required library to compile this module
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
libmagic
已安装到此目录中。它的内容相当于deb
包的内容,虽然看起来很轻。
答案 0 :(得分:1)
我能够做到这一点:
.buildpacks:
https://github.com/ddollar/heroku-buildpack-apt#master
https://github.com/heroku/heroku-buildpack-ruby.git#master
Aptfile:
libmagic-dev
没有必要使用heroku-bundle-config。
答案 1 :(得分:1)
您需要在主buildpack
之前添加heroku buildpacks:add --index 1 https://github.com/NetsoftHoldings/heroku-buildpack-magic.git
buildpack
def find_stddevs(img):
k = np.asmatrix([[-1.0/9, -1.0/9 ,-1.0/9],
[-1.0/9, 8.0/9 , -1.0/9],
[-1.0/9, -1.0/9 ,-1.0/9]])
filtered = convolve(img,k,mode='reflect')
median_a = np.median(filtered)
stddev = np.median(np.absolute(filtered - median_a))/0.67449 #Gaussian noise assumption
return stddev