Skip to content

Instantly share code, notes, and snippets.

@deliciouslytyped
Created March 8, 2019 14:01
Show Gist options
  • Save deliciouslytyped/b0da88ed6d6b37bd5e07e02f6acd1f63 to your computer and use it in GitHub Desktop.
Save deliciouslytyped/b0da88ed6d6b37bd5e07e02f6acd1f63 to your computer and use it in GitHub Desktop.
these derivations will be built:
/nix/store/wzx5fmj8g68rkpl4lzipdzn8k0jvrxwz-python2.7-yara-python-3.9.0.drv
building '/nix/store/wzx5fmj8g68rkpl4lzipdzn8k0jvrxwz-python2.7-yara-python-3.9.0.drv'...
unpacking sources
unpacking source archive /nix/store/i214jpj5sdcxxasvbw3rrzrd356s5w0c-source
source root is source
/build/source /build
/build
setting SOURCE_DATE_EPOCH to timestamp 315619200 of file source/yara-python.c
patching sources
configuring
building
running build_ext
building 'yara' extension
creating build/temp.linux-x86_64-2.7
gcc -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DUSE_LINUX_PROC=1 -DHAVE_MEMMEM=1 -Iyara/libyara/include -Iyara/libyara/ -I. -I/nix/store/k8bai7yi9hycmvl7azqpavry07y7yq5q-source/libyara/include -I/nix/store/2smkcirh3snjk71ia9s3rmrkfzr1giia-python-2.7.15/include/python2.7 -c yara-python.c -o build/temp.linux-x86_64-2.7/yara-python.o
warning: no library file corresponding to '/nix/store/648y0f8xmibznz87r18kpv0ml81fnhd5-yara-3.7.1/lib/libyara.so.3' found (skipping)
warning: no library file corresponding to '/nix/store/648y0f8xmibznz87r18kpv0ml81fnhd5-yara-3.7.1/lib/libyara.so.3' found (skipping)
creating build/lib.linux-x86_64-2.7
gcc -pthread -shared -lgcc_s build/temp.linux-x86_64-2.7/yara-python.o -L/nix/store/648y0f8xmibznz87r18kpv0ml81fnhd5-yara-3.7.1/lib -L/nix/store/2smkcirh3snjk71ia9s3rmrkfzr1giia-python-2.7.15/lib -lyara -lpython2.7 -o build/lib.linux-x86_64-2.7/yara.so
running bdist_wheel
running build
installing to build/bdist.linux-x86_64/wheel
running install
running install_lib
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/wheel
copying build/lib.linux-x86_64-2.7/yara.so -> build/bdist.linux-x86_64/wheel
running install_egg_info
running egg_info
creating yara_python.egg-info
writing yara_python.egg-info/PKG-INFO
writing top-level names to yara_python.egg-info/top_level.txt
writing dependency_links to yara_python.egg-info/dependency_links.txt
writing manifest file 'yara_python.egg-info/SOURCES.txt'
reading manifest file 'yara_python.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'yara/libyara/modules/module_list'
warning: no files found matching '*.c' under directory 'yara'
warning: no files found matching '*.h' under directory 'yara'
writing manifest file 'yara_python.egg-info/SOURCES.txt'
Copying yara_python.egg-info to build/bdist.linux-x86_64/wheel/yara_python-3.9.0-py2.7.egg-info
running install_scripts
creating build/bdist.linux-x86_64/wheel/yara_python-3.9.0.dist-info/WHEEL
creating 'dist/yara_python-3.9.0-cp27-cp27mu-linux_x86_64.whl' and adding 'build/bdist.linux-x86_64/wheel' to it
adding 'yara.so'
adding 'yara_python-3.9.0.dist-info/LICENSE'
adding 'yara_python-3.9.0.dist-info/METADATA'
adding 'yara_python-3.9.0.dist-info/WHEEL'
adding 'yara_python-3.9.0.dist-info/top_level.txt'
adding 'yara_python-3.9.0.dist-info/RECORD'
removing build/bdist.linux-x86_64/wheel
installing
/build/source/dist /build/source
Processing ./yara_python-3.9.0-cp27-cp27mu-linux_x86_64.whl
Installing collected packages: yara-python
Successfully installed yara-python-3.9.0
/build/source
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/5cy818h34r39vvmxx9a6p9dvg8hn0rvr-python2.7-yara-python-3.9.0
shrinking /nix/store/5cy818h34r39vvmxx9a6p9dvg8hn0rvr-python2.7-yara-python-3.9.0/lib/python2.7/site-packages/yara.so
strip is /nix/store/5vyv136pqs75pj0b8vcpdyc03dmn9p0n-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/5cy818h34r39vvmxx9a6p9dvg8hn0rvr-python2.7-yara-python-3.9.0/lib
patching script interpreter paths in /nix/store/5cy818h34r39vvmxx9a6p9dvg8hn0rvr-python2.7-yara-python-3.9.0
checking for references to /build in /nix/store/5cy818h34r39vvmxx9a6p9dvg8hn0rvr-python2.7-yara-python-3.9.0...
running install tests
running test
running egg_info
writing yara_python.egg-info/PKG-INFO
writing top-level names to yara_python.egg-info/top_level.txt
writing dependency_links to yara_python.egg-info/dependency_links.txt
reading manifest file 'yara_python.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'yara/libyara/modules/module_list'
warning: no files found matching '*.c' under directory 'yara'
warning: no files found matching '*.h' under directory 'yara'
writing manifest file 'yara_python.egg-info/SOURCES.txt'
running build_ext
building 'yara' extension
gcc -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DUSE_LINUX_PROC=1 -DHAVE_MEMMEM=1 -Iyara/libyara/include -Iyara/libyara/ -I. -I/nix/store/2smkcirh3snjk71ia9s3rmrkfzr1giia-python-2.7.15/include/python2.7 -c yara-python.c -o build/temp.linux-x86_64-2.7/yara-python.o
gcc -pthread -shared -lgcc_s build/temp.linux-x86_64-2.7/yara-python.o -L/nix/store/2smkcirh3snjk71ia9s3rmrkfzr1giia-python-2.7.15/lib -lpython2.7 -o /build/source/yara.so
Traceback (most recent call last):
File "nix_run_setup", line 8, in <module>
exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\\r\\n', '\\n'), __file__, 'exec'))
File "setup.py", line 329, in <module>
sources=['yara-python.c'])])
File "/nix/store/b2wb8vzqah0a0rcb9c2nx6g4wrrcb329-python2.7-bootstrapped-pip-18.1/lib/python2.7/site-packages/setuptools/__init__.py", line 140, in setup
return distutils.core.setup(**attrs)
File "/nix/store/2smkcirh3snjk71ia9s3rmrkfzr1giia-python-2.7.15/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/nix/store/2smkcirh3snjk71ia9s3rmrkfzr1giia-python-2.7.15/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/nix/store/2smkcirh3snjk71ia9s3rmrkfzr1giia-python-2.7.15/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/nix/store/b2wb8vzqah0a0rcb9c2nx6g4wrrcb329-python2.7-bootstrapped-pip-18.1/lib/python2.7/site-packages/setuptools/command/test.py", line 228, in run
self.run_tests()
File "/nix/store/b2wb8vzqah0a0rcb9c2nx6g4wrrcb329-python2.7-bootstrapped-pip-18.1/lib/python2.7/site-packages/setuptools/command/test.py", line 250, in run_tests
exit=False,
File "/nix/store/2smkcirh3snjk71ia9s3rmrkfzr1giia-python-2.7.15/lib/python2.7/unittest/main.py", line 94, in __init__
self.parseArgs(argv)
File "/nix/store/2smkcirh3snjk71ia9s3rmrkfzr1giia-python-2.7.15/lib/python2.7/unittest/main.py", line 149, in parseArgs
self.createTests()
File "/nix/store/2smkcirh3snjk71ia9s3rmrkfzr1giia-python-2.7.15/lib/python2.7/unittest/main.py", line 158, in createTests
self.module)
File "/nix/store/2smkcirh3snjk71ia9s3rmrkfzr1giia-python-2.7.15/lib/python2.7/unittest/loader.py", line 130, in loadTestsFromNames
suites = [self.loadTestsFromName(name, module) for name in names]
File "/nix/store/2smkcirh3snjk71ia9s3rmrkfzr1giia-python-2.7.15/lib/python2.7/unittest/loader.py", line 91, in loadTestsFromName
module = __import__('.'.join(parts_copy))
File "/build/source/tests.py", line 22, in <module>
import yara
ImportError: /build/source/yara.so: undefined symbol: yr_finalize
builder for '/nix/store/wzx5fmj8g68rkpl4lzipdzn8k0jvrxwz-python2.7-yara-python-3.9.0.drv' failed with exit code 1
error: build of '/nix/store/wzx5fmj8g68rkpl4lzipdzn8k0jvrxwz-python2.7-yara-python-3.9.0.drv' failed
#TODO why does build_ext get run twice??
#TODO these are the modules the setuppy refers to, but what do they have to do with our build process? https://yara.readthedocs.io/en/latest/modules.html
{self, super, lib, buildPythonPackage, yara}:
let
fetchGitJSON = file: fetchFromGitHub {inherit (lib.importJSON file) owner repo rev sha256;}; #nix-prefetch-github
in
buildPythonPackage {
pname = "yara-python";
version = "3.9.0";
#TODO clean up includes upstream somehow?
src = fetchGitJSON ./yara-python.json;#Do not fetch submodule, do not build yara, do not collect 200$
postUnpack = ''
pushd source #TODO is there a var for this
rmdir yara
popd
'';
#TODO unfuck
#use our own yara instead of submodule
propagatedBuildInputs = [ yara ];
setupPyBuildFlags = [
"--dynamic-linking"
"--include-dirs='${yara.src}/libyara/include'"
"--library-dirs='${yara}/lib'"
"--libraries='${yara}/lib/libyara.so.3'"
];
postBuild = ''
# patchelf --add-needed '${yara}/lib/libyara.so.3' yara.so
'';
#doCheck = false; #TOD The check phsae is fucked for some reason; it runs build_ext again and with the wrong arguments so yara isnt linked properly to the python yara so
meta = with lib; {
homepage = "https://github.com/VirusTotal/yara-python";
license = licenses.asl20;
description = "Python interface for YARA";
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment