committed by
Norman Feske
parent
a564b342c4
commit
2e3f012eca
3
include/python3/osreldate.h
Normal file
3
include/python3/osreldate.h
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
/*
|
||||||
|
* Note: This is just a dummy, since Python thinks we're running on FreeBSD.
|
||||||
|
*/
|
||||||
1122
include/python3/pyconfig.h
Normal file
1122
include/python3/pyconfig.h
Normal file
File diff suppressed because it is too large
Load Diff
21
include/python3/spec/x86_32/genode_defs.h
Normal file
21
include/python3/spec/x86_32/genode_defs.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* \brief Data type size definitions (32 Bit)
|
||||||
|
* \author Sebastian Sumpf
|
||||||
|
* \date 2010-02-17
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2010-2017 Genode Labs GmbH
|
||||||
|
*
|
||||||
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
|
* under the terms of the GNU Affero General Public License version 3.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _PYTHON__GENODE_DEFS_H_
|
||||||
|
#define _PYTHON__GENODE_DEFS_H_
|
||||||
|
|
||||||
|
#define GENODE_SIZEOF_LONG 4
|
||||||
|
#define GENODE_SIZEOF_INT 4
|
||||||
|
#define GENODE_SIZEOF_WCHAR 4
|
||||||
|
|
||||||
|
#endif /* _PYTHON__GENODE_DEFS_H_ */
|
||||||
21
include/python3/spec/x86_64/genode_defs.h
Normal file
21
include/python3/spec/x86_64/genode_defs.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* \brief Data type size definitions (32 Bit)
|
||||||
|
* \author Sebastian Sumpf
|
||||||
|
* \date 2010-02-17
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2010-2017 Genode Labs GmbH
|
||||||
|
*
|
||||||
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
|
* under the terms of the GNU Affero General Public License version 3.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _PYTHON__GENODE_DEFS_H_
|
||||||
|
#define _PYTHON__GENODE_DEFS_H_
|
||||||
|
|
||||||
|
#define GENODE_SIZEOF_LONG 8
|
||||||
|
#define GENODE_SIZEOF_INT 4
|
||||||
|
#define GENODE_SIZEOF_WCHAR 4
|
||||||
|
|
||||||
|
#endif /* _PYTHON__GENODE_DEFS_H_ */
|
||||||
14
lib/import/import-python3.mk
Normal file
14
lib/import/import-python3.mk
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
PYTHON = python-3.6.5
|
||||||
|
REP_INC_DIR += include/python3
|
||||||
|
INC_DIR += $(call select_from_ports,python3)/include
|
||||||
|
|
||||||
|
ifeq ($(filter-out $(SPECS),x86),)
|
||||||
|
ifeq ($(filter-out $(SPECS),32bit),)
|
||||||
|
REP_INC_DIR += include/python3/spec/x86_32
|
||||||
|
endif # 32bit
|
||||||
|
|
||||||
|
ifeq ($(filter-out $(SPECS),64bit),)
|
||||||
|
REP_INC_DIR += include/python3/spec/x86_64
|
||||||
|
endif # 64bit
|
||||||
|
endif # x86
|
||||||
|
|
||||||
217
lib/mk/python3.inc
Normal file
217
lib/mk/python3.inc
Normal file
@@ -0,0 +1,217 @@
|
|||||||
|
PYTHON_PORT_DIR := $(call select_from_ports,python3)
|
||||||
|
PYTHON_DIR := $(PYTHON_PORT_DIR)/src/lib/python3
|
||||||
|
LIBS += libc libm
|
||||||
|
SHARED_LIB = yes
|
||||||
|
|
||||||
|
# use our custom 'pyconfig.h' file
|
||||||
|
INC_DIR += $(REP_DIR)/include/python3
|
||||||
|
|
||||||
|
# Python headres
|
||||||
|
INC_DIR += $(PYTHON_DIR)/Include
|
||||||
|
|
||||||
|
# zlib headers
|
||||||
|
INC_DIR += $(PYTHON_DIR)/Modules/zlib
|
||||||
|
|
||||||
|
# expat headers
|
||||||
|
INC_DIR += $(PYTHON_DIR)/Modules/expat
|
||||||
|
|
||||||
|
D_OPTS = Py_BUILD_CORE NDBEUG PREFIX='""' VPATH='"."' EXEC_PREFIX='"lib"' PYTHONPATH='""' HAVE_EXPAT_CONFIG_H='""' VERSION='"3"'
|
||||||
|
F_OPTS = no-strict-aliasing wrapv
|
||||||
|
D_OPTS := $(addprefix -D,$(D_OPTS))
|
||||||
|
F_OPTS := $(addprefix -f,$(F_OPTS))
|
||||||
|
CC_DEF += $(F_OPTS) $(D_OPTS)
|
||||||
|
|
||||||
|
# python.c
|
||||||
|
#
|
||||||
|
SRC_C = \
|
||||||
|
dynload_shlib.c \
|
||||||
|
getbuildinfo.c \
|
||||||
|
acceler.c \
|
||||||
|
grammar1.c \
|
||||||
|
listnode.c \
|
||||||
|
node.c \
|
||||||
|
parser.c \
|
||||||
|
parsetok.c \
|
||||||
|
bitset.c \
|
||||||
|
metagrammar.c \
|
||||||
|
firstsets.c \
|
||||||
|
grammar.c \
|
||||||
|
pgen.c \
|
||||||
|
myreadline.c \
|
||||||
|
tokenizer.c \
|
||||||
|
abstract.c \
|
||||||
|
boolobject.c \
|
||||||
|
bytes_methods.c \
|
||||||
|
bytearrayobject.c \
|
||||||
|
bytesobject.c \
|
||||||
|
capsule.c \
|
||||||
|
cellobject.c \
|
||||||
|
classobject.c \
|
||||||
|
codeobject.c \
|
||||||
|
complexobject.c \
|
||||||
|
descrobject.c \
|
||||||
|
enumobject.c \
|
||||||
|
exceptions.c \
|
||||||
|
genobject.c \
|
||||||
|
fileobject.c \
|
||||||
|
floatobject.c \
|
||||||
|
frameobject.c \
|
||||||
|
funcobject.c \
|
||||||
|
iterobject.c \
|
||||||
|
listobject.c \
|
||||||
|
longobject.c \
|
||||||
|
dictobject.c \
|
||||||
|
methodobject.c \
|
||||||
|
moduleobject.c \
|
||||||
|
object.c \
|
||||||
|
obmalloc.c \
|
||||||
|
rangeobject.c \
|
||||||
|
setobject.c \
|
||||||
|
sliceobject.c \
|
||||||
|
structseq.c \
|
||||||
|
tupleobject.c \
|
||||||
|
typeobject.c \
|
||||||
|
weakrefobject.c \
|
||||||
|
unicodeobject.c \
|
||||||
|
unicodectype.c \
|
||||||
|
_warnings.c \
|
||||||
|
Python-ast.c \
|
||||||
|
asdl.c \
|
||||||
|
ast.c \
|
||||||
|
bltinmodule.c \
|
||||||
|
ceval.c \
|
||||||
|
compile.c \
|
||||||
|
codecs.c \
|
||||||
|
errors.c \
|
||||||
|
faulthandler.c \
|
||||||
|
fileutils.c \
|
||||||
|
frozen.c \
|
||||||
|
frozenmain.c \
|
||||||
|
future.c \
|
||||||
|
getargs.c \
|
||||||
|
getcompiler.c \
|
||||||
|
getcopyright.c \
|
||||||
|
getplatform.c \
|
||||||
|
getversion.c \
|
||||||
|
graminit.c \
|
||||||
|
hashtable.c \
|
||||||
|
import.c \
|
||||||
|
importdl.c \
|
||||||
|
marshal.c \
|
||||||
|
_math.c \
|
||||||
|
memoryobject.c \
|
||||||
|
modsupport.c \
|
||||||
|
mystrtoul.c \
|
||||||
|
mysnprintf.c \
|
||||||
|
namespaceobject.c \
|
||||||
|
odictobject.c \
|
||||||
|
peephole.c \
|
||||||
|
pyarena.c \
|
||||||
|
pyctype.c \
|
||||||
|
pyfpe.c \
|
||||||
|
pyhash.c \
|
||||||
|
pylifecycle.c \
|
||||||
|
pymath.c \
|
||||||
|
pystate.c \
|
||||||
|
pystrhex.c \
|
||||||
|
pytime.c \
|
||||||
|
pythonrun.c \
|
||||||
|
random.c \
|
||||||
|
structmember.c \
|
||||||
|
symtable.c \
|
||||||
|
sysmodule.c \
|
||||||
|
traceback.c \
|
||||||
|
_tracemalloc.c \
|
||||||
|
getopt.c \
|
||||||
|
pystrcmp.c \
|
||||||
|
pystrtod.c \
|
||||||
|
formatter_unicode.c \
|
||||||
|
config.c \
|
||||||
|
getpath.c \
|
||||||
|
main.c \
|
||||||
|
gcmodule.c \
|
||||||
|
signalmodule.c \
|
||||||
|
posixmodule.c \
|
||||||
|
errnomodule.c \
|
||||||
|
pwdmodule.c \
|
||||||
|
md5module.c \
|
||||||
|
sha1module.c \
|
||||||
|
sha256module.c \
|
||||||
|
sha512module.c \
|
||||||
|
_blake2/blake2module.c \
|
||||||
|
_blake2/blake2b_impl.c \
|
||||||
|
_blake2/blake2s_impl.c \
|
||||||
|
_sha3/sha3module.c \
|
||||||
|
_sre.c \
|
||||||
|
_codecsmodule.c \
|
||||||
|
timemodule.c \
|
||||||
|
_operator.c \
|
||||||
|
_randommodule.c \
|
||||||
|
itertoolsmodule.c \
|
||||||
|
_functoolsmodule.c \
|
||||||
|
_collectionsmodule.c \
|
||||||
|
_weakref.c \
|
||||||
|
_io/iobase.c \
|
||||||
|
_io/fileio.c \
|
||||||
|
_io/bufferedio.c \
|
||||||
|
_io/stringio.c \
|
||||||
|
_io/textio.c \
|
||||||
|
_io/bytesio.c \
|
||||||
|
_io/winconsoleio.c \
|
||||||
|
_io/_iomodule.c \
|
||||||
|
_localemodule.c \
|
||||||
|
atexitmodule.c \
|
||||||
|
pyexpat.c \
|
||||||
|
expat/xmlparse.c \
|
||||||
|
expat/xmlrole.c \
|
||||||
|
expat/xmltok.c \
|
||||||
|
_struct.c \
|
||||||
|
accu.c \
|
||||||
|
zipimport.c \
|
||||||
|
zlibmodule.c \
|
||||||
|
zlib/adler32.c \
|
||||||
|
zlib/compress.c \
|
||||||
|
zlib/crc32.c \
|
||||||
|
zlib/deflate.c \
|
||||||
|
zlib/gzlib.c \
|
||||||
|
zlib/gzread.c \
|
||||||
|
zlib/gzwrite.c \
|
||||||
|
zlib/infback.c \
|
||||||
|
zlib/inffast.c \
|
||||||
|
zlib/inflate.c \
|
||||||
|
zlib/inftrees.c \
|
||||||
|
zlib/trees.c \
|
||||||
|
zlib/uncompr.c \
|
||||||
|
zlib/zutil.c \
|
||||||
|
mathmodule.c \
|
||||||
|
symtablemodule.c \
|
||||||
|
xxsubtype.c
|
||||||
|
|
||||||
|
CC_C_OPT = -Wno-implicit-function-declaration \
|
||||||
|
-Wno-int-to-pointer-cast \
|
||||||
|
-Wno-unused-but-set-variable \
|
||||||
|
-Wno-unused-function \
|
||||||
|
-Wno-unused-variable
|
||||||
|
|
||||||
|
vpath %.c $(PYTHON_DIR)/Modules
|
||||||
|
vpath %.c $(PYTHON_DIR)/Objects
|
||||||
|
vpath %.c $(PYTHON_DIR)/Parser
|
||||||
|
vpath %.c $(PYTHON_DIR)/Python
|
||||||
|
vpath %.c $(REP_DIR)/src/lib/python3
|
||||||
|
vpath %.cc $(REP_DIR)/src/lib/python3
|
||||||
|
|
||||||
|
|
||||||
|
PYTHON3_ZIP = $(BUILD_BASE_DIR)/bin/python3.zip
|
||||||
|
|
||||||
|
$(PYTHON3_ZIP):
|
||||||
|
$(MSG_MERGE)$(notdir $@)
|
||||||
|
$(VERBOSE)cd $(PYTHON_DIR)/Lib; zip -rq $(PYTHON3_ZIP) *
|
||||||
|
|
||||||
|
#
|
||||||
|
# Generate python3.zip at the build stage, not the dependency stage, of the
|
||||||
|
# build system.
|
||||||
|
#
|
||||||
|
ifeq ($(called_from_lib_mk),yes)
|
||||||
|
python3.lib.tag: $(PYTHON3_ZIP)
|
||||||
|
endif
|
||||||
|
|
||||||
3
lib/mk/spec/x86_64/python3.mk
Normal file
3
lib/mk/spec/x86_64/python3.mk
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
include $(REP_DIR)/lib/mk/python3.inc
|
||||||
|
|
||||||
|
INC_DIR += $(REP_DIR)/include/python3/spec/x86_64
|
||||||
1
ports/python3.hash
Normal file
1
ports/python3.hash
Normal file
@@ -0,0 +1 @@
|
|||||||
|
0e64c351246be6e49e5d866ed2e19fa546badbd0
|
||||||
14
ports/python3.port
Normal file
14
ports/python3.port
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
LICENSE := Python
|
||||||
|
VERSION := 3.6.5
|
||||||
|
DOWNLOADS := python3.archive
|
||||||
|
|
||||||
|
URL(python3) := https://www.python.org/ftp/python/$(VERSION)/Python-$(VERSION).tar.xz
|
||||||
|
SHA(python3) := f434053ba1b5c8a5cc597e966ead3c5143012af827fd3f0697d21450bb8d87a6
|
||||||
|
SIG(python3) := ${URL(python)}.asc
|
||||||
|
PYTHON_KEY := 12EF3DC38047DA382D18A5B999CDEA9DA4135B38
|
||||||
|
DIR(python3) := src/lib/python3
|
||||||
|
|
||||||
|
PATCHES := src/lib/python3/posixmodule.patch src/lib/python3/dup.patch src/lib/python3/expat.patch
|
||||||
|
|
||||||
|
DIRS := include/python3
|
||||||
|
DIR_CONTENT(include/python3) := src/lib/python3/Include/*.h
|
||||||
130
run/python3.run
Normal file
130
run/python3.run
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
#
|
||||||
|
# \brief Test for running python
|
||||||
|
# \author Norman Feske
|
||||||
|
# \author Johannes Schlatow
|
||||||
|
# \date 2011-11-22
|
||||||
|
#
|
||||||
|
|
||||||
|
if {![have_spec x86]} {
|
||||||
|
puts "Run script is only supported on x86"; exit 0 }
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Build
|
||||||
|
#
|
||||||
|
|
||||||
|
build {
|
||||||
|
core init
|
||||||
|
app/python3
|
||||||
|
lib/vfs/jitterentropy
|
||||||
|
drivers/timer
|
||||||
|
drivers/rtc
|
||||||
|
}
|
||||||
|
|
||||||
|
create_boot_directory
|
||||||
|
|
||||||
|
#
|
||||||
|
# Generate config
|
||||||
|
#
|
||||||
|
|
||||||
|
set config {
|
||||||
|
<config verbose="yes">
|
||||||
|
<parent-provides>
|
||||||
|
<service name="ROM"/>
|
||||||
|
<service name="PD"/>
|
||||||
|
<service name="RM"/>
|
||||||
|
<service name="CPU"/>
|
||||||
|
<service name="LOG"/>
|
||||||
|
</parent-provides>
|
||||||
|
<default-route>
|
||||||
|
<any-service> <parent/> <any-child/> </any-service>
|
||||||
|
</default-route>
|
||||||
|
<default caps="100"/>
|
||||||
|
<start name="timer">
|
||||||
|
<resource name="RAM" quantum="1M"/>
|
||||||
|
<provides><service name="Timer" /></provides>
|
||||||
|
</start>
|
||||||
|
<start name="rtc_drv">
|
||||||
|
<resource name="RAM" quantum="1M"/>
|
||||||
|
<provides> <service name="Rtc"/> </provides>
|
||||||
|
</start>
|
||||||
|
<start name="python3">
|
||||||
|
<resource name="RAM" quantum="16M"/>
|
||||||
|
<config>
|
||||||
|
<pythonpath name="lib/python3.zip" />
|
||||||
|
<file name="hello.py" />
|
||||||
|
<vfs>
|
||||||
|
<dir name="dev">
|
||||||
|
<log/>
|
||||||
|
<jitterentropy name="urandom" />
|
||||||
|
<jitterentropy name="random" />
|
||||||
|
<rtc/>
|
||||||
|
<zero/>
|
||||||
|
</dir>
|
||||||
|
<dir name="lib">
|
||||||
|
<rom name="python3.zip" />
|
||||||
|
</dir>
|
||||||
|
<inline name="hello.py">
|
||||||
|
print(" \r\n\r");
|
||||||
|
print(" -============================-");
|
||||||
|
print(" || ||");
|
||||||
|
print(" || Python Core 3 ||");
|
||||||
|
print(" || ||");
|
||||||
|
print(" || Genode 17.11 ||");
|
||||||
|
print(" || ||");
|
||||||
|
print(" -============================-");
|
||||||
|
print(" \r");
|
||||||
|
print(" 2018 by Genode Labs www.genode-labs.com");
|
||||||
|
print(" \r\n\r");
|
||||||
|
</inline>
|
||||||
|
</vfs>
|
||||||
|
<libc stdin="/dev/zero" stdout="/dev/log" stderr="/dev/log" rtc="/dev/rtc"/>
|
||||||
|
</config>
|
||||||
|
</start>
|
||||||
|
</config>
|
||||||
|
}
|
||||||
|
|
||||||
|
install_config $config
|
||||||
|
|
||||||
|
#
|
||||||
|
# Boot modules
|
||||||
|
#
|
||||||
|
|
||||||
|
# generic modules
|
||||||
|
set boot_modules {
|
||||||
|
core init
|
||||||
|
ld.lib.so libc.lib.so libm.lib.so python3.lib.so posix.lib.so
|
||||||
|
python3
|
||||||
|
vfs_jitterentropy.lib.so
|
||||||
|
timer
|
||||||
|
rtc_drv
|
||||||
|
python3.zip
|
||||||
|
vfs.lib.so
|
||||||
|
}
|
||||||
|
|
||||||
|
build_boot_image $boot_modules
|
||||||
|
|
||||||
|
#
|
||||||
|
# Execute test case
|
||||||
|
#
|
||||||
|
|
||||||
|
append qemu_args " -nographic "
|
||||||
|
|
||||||
|
run_genode_until {.*Executed .*} 60
|
||||||
|
|
||||||
|
grep_output {python3\] }
|
||||||
|
compare_output_to {
|
||||||
|
[init -> python3]
|
||||||
|
[init -> python3] -============================-
|
||||||
|
[init -> python3] || ||
|
||||||
|
[init -> python3] || Python Core 3 ||
|
||||||
|
[init -> python3] || ||
|
||||||
|
[init -> python3] || Genode 17.11 ||
|
||||||
|
[init -> python3] || ||
|
||||||
|
[init -> python3] -============================-
|
||||||
|
[init -> python3]
|
||||||
|
[init -> python3] 2018 by Genode Labs www.genode-labs.com
|
||||||
|
[init -> python3]
|
||||||
|
}
|
||||||
|
|
||||||
|
# vi: set ft=tcl :
|
||||||
97
src/app/python3/main.cc
Normal file
97
src/app/python3/main.cc
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
/*
|
||||||
|
* \brief Running python script on Genode
|
||||||
|
* \author Johannes Schlatow
|
||||||
|
* \date 2010-02-17
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2018 Genode Labs GmbH
|
||||||
|
*
|
||||||
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
|
* under the terms of the GNU Affero General Public License version 3.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Python includes */
|
||||||
|
#include <python3/Python.h>
|
||||||
|
|
||||||
|
/* Genode includes */
|
||||||
|
#include <base/attached_rom_dataspace.h>
|
||||||
|
#include <base/env.h>
|
||||||
|
#include <libc/component.h>
|
||||||
|
#include <base/log.h>
|
||||||
|
|
||||||
|
/* libc includes */
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
namespace Python
|
||||||
|
{
|
||||||
|
struct Main;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Python::Main
|
||||||
|
{
|
||||||
|
Genode::Env &_env;
|
||||||
|
|
||||||
|
Genode::Attached_rom_dataspace _config = { _env, "config" };
|
||||||
|
|
||||||
|
void _handle_config()
|
||||||
|
{
|
||||||
|
enum {
|
||||||
|
MAX_NAME_LEN = 128
|
||||||
|
};
|
||||||
|
|
||||||
|
char filename[MAX_NAME_LEN];
|
||||||
|
|
||||||
|
if (_config.xml().has_sub_node("file")) {
|
||||||
|
Genode::Xml_node script = _config.xml().sub_node("file");
|
||||||
|
|
||||||
|
script.attribute("name").value(filename, sizeof(filename));
|
||||||
|
} else {
|
||||||
|
Genode::error("Need <file name=\"filename\"> as argument!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
wchar_t wbuf[MAX_NAME_LEN];
|
||||||
|
|
||||||
|
if (_config.xml().has_sub_node("pythonpath")) {
|
||||||
|
char pythonpath[MAX_NAME_LEN];
|
||||||
|
Genode::Xml_node path = _config.xml().sub_node("pythonpath");
|
||||||
|
|
||||||
|
path.attribute("name").value(pythonpath, sizeof(pythonpath));
|
||||||
|
mbstowcs(wbuf, pythonpath, strlen(pythonpath));
|
||||||
|
|
||||||
|
Py_SetPath(wbuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
mbstowcs(wbuf, filename, strlen(filename));
|
||||||
|
|
||||||
|
FILE * fp = fopen(filename, "r");
|
||||||
|
//fp._flags = __SRD;
|
||||||
|
Py_SetProgramName(wbuf);
|
||||||
|
//don't need the 'site' module
|
||||||
|
Py_NoSiteFlag = 1;
|
||||||
|
//don't support interactive mode, yet
|
||||||
|
Py_InteractiveFlag = 0;
|
||||||
|
Py_Initialize();
|
||||||
|
|
||||||
|
Genode::log("Starting python ...");
|
||||||
|
PyRun_SimpleFile(fp, filename);
|
||||||
|
Genode::log("Executed '", Genode::Cstring(filename), "'");
|
||||||
|
Py_Finalize();
|
||||||
|
}
|
||||||
|
|
||||||
|
Genode::Signal_handler<Main> _config_handler {
|
||||||
|
_env.ep(), *this, &Main::_handle_config };
|
||||||
|
|
||||||
|
Main(Genode::Env &env) : _env(env)
|
||||||
|
{
|
||||||
|
_config.sigh(_config_handler);
|
||||||
|
_handle_config();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void Libc::Component::construct(Libc::Env &env)
|
||||||
|
{
|
||||||
|
Libc::with_libc([&] () { static Python::Main main(env); });
|
||||||
|
}
|
||||||
4
src/app/python3/target.mk
Normal file
4
src/app/python3/target.mk
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
TARGET = python3
|
||||||
|
LIBS = python3 libc
|
||||||
|
REQUIRES = x86
|
||||||
|
SRC_CC = main.cc
|
||||||
129
src/lib/python3/config.c
Normal file
129
src/lib/python3/config.c
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
/* Generated automatically from ./Modules/config.c.in by makesetup. */
|
||||||
|
/* -*- C -*- ***********************************************
|
||||||
|
Copyright (c) 2000, BeOpen.com.
|
||||||
|
Copyright (c) 1995-2000, Corporation for National Research Initiatives.
|
||||||
|
Copyright (c) 1990-1995, Stichting Mathematisch Centrum.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
See the file "Misc/COPYRIGHT" for information on usage and
|
||||||
|
redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
|
******************************************************************/
|
||||||
|
|
||||||
|
/* Module configuration */
|
||||||
|
|
||||||
|
/* !!! !!! !!! This file is edited by the makesetup script !!! !!! !!! */
|
||||||
|
|
||||||
|
/* This file contains the table of built-in modules.
|
||||||
|
See create_builtin() in import.c. */
|
||||||
|
|
||||||
|
#include "Python.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
extern PyObject* PyInit__signal(void);
|
||||||
|
extern PyObject* PyInit__struct(void);
|
||||||
|
extern PyObject* PyInit_atexit(void);
|
||||||
|
extern PyObject* PyInit_posix(void);
|
||||||
|
extern PyObject* PyInit_errno(void);
|
||||||
|
extern PyObject* PyInit_pwd(void);
|
||||||
|
extern PyObject* PyInit__sre(void);
|
||||||
|
extern PyObject* PyInit__codecs(void);
|
||||||
|
extern PyObject* PyInit_zipimport(void);
|
||||||
|
extern PyObject* PyInit__symtable(void);
|
||||||
|
extern PyObject* PyInit_xxsubtype(void);
|
||||||
|
extern PyObject* PyInit_math(void);
|
||||||
|
extern PyObject* PyInit_time(void);
|
||||||
|
extern PyObject* PyInit__operator(void);
|
||||||
|
extern PyObject* PyInit_zlib(void);
|
||||||
|
extern PyObject* PyInit__random(void);
|
||||||
|
extern PyObject* PyInit_itertools(void);
|
||||||
|
extern PyObject* PyInit__functools(void);
|
||||||
|
extern PyObject* PyInit__collections(void);
|
||||||
|
extern PyObject* PyInit__weakref(void);
|
||||||
|
extern PyObject* PyInit__locale(void);
|
||||||
|
extern PyObject* PyInit__io(void);
|
||||||
|
extern PyObject* PyInit__md5(void);
|
||||||
|
extern PyObject* PyInit__sha1(void);
|
||||||
|
extern PyObject* PyInit__sha256(void);
|
||||||
|
extern PyObject* PyInit__sha512(void);
|
||||||
|
extern PyObject* PyInit__blake2(void);
|
||||||
|
extern PyObject* PyInit__sha3(void);
|
||||||
|
extern PyObject* PyInit_pyexpat(void);
|
||||||
|
|
||||||
|
/* -- ADDMODULE MARKER 1 -- */
|
||||||
|
|
||||||
|
extern PyObject* PyMarshal_Init(void);
|
||||||
|
extern PyObject* PyInit_imp(void);
|
||||||
|
extern PyObject* PyInit_gc(void);
|
||||||
|
extern PyObject* PyInit__ast(void);
|
||||||
|
extern PyObject* _PyWarnings_Init(void);
|
||||||
|
extern PyObject* PyInit__string(void);
|
||||||
|
|
||||||
|
struct _inittab _PyImport_Inittab[] = {
|
||||||
|
|
||||||
|
{"_signal", PyInit__signal},
|
||||||
|
{"_struct", PyInit__struct},
|
||||||
|
{"atexit", PyInit_atexit},
|
||||||
|
{"posix", PyInit_posix},
|
||||||
|
{"errno", PyInit_errno},
|
||||||
|
{"pwd", PyInit_pwd},
|
||||||
|
{"_sre", PyInit__sre},
|
||||||
|
{"_codecs", PyInit__codecs},
|
||||||
|
{"_weakref", PyInit__weakref},
|
||||||
|
{"_operator", PyInit__operator},
|
||||||
|
{"math", PyInit_math},
|
||||||
|
{"time", PyInit_time},
|
||||||
|
{"itertools", PyInit_itertools},
|
||||||
|
{"_functools", PyInit__functools},
|
||||||
|
{"_collections", PyInit__collections},
|
||||||
|
{"_locale", PyInit__locale},
|
||||||
|
{"_io", PyInit__io},
|
||||||
|
{"zipimport", PyInit_zipimport},
|
||||||
|
{"_symtable", PyInit__symtable},
|
||||||
|
{"xxsubtype", PyInit_xxsubtype},
|
||||||
|
{"_random", PyInit__random},
|
||||||
|
{"zlib", PyInit_zlib},
|
||||||
|
{"_md5", PyInit__md5},
|
||||||
|
{"_sha1", PyInit__sha1},
|
||||||
|
{"_sha256", PyInit__sha256},
|
||||||
|
{"_sha512", PyInit__sha512},
|
||||||
|
{"_blake2", PyInit__blake2},
|
||||||
|
{"_sha3", PyInit__sha3},
|
||||||
|
{"pyexpat", PyInit_pyexpat},
|
||||||
|
|
||||||
|
/* -- ADDMODULE MARKER 2 -- */
|
||||||
|
|
||||||
|
/* This module lives in marshal.c */
|
||||||
|
{"marshal", PyMarshal_Init},
|
||||||
|
|
||||||
|
/* This lives in import.c */
|
||||||
|
{"imp", PyInit_imp},
|
||||||
|
|
||||||
|
/* This lives in Python/Python-ast.c */
|
||||||
|
{"_ast", PyInit__ast},
|
||||||
|
|
||||||
|
/* These entries are here for sys.builtin_module_names */
|
||||||
|
{"builtins", NULL},
|
||||||
|
{"sys", NULL},
|
||||||
|
|
||||||
|
/* This lives in gcmodule.c */
|
||||||
|
{"gc", PyInit_gc},
|
||||||
|
|
||||||
|
/* This lives in _warnings.c */
|
||||||
|
{"_warnings", _PyWarnings_Init},
|
||||||
|
|
||||||
|
/* This lives in Objects/unicodeobject.c */
|
||||||
|
{"_string", PyInit__string},
|
||||||
|
|
||||||
|
/* Sentinel */
|
||||||
|
{0, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
27
src/lib/python3/dup.patch
Normal file
27
src/lib/python3/dup.patch
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
+++ src/lib/python3/Python/pylifecycle.c 2018-05-11 15:20:34.421070206 +0200
|
||||||
|
@@ -1051,15 +1051,7 @@
|
||||||
|
int fd2;
|
||||||
|
if (fd < 0)
|
||||||
|
return 0;
|
||||||
|
- _Py_BEGIN_SUPPRESS_IPH
|
||||||
|
- /* Prefer dup() over fstat(). fstat() can require input/output whereas
|
||||||
|
- dup() doesn't, there is a low risk of EMFILE/ENFILE at Python
|
||||||
|
- startup. */
|
||||||
|
- fd2 = dup(fd);
|
||||||
|
- if (fd2 >= 0)
|
||||||
|
- close(fd2);
|
||||||
|
- _Py_END_SUPPRESS_IPH
|
||||||
|
- return fd2 >= 0;
|
||||||
|
+ return fd >= 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
+++ src/lib/python3/Python/fileutils.c 2018-05-11 15:15:46.841809875 +0200
|
||||||
|
@@ -1543,6 +1543,7 @@
|
||||||
|
int
|
||||||
|
_Py_dup(int fd)
|
||||||
|
{
|
||||||
|
+ return fd;
|
||||||
|
#ifdef MS_WINDOWS
|
||||||
|
HANDLE handle;
|
||||||
|
DWORD ftype;
|
||||||
8
src/lib/python3/expat.patch
Normal file
8
src/lib/python3/expat.patch
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
+++ src/lib/python3/Modules/expat/expat_config.h 2018-05-29 14:26:26.737762285 +0200
|
||||||
|
@@ -16,4 +16,6 @@
|
||||||
|
#define XML_DTD 1
|
||||||
|
#define XML_CONTEXT_BYTES 1024
|
||||||
|
|
||||||
|
+#undef PREFIX
|
||||||
|
+
|
||||||
|
#endif /* EXPAT_CONFIG_H */
|
||||||
20
src/lib/python3/posixmodule.patch
Normal file
20
src/lib/python3/posixmodule.patch
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
+++ src/lib/python3/Modules/posixmodule.c
|
||||||
|
@@ -178,15 +178,15 @@
|
||||||
|
#define fsync _commit
|
||||||
|
#else
|
||||||
|
/* Unix functions that the configure script doesn't check for */
|
||||||
|
-#define HAVE_EXECV 1
|
||||||
|
+//#define HAVE_EXECV 1
|
||||||
|
#define HAVE_FORK 1
|
||||||
|
#if defined(__USLC__) && defined(__SCO_VERSION__) /* SCO UDK Compiler */
|
||||||
|
#define HAVE_FORK1 1
|
||||||
|
#endif
|
||||||
|
-#define HAVE_GETEGID 1
|
||||||
|
+//#define HAVE_GETEGID 1
|
||||||
|
#define HAVE_GETEUID 1
|
||||||
|
#define HAVE_GETGID 1
|
||||||
|
-#define HAVE_GETPPID 1
|
||||||
|
+//#define HAVE_GETPPID 1
|
||||||
|
#define HAVE_GETUID 1
|
||||||
|
#define HAVE_KILL 1
|
||||||
|
#define HAVE_OPENDIR 1
|
||||||
Reference in New Issue
Block a user