Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python38Packages.telethon: Patch find_library call for libssl #97349

Open
wants to merge 2 commits into
base: master
from

Conversation

@udf
Copy link

@udf udf commented Sep 7, 2020

https://github.com/LonamiWebs/Telethon/blob/8330635a725717390e1981848737b8988a419fe1/telethon/crypto/libssl.py#L19

Motivation for this change

Telethon can use libssl to speed up encryption, this is especially useful when sending files.
See https://docs.telethon.dev/en/latest/developing/philosophy.html:

If libssl is available on your system, the library will make use of it to speed up some critical parts such as encrypting and decrypting the messages. Files will notably be sent and downloaded faster.

The ctypes.util.find_library call fails on NixOS because the environmental variables that get checked (by ldconfig, gcc, etc) are obviously missing so we patch it with a direct path to libssl.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Telethon can use libssl to speed up encryption. The `find_library` call fails on NixOS because the environmental variables that get checked are obviously missing so we patch it with a direct path to libssl.

https://github.com/LonamiWebs/Telethon/blob/8330635a725717390e1981848737b8988a419fe1/telethon/crypto/libssl.py#L19
@udf udf requested review from FRidh and jonringer as code owners Sep 7, 2020
@ofborg ofborg bot added the 6.topic: python label Sep 7, 2020
Copy link
Contributor

@jonringer jonringer left a comment

please add openssl to the inputs. And think in python-packages.nix please do:

  telethon = callPackages ..... {
     inherit (pkgs) openssl;
  };

to avoid importing the "openssl" python package

while evaluating 'callPackageWith' at /home/jon/.cache/nixpkgs-review/pr-97349/nixpkgs/lib/customisation.nix:117:35, called from /home/jon/.cache/nixpkgs-review/pr-97349/nixpkgs/pkgs/top-level/python-packages.nix:6800:14:
while evaluating 'makeOverridable' at /home/jon/.cache/nixpkgs-review/pr-97349/nixpkgs/lib/customisation.nix:67:24, called from /home/jon/.cache/nixpkgs-review/pr-97349/nixpkgs/lib/customisation.nix:121:8:
undefined variable 'openssl' at /home/jon/.cache/nixpkgs-review/pr-97349/nixpkgs/pkgs/development/python-modules/telethon/default.nix:15:45
@jonringer jonringer mentioned this pull request Sep 7, 2020
3 of 10 tasks complete
@udf
Copy link
Author

@udf udf commented Sep 7, 2020

Okay, it should work now.

Tested with:

[nix-shell:~/github/nixpkgs]$ python
Python 3.8.5 (default, Jul 20 2020, 13:26:22) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import telethon
>>> telethon.crypto.libssl._find_ssl_lib()
<CDLL '/nix/store/ljh2y54hgm198ng3y0wk857rcf5l9dfi-openssl-1.1.1g/lib/libssl.so', handle 1182710 at 0x7fca057a21f0>
>>> 
@udf udf requested a review from jonringer Sep 7, 2020
@ofborg ofborg bot requested a review from nyanloutre Sep 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.