Skip to content

Commit af69d7f

Browse files
committed
Bundle Python module "requests"
1 parent b5b1ca5 commit af69d7f

3 files changed

Lines changed: 32 additions & 17 deletions

File tree

README.md

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,18 @@ spreadsheets - currently supporting Yahoo's (FX, crypto, equities, indices, futu
99
## Latest version vs Yahoo HTTPS fingerprinting
1010

1111
Latest version 3.8.0 was created to bypass Yahoo's recently adding crazy HTTPS fingerprinting
12-
to their website. In a step back to before or rather a return to times long gone some Python modules need
13-
to be installed such that LibreOffice can find them.
12+
to their website. In a step back to before or rather a return to times long gone some Python
13+
modules need to be installed such that LibreOffice can find them - otherwise Yahoo will not work.
1414

15-
Ideally install module 'curl_cffi' (although 'requests' works as well if you don't intend to use Yahoo as source)
16-
using e.g. on my Ubuntu:
15+
Update for version: 3.8.1 - this bundles the Python 'requests' module so users using 'FT' as source
16+
should not require anything else.
1717

18-
```sudo pip3 install curl_cffi --upgrade```
18+
Everyone else needs to install module 'curl_cffi' e.g. on my Ubuntu system:
1919

20-
Previously this worked on Windows - as LibreOffice on Windows ships with its own, minimal Python runtime a
21-
few more steps are required:
20+
- ```sudo pip3 install curl_cffi --upgrade```
2221

22+
For Windows something along those lines used to work for other dependencies
23+
2324
- Download the script https://bootstrap.pypa.io/get-pip.py to your computer
2425

2526
- Start a Command Prompt (CMD) as Administrator on the command prompt run (change path as required)
@@ -28,18 +29,20 @@ few more steps are required:
2829

2930
```"c:\Program Files\LibreOffice\program\python.exe" -m pip install curl_cffi --upgrade```
3031

31-
If you want to use Yahoo as a source you need to download latest binary of [curl-impersonate](https://github.com/lwthiker/curl-impersonate/releases) e.g.
32-
libcurl-impersonate-v0.6.1.x86_64-linux-gnu.tar.gz and untar it somewhere
32+
Then you need to download latest binary of [curl-impersonate](https://github.com/lwthiker/curl-impersonate/releases) e.g.
33+
(currently) libcurl-impersonate-v0.6.1.x86_64-linux-gnu.tar.gz and untar it somewhere
3334

3435
Now some of these bits need to be loaded/initialised before running LibreOffice: I used the below (adjust your location
35-
to libcurl-impersonate-chrome.so) to run LibreOffice Calc directly from command line:
36+
to libcurl-impersonate-chrome.so) to run LibreOffice Calc directly from command line - alternatively you could
37+
define LD_PRELOAD and CURL_IMPERSONATE in your environment e.g. by putting them in your .bashrc
3638

3739
```
3840
LD_PRELOAD=/tmp/curl-impersonate/libcurl-impersonate-chrome.so CURL_IMPERSONATE=chrome101 /usr/lib/libreoffice/program/soffice.bin --calc
3941
```
4042

4143
With this I can see the below in the output from `=GETREALTIME("SUPPORT")` and the examples.ods file from this repo
4244
can load data for Yahoo again.
45+
4346
```
4447
...
4548
requests=curl_cffi_0.10.0
@@ -51,14 +54,21 @@ curl_version="libcurl/8.1.1 BoringSSL zlib/1.2.11 brotli/1.0.9 nghttp2/1.56.0"
5154
Similar things should be possible on Windows - let me know if [this](https://stackoverflow.com/questions/1178257/ld-preload-equivalent-for-windows-to-preload-shared-libraries)
5255
is helpful and share your experience.
5356

57+
User report for Linux Mint: the command to install curl_cffi is:
58+
```
59+
sudo apt install python3-pip
60+
sudo pip3 install curl_cffi --upgrade --break-system-packages
61+
```
62+
and then adding the following to /etc/environment:
63+
```
64+
LD_PRELOAD=/home/rvkpbv/bin/libcurl-impersonate-chrome.so
65+
CURL_IMPERSONATE=chrome101
66+
```
67+
5468
Background: for a normal Python script just installing curl_cffi is enough to bypass Yahoo's HTTPS fingerprinting.
5569
Because LibreOffice is loading the stock curl library before executing the extension code directly, the above hack
5670
is required. Unless someone tells me otherwise...
5771

58-
### Feedback requested:
59-
60-
Please provide feedback about using the extension [here](https://github.com/cmallwitz/Financials-Extension/issues/10)
61-
6272
### Usage:
6373

6474
Under 'Releases' on GitHub [there](https://github.com/cmallwitz/Financials-Extension/releases) is a downloadable **Financials-Extension.oxt** file - load it into Calc

compile.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ cp -f "${PWD}"/src/financials_ft.py "${PWD}"/build/
5959
cp -f "${PWD}"/src/financials_yahoo.py "${PWD}"/build/
6060
cp -f "${PWD}"/src/financials_coinbase.py "${PWD}"/build/
6161

62-
# this copies python modules dateutil, pytz, pyparsing to extension so it doesn't have to be installed by user
62+
# this copies python some modules to extension so they doesn't have to be installed by user
6363

6464
TMPFILE=`mktemp`
6565

@@ -75,11 +75,16 @@ wget "https://files.pythonhosted.org/packages/8a/bb/488841f56197b13700afd5658fc2
7575
unzip $TMPFILE pyparsing.py -d "${PWD}"/build/
7676
rm $TMPFILE
7777

78-
# Windows LibreOffice 7.1 Python is missing this...
78+
# Windows LibreOffice Python is not including this by default...
7979
wget "https://files.pythonhosted.org/packages/b7/ce/149a00dd41f10bc29e5921b496af8b574d8413afcd5e30dfa0ed46c2cc5e/six-1.17.0-py2.py3-none-any.whl" -O $TMPFILE
8080
unzip $TMPFILE six.py -d "${PWD}"/build/
8181
rm $TMPFILE
8282

83+
# Windows LibreOffice Python is not including this by default...
84+
wget "https://files.pythonhosted.org/packages/f9/9b/335f9764261e915ed497fcdeb11df5dfd6f7bf257d4a6a2a686d80da4d54/requests-2.32.3-py3-none-any.whl" -O $TMPFILE
85+
unzip $TMPFILE requests/\* -d "${PWD}"/build/
86+
rm $TMPFILE
87+
8388
echo "Package into oxt file..."
8489
pushd "${PWD}"/build/
8590
zip -r "${PWD}"/Financials-Extension.zip ./*

src/generate_metainfo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
cur_dir = os.getcwd()
1515

1616
addin_id = "com.financials.getinfo"
17-
addin_version = "3.8.0"
17+
addin_version = "3.8.1"
1818
addin_displayname = "Financial Market Extension"
1919
addin_publisher_link = "https://github.com/cmallwitz/Financials-Extension"
2020
addin_publisher_name = "The Publisher"

0 commit comments

Comments
 (0)