Skip to content

Commit

Permalink
Merge branch 'feature/convertIntDoubleToLong' into mausbrand
Browse files Browse the repository at this point in the history
  • Loading branch information
phorward committed Sep 24, 2019
2 parents 910e6e8 + 486d19e commit 45816c0
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 16 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Unreleased

- The built-in `sqlite3** module of Python is now enabled.
- The built-in `sqlite` and `bz2` modules of Python are now enabled.

- New package: `nltk`

Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ LDFLAGS=\
-s USE_LIBPNG=1 \
-std=c++14 \
-L$(wildcard $(CPYTHONROOT)/build/sqlite*/.libs) -lsqlite3 \
$(wildcard $(CPYTHONROOT)/build/bzip2*/libbz2.a) \
-lstdc++ \
--memory-init-file 0 \
-s "BINARYEN_TRAP_MODE='clamp'" \
Expand Down
40 changes: 29 additions & 11 deletions cpython/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ SQLITETARBALL=$(ROOT)/downloads/sqlite-autoconf-3270200.tar.gz
SQLITEBUILD=$(ROOT)/build/sqlite-autoconf-3270200
SQLITEURL=https://www.sqlite.org/2019/sqlite-autoconf-3270200.tar.gz

BZIP2TARBALL=$(ROOT)/downloads/bzip2-1.0.2.tar.gz
BZIP2BUILD=$(ROOT)/build/bzip2-1.0.2
BZIP2URL=ftp://sources.redhat.com/pub/bzip2/v102/bzip2-1.0.2.tar.gz


all: $(INSTALL)/lib/$(LIB)

Expand Down Expand Up @@ -62,6 +66,11 @@ $(SQLITETARBALL):
wget -q -O $@ $(SQLITEURL)


$(BZIP2TARBALL):
[ -d $(ROOT)/downloads ] || mkdir $(ROOT)/downloads
wget -q -O $@ $(BZIP2URL)


$(HOSTPYTHON) $(HOSTPGEN): $(TARBALL)
mkdir -p $(HOSTINSTALL)
[ -d $(HOSTBUILD) ] || tar -C $(HOSTINSTALL) -xf $(TARBALL)
Expand Down Expand Up @@ -98,21 +107,30 @@ $(SQLITEBUILD)/libsqlite3.la: $(SQLITETARBALL)
)


$(BUILD)/Makefile: $(BUILD)/.patched $(ZLIBBUILD)/.patched $(SQLITEBUILD)/libsqlite3.la
$(BZIP2BUILD)/libbz2.a: $(BZIP2TARBALL)
[ -d $(ROOT)/build ] || (mkdir $(ROOT)/build)
tar -C $(ROOT)/build/ -xf $(BZIP2TARBALL)
( \
cd $(BZIP2BUILD); \
emmake make CC=emcc CFLAGS="-Wall -Winline -O2 -fomit-frame-pointer -D_FILE_OFFSET_BITS=64" AR=emar RANLIB=emranlib libbz2.a; \
)


$(BUILD)/Makefile: $(BUILD)/.patched $(ZLIBBUILD)/.patched $(SQLITEBUILD)/libsqlite3.la $(BZIP2BUILD)/libbz2.a
cp config.site $(BUILD)/
( \
cd $(BUILD); \
CONFIG_SITE=./config.site READELF=true LD_RUN_PATH=$(SQLITEBUILD) emconfigure \
CONFIG_SITE=./config.site READELF=true LD_RUN_PATH="$(SQLITEBUILD):$(BZIP2BUILD)" emconfigure \
./configure \
CPPFLAGS="-I$(SQLITEBUILD)" \
LDFLAGS="-L$(SQLITEBUILD)" \
--without-pymalloc \
--disable-shared \
--disable-ipv6 \
--without-gcc \
--host=asmjs-unknown-emscripten \
--build=$(shell $(BUILD)/config.guess) \
--prefix=$(INSTALL) ; \
CPPFLAGS="-I$(SQLITEBUILD) -I$(BZIP2BUILD)" \
LDFLAGS="-L$(SQLITEBUILD) -L$(BZIP2BUILD)" \
--without-pymalloc \
--disable-shared \
--disable-ipv6 \
--without-gcc \
--host=asmjs-unknown-emscripten \
--build=$(shell $(BUILD)/config.guess) \
--prefix=$(INSTALL) ; \
)


Expand Down
1 change: 1 addition & 0 deletions cpython/Setup.local
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ _blake2 _blake2/blake2module.c _blake2/blake2b_impl.c ../../host/Python-3.7.0/Mo

_sqlite3 _sqlite/cache.c _sqlite/connection.c _sqlite/cursor.c _sqlite/microprotocols.c _sqlite/module.c _sqlite/prepare_protocol.c _sqlite/row.c _sqlite/statement.c _sqlite/util.c -I$(SQLITEBUILD) -L$(SQLITEBUILD) -lsqlite3
_crypt _cryptmodule.c
_bz2 _bz2module.c -I$(BZIP2BUILD) -L$(BZIP2BUILD) -lbz2

_queue _queuemodule.c

Expand Down
2 changes: 1 addition & 1 deletion src/js2python.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ _js2python_number(double val)
double i;

if (modf(val, &i) == 0.0)
return (int)PyLong_FromLong(i);
return (int)PyLong_FromDouble(i);

return (int)PyFloat_FromDouble(val);
}
Expand Down
2 changes: 1 addition & 1 deletion test/python_tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ test_buffer
test_bufio
test_builtin floating point
test_bytes
test_bz2
test_bz2 threading
test_c_locale_coercion
test_calendar
test_call
Expand Down
10 changes: 10 additions & 0 deletions test/test_bz2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
def test_bz2(selenium):
selenium.run("""
import bz2
text = "Hello test test test test this is a test test test"
some_compressed_bytes = bz2.compress(text.encode('utf-8'))
assert some_compressed_bytes != text
decompressed_bytes = bz2.decompress(some_compressed_bytes)
assert decompressed_bytes.decode('utf-8') == text
""")
4 changes: 2 additions & 2 deletions test/test_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,10 @@ def test_js2python(selenium):
'jsstring_ucs4 == "🐍"')
assert selenium.run(
'from js import jsnumber0\n'
'jsnumber0 == 42')
'jsnumber0 == 42 and isinstance(jsnumber0, int)')
assert selenium.run(
'from js import jsnumber1\n'
'jsnumber1 == 42.5')
'jsnumber1 == 42.5 and isinstance(jsnumber1, float)')
assert selenium.run(
'from js import jsundefined\n'
'jsundefined is None')
Expand Down

0 comments on commit 45816c0

Please sign in to comment.