Closed aytekinar closed 1 year ago
Note that if I change the Dockerfile
's pyinstaller
- and staticx
-related RUN
statements to read as follows:
RUN python3 -m pipenv run pyinstaller --add-binary /usr/lib64/libcrypt.so.1:. \
--add-binary /lib64/libutil.so.1:. \
--add-binary /lib64/libm.so.6:. \
--clean --name app --onefile main.py
RUN python3 -m pipenv run staticx --strip dist/app dist/app-static
the binary works:
$ docker run --rm -it delete-me --help
usage: vectorops [-h] [--debug] [--operation {add,subtract,multiply,divide,dot}] --var-1 VAR_1 [VAR_1 ...] --var-2 VAR_2 [VAR_2 ...]
optional arguments:
-h, --help show this help message and exit
--debug, -d
--operation {add,subtract,multiply,divide,dot}, -o {add,subtract,multiply,divide,dot}
--var-1 VAR_1 [VAR_1 ...], -x VAR_1 [VAR_1 ...]
--var-2 VAR_2 [VAR_2 ...], -y VAR_2 [VAR_2 ...]
$ docker run --rm -it delete-me -d -x 1 2 3 -y 4 5 6
2021-09-13T15:29:37UTC - __main__ - DEBUG - vectorops runing with options: Namespace(debug=True, operation='add', var_1=[1.0, 2.0, 3.0], var_2=[4.0, 5.0, 6.0])
2021-09-13T15:29:37UTC - __main__ - INFO - np.add([1.0, 2.0, 3.0], [4.0, 5.0, 6.0]) = [5. 7. 9.]
In this case, do you think the problem is related to staticx
or pyinstaller
?
Hi @aytekinar, a couple things:
opensuse/leap
?libcrypt.so
isn't loadingreadelf -d libwhatever.so | grep RUNPATH
on the execuable/librariesRUNPATH
is indeed the problem -- see https://github.com/pyinstaller/pyinstaller/issues/6217#issuecomment-932850750ld.so
:
LD_DEBUG_OUTPUT=myprog_ld_debug LD_DEBUG=all ./myprog
(replacing myprog
as appropriate) -- this will generate a file named myprog_ld_debug.$PID
Hi, please try the recently-released v0.13.0.
@aytekinar Can you please try with the latest version of Staticx v0.13.5?
Closing after receiving no feedback.
Hi,
I have the following
Dockerfile
Dockerfile details
```dockerfile ARG BASE_IMAGE ARG BASE_VERSION FROM ${BASE_IMAGE}:${BASE_VERSION} AS develop RUN set -ex; \ zypper addrepo https://download.opensuse.org/repositories/openSUSE:Backports:SLE-15-SP3/standard/openSUSE:Backports:SLE-15-SP3.repo; \ zypper --gpg-auto-import-keys refresh; \ zypper install --auto-agree-with-licenses --no-confirm upx; \ zypper removerepo 4; \ zypper clean --all FROM ${BASE_IMAGE}:${BASE_VERSION} AS builder COPY --from=develop /usr/bin/upx /usr/bin/ COPY main.py Pipfile Pipfile.lock /tmp/app/ WORKDIR /tmp/app/ RUN python3 -m pipenv sync --dev RUN find /usr/local -name __pycache__ -exec mkdir -pv {} + RUN python3 -m pipenv run pyinstaller --clean --name app --onefile main.py RUN python3 -m pipenv run staticx --debug --strip dist/app dist/app-static FROM scratch AS final COPY --from=builder /tmp/app/dist/app-static /app WORKDIR /tmp ENTRYPOINT [ "/app" ] ```with
BASE_IMAGE
pointing to a SUSE Linux Enterprise Server (SLES) image, andBASE_VERSION
pointing to a corresponding version (e.g.,SLE15.3
), neither of which I can share due to licensing problems. Moreover, I have the following versions of the important libraries installed:Library versions
```bash $ patchelf --version patchelf 0.12.20200827.8d3a16e $ upx --version upx 3.96 UCL data compression library 1.03 zlib data compression library 1.2.11 LZMA SDK version 4.43 Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2020 Laszlo Molnar Copyright (C) 2000-2020 John F. Reiser Copyright (C) 2002-2020 Jens Medoch Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler Copyright (C) 1999-2006 Igor Pavlov UPX comes with ABSOLUTELY NO WARRANTY; for details type 'upx -L'. $ pyinstaller --version 4.5.1 $ staticx --version staticx 0.12.3 ```When I try to create a static image from the following
main.py
filemain.py details
```python import argparse import logging import numpy as np if __name__ == "__main__": logger = logging.getLogger(__name__) handler = logging.StreamHandler() formatter = logging.Formatter( fmt="%(asctime)s - %(name)s - %(levelname)s - %(message)s", datefmt="%Y-%m-%dT%H:%M:%S%Z") handler.setFormatter(formatter) logger.addHandler(handler) arg_parser = argparse.ArgumentParser(prog="vectorops") arg_parser.add_argument("--debug", "-d", action="store_const", dest="debug", default=False, const=True) arg_parser.add_argument("--operation", "-o", type=str, default="add", choices=["add", "subtract", "multiply", "divide", "dot"]) arg_parser.add_argument("--var-1", "-x", type=float, nargs="+", required=True) arg_parser.add_argument("--var-2", "-y", type=float, nargs="+", required=True) options = arg_parser.parse_args() if options.debug: logger.setLevel(logging.DEBUG) else: logger.setLevel(logging.INFO) logger.debug("vectorops runing with options: %s", options) logger.info("np.%s(%s, %s) = %s", options.operation, options.var_1, options.var_2, getattr(np, options.operation)(options.var_1, options.var_2) ) ```in a virtual environment (cf. the following
Pipfile
andPipfile.lock
files at the end), I get the following error:Even though
libcrypt.so.1
seems to be properly copied and linked,dlopen
is having a hard time finding the library.I would appreciate it if you helped me solve the issue.
Pipfile
```toml [[source]] url = "https://pypi.org/simple" verify_ssl = true name = "pypi" [packages] numpy = "~=1.21.0" [dev-packages] autopep8 = "*" build = "*" mypy = "*" pyinstaller = "*" pylint = "*" staticx = "*" [requires] python_version = "3.9" ```Pipfile.lock
```json { "_meta": { "hash": { "sha256": "fda85bfe2d2b6591de1771408b6e09e8a7b46b5e3d6b7a27d4c0e62274083e57" }, "pipfile-spec": 6, "requires": { "python_version": "3.9" }, "sources": [ { "name": "pypi", "url": "https://pypi.org/simple", "verify_ssl": true } ] }, "default": { "numpy": { "hashes": [ "sha256:09858463db6dd9f78b2a1a05c93f3b33d4f65975771e90d2cf7aadb7c2f66edf", "sha256:209666ce9d4a817e8a4597cd475b71b4878a85fa4b8db41d79fdb4fdee01dde2", "sha256:298156f4d3d46815eaf0fcf0a03f9625fc7631692bd1ad851517ab93c3168fc6", "sha256:30fc68307c0155d2a75ad19844224be0f2c6f06572d958db4e2053f816b859ad", "sha256:423216d8afc5923b15df86037c6053bf030d15cc9e3224206ef868c2d63dd6dc", "sha256:426a00b68b0d21f2deb2ace3c6d677e611ad5a612d2c76494e24a562a930c254", "sha256:466e682264b14982012887e90346d33435c984b7fead7b85e634903795c8fdb0", "sha256:51a7b9db0a2941434cd930dacaafe0fc9da8f3d6157f9d12f761bbde93f46218", "sha256:52a664323273c08f3b473548bf87c8145b7513afd63e4ebba8496ecd3853df13", "sha256:550564024dc5ceee9421a86fc0fb378aa9d222d4d0f858f6669eff7410c89bef", "sha256:5de64950137f3a50b76ce93556db392e8f1f954c2d8207f78a92d1f79aa9f737", "sha256:640c1ccfd56724f2955c237b6ccce2e5b8607c3bc1cc51d3933b8c48d1da3723", "sha256:7fdc7689daf3b845934d67cb221ba8d250fdca20ac0334fea32f7091b93f00d3", "sha256:805459ad8baaf815883d0d6f86e45b3b0b67d823a8f3fa39b1ed9c45eaf5edf1", "sha256:92a0ab128b07799dd5b9077a9af075a63467d03ebac6f8a93e6440abfea4120d", "sha256:9f2dc79c093f6c5113718d3d90c283f11463d77daa4e83aeeac088ec6a0bda52", "sha256:a5109345f5ce7ddb3840f5970de71c34a0ff7fceb133c9441283bb8250f532a3", "sha256:a55e4d81c4260386f71d22294795c87609164e22b28ba0d435850fbdf82fc0c5", "sha256:a9da45b748caad72ea4a4ed57e9cd382089f33c5ec330a804eb420a496fa760f", "sha256:b160b9a99ecc6559d9e6d461b95c8eec21461b332f80267ad2c10394b9503496", "sha256:b342064e647d099ca765f19672696ad50c953cac95b566af1492fd142283580f", "sha256:b5e8590b9245803c849e09bae070a8e1ff444f45e3f0bed558dd722119eea724", "sha256:bf75d5825ef47aa51d669b03ce635ecb84d69311e05eccea083f31c7570c9931", "sha256:c01b59b33c7c3ba90744f2c695be571a3bd40ab2ba7f3d169ffa6db3cfba614f", "sha256:d96a6a7d74af56feb11e9a443150216578ea07b7450f7c05df40eec90af7f4a7", "sha256:dd0e3651d210068d13e18503d75aaa45656eef51ef0b261f891788589db2cc38", "sha256:e167b9805de54367dcb2043519382be541117503ce99e3291cc9b41ca0a83557", "sha256:e42029e184008a5fd3d819323345e25e2337b0ac7f5c135b7623308530209d57", "sha256:f545c082eeb09ae678dd451a1b1dbf17babd8a0d7adea02897a76e639afca310", "sha256:fde50062d67d805bc96f1a9ecc0d37bfc2a8f02b937d2c50824d186aa91f2419" ], "index": "pypi", "version": "==1.21.2" } }, "develop": { "altgraph": { "hashes": [ "sha256:743628f2ac6a7c26f5d9223c91ed8ecbba535f506f4b6f558885a8a56a105857", "sha256:ebf2269361b47d97b3b88e696439f6e4cbc607c17c51feb1754f90fb79839158" ], "version": "==0.17.2" }, "astroid": { "hashes": [ "sha256:3b680ce0419b8a771aba6190139a3998d14b413852506d99aff8dc2bf65ee67c", "sha256:dc1e8b28427d6bbef6b8842b18765ab58f558c42bb80540bd7648c98412af25e" ], "markers": "python_version ~= '3.6'", "version": "==2.7.3" }, "autopep8": { "hashes": [ "sha256:276ced7e9e3cb22e5d7c14748384a5cf5d9002257c0ed50c0e075b68011bb6d0", "sha256:aa213493c30dcdac99537249ee65b24af0b2c29f2e83cd8b3f68760441ed0db9" ], "index": "pypi", "version": "==1.5.7" }, "build": { "hashes": [ "sha256:32290592c8ccf70ce84107962f6129407abf52cedaa752af28c0c95d99dfa2e7", "sha256:d8d8417caff47888274d677f984de509554637dd1ea952d467b027849b06d83b" ], "index": "pypi", "version": "==0.6.0.post1" }, "isort": { "hashes": [ "sha256:9c2ea1e62d871267b78307fe511c0838ba0da28698c5732d54e2790bf3ba9899", "sha256:e17d6e2b81095c9db0a03a8025a957f334d6ea30b26f9ec70805411e5c7c81f2" ], "markers": "python_version < '4.0' and python_full_version >= '3.6.1'", "version": "==5.9.3" }, "lazy-object-proxy": { "hashes": [ "sha256:17e0967ba374fc24141738c69736da90e94419338fd4c7c7bef01ee26b339653", "sha256:1fee665d2638491f4d6e55bd483e15ef21f6c8c2095f235fef72601021e64f61", "sha256:22ddd618cefe54305df49e4c069fa65715be4ad0e78e8d252a33debf00f6ede2", "sha256:24a5045889cc2729033b3e604d496c2b6f588c754f7a62027ad4437a7ecc4837", "sha256:410283732af311b51b837894fa2f24f2c0039aa7f220135192b38fcc42bd43d3", "sha256:4732c765372bd78a2d6b2150a6e99d00a78ec963375f236979c0626b97ed8e43", "sha256:489000d368377571c6f982fba6497f2aa13c6d1facc40660963da62f5c379726", "sha256:4f60460e9f1eb632584c9685bccea152f4ac2130e299784dbaf9fae9f49891b3", "sha256:5743a5ab42ae40caa8421b320ebf3a998f89c85cdc8376d6b2e00bd12bd1b587", "sha256:85fb7608121fd5621cc4377a8961d0b32ccf84a7285b4f1d21988b2eae2868e8", "sha256:9698110e36e2df951c7c36b6729e96429c9c32b3331989ef19976592c5f3c77a", "sha256:9d397bf41caad3f489e10774667310d73cb9c4258e9aed94b9ec734b34b495fd", "sha256:b579f8acbf2bdd9ea200b1d5dea36abd93cabf56cf626ab9c744a432e15c815f", "sha256:b865b01a2e7f96db0c5d12cfea590f98d8c5ba64ad222300d93ce6ff9138bcad", "sha256:bf34e368e8dd976423396555078def5cfc3039ebc6fc06d1ae2c5a65eebbcde4", "sha256:c6938967f8528b3668622a9ed3b31d145fab161a32f5891ea7b84f6b790be05b", "sha256:d1c2676e3d840852a2de7c7d5d76407c772927addff8d742b9808fe0afccebdf", "sha256:d7124f52f3bd259f510651450e18e0fd081ed82f3c08541dffc7b94b883aa981", "sha256:d900d949b707778696fdf01036f58c9876a0d8bfe116e8d220cfd4b15f14e741", "sha256:ebfd274dcd5133e0afae738e6d9da4323c3eb021b3e13052d8cbd0e457b1256e", "sha256:ed361bb83436f117f9917d282a456f9e5009ea12fd6de8742d1a4752c3017e93", "sha256:f5144c75445ae3ca2057faac03fda5a902eff196702b0a24daf1d6ce0650514b" ], "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'", "version": "==1.6.0" }, "mccabe": { "hashes": [ "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42", "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f" ], "version": "==0.6.1" }, "mypy": { "hashes": [ "sha256:088cd9c7904b4ad80bec811053272986611b84221835e079be5bcad029e79dd9", "sha256:0aadfb2d3935988ec3815952e44058a3100499f5be5b28c34ac9d79f002a4a9a", "sha256:119bed3832d961f3a880787bf621634ba042cb8dc850a7429f643508eeac97b9", "sha256:1a85e280d4d217150ce8cb1a6dddffd14e753a4e0c3cf90baabb32cefa41b59e", "sha256:3c4b8ca36877fc75339253721f69603a9c7fdb5d4d5a95a1a1b899d8b86a4de2", "sha256:3e382b29f8e0ccf19a2df2b29a167591245df90c0b5a2542249873b5c1d78212", "sha256:42c266ced41b65ed40a282c575705325fa7991af370036d3f134518336636f5b", "sha256:53fd2eb27a8ee2892614370896956af2ff61254c275aaee4c230ae771cadd885", "sha256:704098302473cb31a218f1775a873b376b30b4c18229421e9e9dc8916fd16150", "sha256:7df1ead20c81371ccd6091fa3e2878559b5c4d4caadaf1a484cf88d93ca06703", "sha256:866c41f28cee548475f146aa4d39a51cf3b6a84246969f3759cb3e9c742fc072", "sha256:a155d80ea6cee511a3694b108c4494a39f42de11ee4e61e72bc424c490e46457", "sha256:adaeee09bfde366d2c13fe6093a7df5df83c9a2ba98638c7d76b010694db760e", "sha256:b6fb13123aeef4a3abbcfd7e71773ff3ff1526a7d3dc538f3929a49b42be03f0", "sha256:b94e4b785e304a04ea0828759172a15add27088520dc7e49ceade7834275bedb", "sha256:c0df2d30ed496a08de5daed2a9ea807d07c21ae0ab23acf541ab88c24b26ab97", "sha256:c6c2602dffb74867498f86e6129fd52a2770c48b7cd3ece77ada4fa38f94eba8", "sha256:ceb6e0a6e27fb364fb3853389607cf7eb3a126ad335790fa1e14ed02fba50811", "sha256:d9dd839eb0dc1bbe866a288ba3c1afc33a202015d2ad83b31e875b5905a079b6", "sha256:e4dab234478e3bd3ce83bac4193b2ecd9cf94e720ddd95ce69840273bf44f6de", "sha256:ec4e0cd079db280b6bdabdc807047ff3e199f334050db5cbb91ba3e959a67504", "sha256:ecd2c3fe726758037234c93df7e98deb257fd15c24c9180dacf1ef829da5f921", "sha256:ef565033fa5a958e62796867b1df10c40263ea9ded87164d67572834e57a174d" ], "index": "pypi", "version": "==0.910" }, "mypy-extensions": { "hashes": [ "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d", "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8" ], "version": "==0.4.3" }, "packaging": { "hashes": [ "sha256:7dc96269f53a4ccec5c0670940a4281106dd0bb343f47b7471f779df49c2fbe7", "sha256:c86254f9220d55e31cc94d69bade760f0847da8000def4dfe1c6b872fd14ff14" ], "markers": "python_version >= '3.6'", "version": "==21.0" }, "pep517": { "hashes": [ "sha256:3fa6b85b9def7ba4de99fb7f96fe3f02e2d630df8aa2720a5cf3b183f087a738", "sha256:e1ba5dffa3a131387979a68ff3e391ac7d645be409216b961bc2efe6468ab0b2" ], "version": "==0.11.0" }, "platformdirs": { "hashes": [ "sha256:15b056538719b1c94bdaccb29e5f81879c7f7f0f4a153f46086d155dffcd4f0f", "sha256:8003ac87717ae2c7ee1ea5a84a1a61e87f3fbd16eb5aadba194ea30a9019f648" ], "markers": "python_version >= '3.6'", "version": "==2.3.0" }, "pycodestyle": { "hashes": [ "sha256:514f76d918fcc0b55c6680472f0a37970994e07bbb80725808c17089be302068", "sha256:c389c1d06bf7904078ca03399a4816f974a1d590090fecea0c63ec26ebaf1cef" ], "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==2.7.0" }, "pyelftools": { "hashes": [ "sha256:5609aa6da1123fccfae2e8431a67b4146aa7fad5b3889f808df12b110f230937", "sha256:cde854e662774c5457d688ca41615f6594187ba7067af101232df889a6b7a66b" ], "version": "==0.27" }, "pyinstaller": { "hashes": [ "sha256:30733baaf8971902286a0ddf77e5499ac5f7bf8e7c39163e83d4f8c696ef265e", "sha256:4d848cd782ee0893d7ad9fe2bfe535206a79f0b6760cecc5f2add831258b9322", "sha256:8f747b190e6ad30e2d2fd5da9a64636f61aac8c038c0b7f685efa92c782ea14f", "sha256:aae456205c68355f9597411090576bb31b614e53976b4c102d072bbe5db8392a", "sha256:c587da8f521a7ce1b9efb4e3d0117cd63c92dc6cedff24590aeef89372f53012", "sha256:ecc2baadeeefd2b6fbf39d13c65d4aa603afdda1c6aaaebc4577ba72893fee9e", "sha256:fed9f5e4802769a416a8f2ca171c6be961d1861cc05a0b71d20dfe05423137e9" ], "index": "pypi", "version": "==4.5.1" }, "pyinstaller-hooks-contrib": { "hashes": [ "sha256:169b09802a19f83593114821d6ba0416a05c7071ef0ca394f7bfb7e2c0c916c8", "sha256:a52bc3834281266bbf77239cfc9521923336ca622f44f90924546ed6c6d3ad5e" ], "version": "==2021.3" }, "pylint": { "hashes": [ "sha256:6758cce3ddbab60c52b57dcc07f0c5d779e5daf0cf50f6faacbef1d3ea62d2a1", "sha256:e178e96b6ba171f8ef51fbce9ca30931e6acbea4a155074d80cc081596c9e852" ], "index": "pypi", "version": "==2.10.2" }, "pyparsing": { "hashes": [ "sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1", "sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b" ], "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==2.4.7" }, "staticx": { "hashes": [ "sha256:5997e9e181f92699be77729b56e51c8c73562d835e753072edaf6bed3fb6eed1", "sha256:f12816c02d9f406a6ec228d18644f5d7f35ae6c8d56038c300143970e68a2845" ], "index": "pypi", "version": "==0.12.3" }, "toml": { "hashes": [ "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b", "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f" ], "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==0.10.2" }, "tomli": { "hashes": [ "sha256:8dd0e9524d6f386271a36b41dbf6c57d8e32fd96fd22b6584679dc569d20899f", "sha256:a5b75cb6f3968abb47af1b40c1819dc519ea82bcc065776a866e8d74c5ca9442" ], "markers": "python_version >= '3.6'", "version": "==1.2.1" }, "typing-extensions": { "hashes": [ "sha256:49f75d16ff11f1cd258e1b988ccff82a3ca5570217d7ad8c5f48205dd99a677e", "sha256:d8226d10bc02a29bcc81df19a26e56a9647f8b0a6d4a83924139f4a8b01f17b7", "sha256:f1d25edafde516b146ecd0613dabcc61409817af4766fbbcfb8d1ad4ec441a34" ], "version": "==3.10.0.2" }, "wrapt": { "hashes": [ "sha256:b62ffa81fb85f4332a4f609cab4ac40709470da05643a082ec1eb88e6d9b97d7" ], "version": "==1.12.1" } } } ```