mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) updates from grist-core
This commit is contained in:
@@ -740,12 +740,12 @@ class Response(object):
|
||||
"""
|
||||
Similar to the Response class from the `requests` library.
|
||||
"""
|
||||
def __init__(self, content, status, statusText, headers, encoding):
|
||||
def __init__(self, content, status, statusText, headers, encoding=None):
|
||||
self.content = content # raw bytes
|
||||
self.status_code = status # e.g. 404
|
||||
self.reason = statusText # e.g. "Not Found"
|
||||
self.headers = CaseInsensitiveDict(headers)
|
||||
self.encoding = encoding or self.apparent_encoding
|
||||
self.encoding = encoding or self.apparent_encoding or "utf-8"
|
||||
|
||||
@property
|
||||
def text(self):
|
||||
|
||||
@@ -73,6 +73,13 @@ class TestResponse(unittest.TestCase):
|
||||
self.assertEqual(r.content, content)
|
||||
self.assertEqual(r.text, text)
|
||||
|
||||
def test_unknown_undetectable_encoding(self):
|
||||
content = b''
|
||||
r = Response(content, 200, "OK", {}, encoding=None)
|
||||
|
||||
# Not knowing the encoding should not break text
|
||||
self.assertEqual(r.text, "")
|
||||
|
||||
|
||||
class TestRequestsPostInterface(unittest.TestCase):
|
||||
def test_no_post_args(self):
|
||||
|
||||
@@ -1,18 +1,26 @@
|
||||
# This number should be bumped up if making a non-additive change
|
||||
# to python packages.
|
||||
GRIST_PYODIDE_VERSION = 2
|
||||
|
||||
default:
|
||||
echo "Welcome to the pyodide sandbox"
|
||||
echo "make fetch_packages # gets python packages prepared earlier"
|
||||
echo "make build_packages # build python packages from scratch"
|
||||
echo "make save_packages # upload python packages to fetch later"
|
||||
echo "setup # get pyodide node package"
|
||||
echo "make clean_packages # remove local cache of python packages"
|
||||
echo "setup # get pyodide node package, and python packages"
|
||||
|
||||
fetch_packages:
|
||||
node ./packages.js https://s3.amazonaws.com/grist-pynbox/pyodide/packages/ _build/packages/
|
||||
node ./packages.js https://s3.amazonaws.com/grist-pynbox/pyodide/packages/v$(GRIST_PYODIDE_VERSION)/ _build/packages/
|
||||
|
||||
build_packages:
|
||||
./build_packages.sh
|
||||
|
||||
save_packages:
|
||||
aws s3 sync _build/packages s3://grist-pynbox/pyodide/packages/
|
||||
aws s3 sync _build/packages s3://grist-pynbox/pyodide/packages/v$(GRIST_PYODIDE_VERSION)
|
||||
|
||||
clean_packages:
|
||||
rm -rf _build/packages
|
||||
|
||||
setup:
|
||||
./setup.sh
|
||||
|
||||
8
sandbox/pyodide/build_packages.sh
Normal file → Executable file
8
sandbox/pyodide/build_packages.sh
Normal file → Executable file
@@ -17,14 +17,16 @@ echo "###############################################################"
|
||||
echo "## Prepare python packages"
|
||||
|
||||
cd _build/pyodide
|
||||
git checkout 0.23.4 || (git fetch && git checkout 0.23.4)
|
||||
./run_docker make
|
||||
cp ../../../requirements3.txt .
|
||||
./run_docker pyodide build -r requirements3.txt --output-lockfile result.txt
|
||||
cat result.txt
|
||||
./run_docker "source emsdk/emsdk/emsdk_env.sh && pyodide build -r requirements3.txt --outdir grist-packages"
|
||||
./run_docker pyodide py-compile grist-packages
|
||||
cd ../..
|
||||
|
||||
echo ""
|
||||
echo "###############################################################"
|
||||
echo "## Copy out python packages"
|
||||
|
||||
node ./packages.js _build/pyodide/dist/ _build/packages/
|
||||
rm -rf _build/packages/
|
||||
node ./packages.js _build/pyodide/grist-packages/ _build/packages/
|
||||
|
||||
21
sandbox/pyodide/package_filenames.json
Normal file
21
sandbox/pyodide/package_filenames.json
Normal file
@@ -0,0 +1,21 @@
|
||||
[
|
||||
"astroid-2.14.2-cp311-none-any.whl",
|
||||
"asttokens-2.2.1-cp311-none-any.whl",
|
||||
"chardet-4.0.0-cp311-none-any.whl",
|
||||
"et_xmlfile-1.0.1-cp311-none-any.whl",
|
||||
"executing-1.1.1-cp311-none-any.whl",
|
||||
"friendly_traceback-0.7.48-cp311-none-any.whl",
|
||||
"iso8601-0.1.12-cp311-none-any.whl",
|
||||
"lazy_object_proxy-1.6.0-cp311-cp311-emscripten_3_1_32_wasm32.whl",
|
||||
"openpyxl-3.0.10-cp311-none-any.whl",
|
||||
"phonenumberslite-8.12.57-cp311-none-any.whl",
|
||||
"pure_eval-0.2.2-cp311-none-any.whl",
|
||||
"python_dateutil-2.8.2-cp311-none-any.whl",
|
||||
"roman-3.3-cp311-none-any.whl",
|
||||
"six-1.16.0-cp311-none-any.whl",
|
||||
"sortedcontainers-2.4.0-cp311-none-any.whl",
|
||||
"stack_data-0.5.1-cp311-none-any.whl",
|
||||
"typing_extensions-4.4.0-cp311-none-any.whl",
|
||||
"unittest_xml_reporting-2.0.0-cp311-none-any.whl",
|
||||
"wrapt-1.15.0-cp311-none-any.whl"
|
||||
]
|
||||
@@ -61,6 +61,8 @@ async function findOnDisk(src, dest) {
|
||||
});
|
||||
}
|
||||
libs = await listLibs(dest);
|
||||
fs.writeFileSync(path.join(__dirname, `package_filenames.json`),
|
||||
JSON.stringify(libs.available.map(lib => lib.fileName), null, 2));
|
||||
console.log(`Cached`, {libs: libs.available.map(lib => lib.name)});
|
||||
console.log(`Missing`, {libs: libs.misses.map(lib => lib.name)});
|
||||
}
|
||||
|
||||
@@ -10,6 +10,6 @@ if [[ ! -e _build/worker ]]; then
|
||||
mkdir -p _build/worker
|
||||
cd _build/worker
|
||||
yarn init --yes
|
||||
yarn add pyodide@0.22.1
|
||||
yarn add pyodide@0.23.4
|
||||
cd ../..
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user