Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pyodide
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
pyodide
Commits
72293058
Commit
72293058
authored
Sep 20, 2018
by
Roman Yurchak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Converting tools scripts to a python package
parent
9d15654f
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
62 additions
and
35 deletions
+62
-35
.gitignore
.gitignore
+1
-0
Makefile
Makefile
+2
-0
packages/Makefile
packages/Makefile
+1
-1
pyodide_build/__init__.py
pyodide_build/__init__.py
+1
-0
pyodide_build/buildall.py
pyodide_build/buildall.py
+7
-7
pyodide_build/buildpkg.py
pyodide_build/buildpkg.py
+9
-10
pyodide_build/common.py
pyodide_build/common.py
+4
-3
pyodide_build/pywasmcross.py
pyodide_build/pywasmcross.py
+21
-14
setup.py
setup.py
+16
-0
No files found.
.gitignore
View file @
72293058
...
@@ -22,3 +22,4 @@ ccache
...
@@ -22,3 +22,4 @@ ccache
/six/six-1.11.0
/six/six-1.11.0
/lz4/lz4-1.8.3
/lz4/lz4-1.8.3
*.egg-info/
Makefile
View file @
72293058
...
@@ -204,6 +204,8 @@ ccache/em++:
...
@@ -204,6 +204,8 @@ ccache/em++:
$(CPYTHONLIB)
:
emsdk/emsdk/.complete ccache/emcc ccache/em++
$(CPYTHONLIB)
:
emsdk/emsdk/.complete ccache/emcc ccache/em++
make
-C
$(CPYTHONROOT)
make
-C
$(CPYTHONROOT)
python
-m
pip
install
-e
.
"
$(HOSTPYTHONROOT)
/bin/python3"
-m
pip
install
-e
.
$(LZ4LIB)
:
$(LZ4LIB)
:
...
...
packages/Makefile
View file @
72293058
...
@@ -2,7 +2,7 @@ PYODIDE_ROOT=$(abspath ..)
...
@@ -2,7 +2,7 @@ PYODIDE_ROOT=$(abspath ..)
include
../Makefile.envs
include
../Makefile.envs
all
:
all
:
../tools/
buildall
.
../build
--ldflags
=
"
$(SIDE_LDFLAGS)
"
--host
=
$(HOSTPYTHONROOT)
--target
=
$(TARGETPYTHONROOT)
pyodide
buildall
.
../build
--ldflags
=
"
$(SIDE_LDFLAGS)
"
--host
=
$(HOSTPYTHONROOT)
--target
=
$(TARGETPYTHONROOT)
clean
:
clean
:
rm
-rf
./
*
/build
rm
-rf
./
*
/build
pyodide_build/__init__.py
0 → 100644
View file @
72293058
__version__
=
'0.1.0'
tools/buildall
→
pyodide_build/buildall.py
View file @
72293058
...
@@ -10,8 +10,8 @@ from pathlib import Path
...
@@ -10,8 +10,8 @@ from pathlib import Path
import
shutil
import
shutil
import
common
from
.
import
common
import
buildpkg
from
.
import
buildpkg
def
build_package
(
pkgname
,
dependencies
,
packagesdir
,
outputdir
,
args
):
def
build_package
(
pkgname
,
dependencies
,
packagesdir
,
outputdir
,
args
):
...
@@ -54,9 +54,8 @@ def build_packages(packagesdir, outputdir, args):
...
@@ -54,9 +54,8 @@ def build_packages(packagesdir, outputdir, args):
json
.
dump
({
'dependencies'
:
dependencies
},
fd
)
json
.
dump
({
'dependencies'
:
dependencies
},
fd
)
def
parse_args
():
def
make_parser
(
parser
):
parser
=
argparse
.
ArgumentParser
(
parser
.
description
=
"Build all of the packages in a given directory"
"Build all of the packages in a given directory"
)
parser
.
add_argument
(
parser
.
add_argument
(
'dir'
,
type
=
str
,
nargs
=
1
,
'dir'
,
type
=
str
,
nargs
=
1
,
help
=
'Input directory containing a tree of package definitions'
)
help
=
'Input directory containing a tree of package definitions'
)
...
@@ -75,7 +74,7 @@ def parse_args():
...
@@ -75,7 +74,7 @@ def parse_args():
parser
.
add_argument
(
parser
.
add_argument
(
'--target'
,
type
=
str
,
nargs
=
'?'
,
default
=
common
.
TARGETPYTHON
,
'--target'
,
type
=
str
,
nargs
=
'?'
,
default
=
common
.
TARGETPYTHON
,
help
=
'The path to the target Python installation'
)
help
=
'The path to the target Python installation'
)
return
parser
.
parse_args
()
return
parser
def
main
(
args
):
def
main
(
args
):
...
@@ -85,5 +84,6 @@ def main(args):
...
@@ -85,5 +84,6 @@ def main(args):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
args
=
parse_args
()
parser
=
make_parser
(
argparse
.
ArgumentParser
())
args
=
parser
.
parse_args
()
main
(
args
)
main
(
args
)
tools
/buildpkg.py
→
pyodide_build
/buildpkg.py
View file @
72293058
...
@@ -12,10 +12,7 @@ import shutil
...
@@ -12,10 +12,7 @@ import shutil
import
subprocess
import
subprocess
import
common
from
.
import
common
ROOTDIR
=
Path
(
__file__
).
parent
.
resolve
()
def
check_checksum
(
path
,
pkg
):
def
check_checksum
(
path
,
pkg
):
...
@@ -88,7 +85,8 @@ def compile(path, srcpath, pkg, args):
...
@@ -88,7 +85,8 @@ def compile(path, srcpath, pkg, args):
try
:
try
:
subprocess
.
run
([
subprocess
.
run
([
str
(
Path
(
args
.
host
)
/
'bin'
/
'python3'
),
str
(
Path
(
args
.
host
)
/
'bin'
/
'python3'
),
str
(
ROOTDIR
/
'pywasmcross'
),
'-m'
,
'pyodide_build'
,
'pywasmcross'
,
'--cflags'
,
'--cflags'
,
args
.
cflags
+
' '
+
args
.
cflags
+
' '
+
pkg
.
get
(
'build'
,
{}).
get
(
'cflags'
,
''
),
pkg
.
get
(
'build'
,
{}).
get
(
'cflags'
,
''
),
...
@@ -124,7 +122,7 @@ def package_files(buildpath, srcpath, pkg, args):
...
@@ -124,7 +122,7 @@ def package_files(buildpath, srcpath, pkg, args):
install_prefix
=
(
srcpath
/
'install'
).
resolve
()
install_prefix
=
(
srcpath
/
'install'
).
resolve
()
subprocess
.
run
([
subprocess
.
run
([
'python'
,
'python'
,
Path
(
ROOTDIR
)
/
'file_packager.py'
,
common
.
TOOLSDIR
/
'file_packager.py'
,
name
+
'.data'
,
name
+
'.data'
,
'--lz4'
,
'--lz4'
,
'--preload'
,
'--preload'
,
...
@@ -163,8 +161,8 @@ def build_package(path, args):
...
@@ -163,8 +161,8 @@ def build_package(path, args):
os
.
chdir
(
orig_path
)
os
.
chdir
(
orig_path
)
def
parse_args
(
):
def
make_parser
(
parser
):
parser
=
argparse
.
ArgumentParser
(
'Build a pyodide package.'
)
parser
.
description
=
'Build a pyodide package.'
parser
.
add_argument
(
parser
.
add_argument
(
'package'
,
type
=
str
,
nargs
=
1
,
'package'
,
type
=
str
,
nargs
=
1
,
help
=
"Path to meta.yaml package description"
)
help
=
"Path to meta.yaml package description"
)
...
@@ -180,7 +178,7 @@ def parse_args():
...
@@ -180,7 +178,7 @@ def parse_args():
parser
.
add_argument
(
parser
.
add_argument
(
'--target'
,
type
=
str
,
nargs
=
'?'
,
default
=
common
.
TARGETPYTHON
,
'--target'
,
type
=
str
,
nargs
=
'?'
,
default
=
common
.
TARGETPYTHON
,
help
=
'The path to the target Python installation'
)
help
=
'The path to the target Python installation'
)
return
parser
.
parse_args
()
return
parser
def
main
(
args
):
def
main
(
args
):
...
@@ -189,5 +187,6 @@ def main(args):
...
@@ -189,5 +187,6 @@ def main(args):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
args
=
parse_args
()
parser
=
make_parser
(
argparse
.
ArgumentParser
())
args
=
parser
.
parse_args
()
main
(
args
)
main
(
args
)
tools
/common.py
→
pyodide_build
/common.py
View file @
72293058
from
pathlib
import
Path
from
pathlib
import
Path
ROOTDIR
=
Path
(
__file__
).
parent
.
resolve
()
ROOTDIR
=
Path
(
__file__
).
parents
[
1
].
resolve
()
HOSTPYTHON
=
ROOTDIR
/
'..'
/
'cpython'
/
'build'
/
'3.7.0'
/
'host'
TOOLSDIR
=
ROOTDIR
/
'tools'
TARGETPYTHON
=
ROOTDIR
/
'..'
/
'cpython'
/
'installs'
/
'python-3.7.0'
HOSTPYTHON
=
ROOTDIR
/
'cpython'
/
'build'
/
'3.7.0'
/
'host'
TARGETPYTHON
=
ROOTDIR
/
'cpython'
/
'installs'
/
'python-3.7.0'
DEFAULTCFLAGS
=
''
DEFAULTCFLAGS
=
''
DEFAULTLDFLAGS
=
' '
.
join
([
DEFAULTLDFLAGS
=
' '
.
join
([
'-O3'
,
'-O3'
,
...
...
tools/pywasmcross
→
pyodide_build/pywasmcross.py
View file @
72293058
...
@@ -34,10 +34,12 @@ import subprocess
...
@@ -34,10 +34,12 @@ import subprocess
import
sys
import
sys
import
common
# absolute import is necessary as this file will be symlinked
# under tools
from
pyodide_build
import
common
ROOTDIR
=
Path
(
__file__
).
parent
.
resolve
()
TOOLSDIR
=
common
.
TOOLSDIR
symlinks
=
set
([
'cc'
,
'c++'
,
'ld'
,
'ar'
,
'gcc'
])
symlinks
=
set
([
'cc'
,
'c++'
,
'ld'
,
'ar'
,
'gcc'
])
...
@@ -53,8 +55,8 @@ def collect_args(basename):
...
@@ -53,8 +55,8 @@ def collect_args(basename):
# native compiler
# native compiler
env
=
dict
(
os
.
environ
)
env
=
dict
(
os
.
environ
)
path
=
env
[
'PATH'
]
path
=
env
[
'PATH'
]
while
str
(
ROOT
DIR
)
+
':'
in
path
:
while
str
(
TOOLS
DIR
)
+
':'
in
path
:
path
=
path
.
replace
(
str
(
ROOT
DIR
)
+
':'
,
''
)
path
=
path
.
replace
(
str
(
TOOLS
DIR
)
+
':'
,
''
)
env
[
'PATH'
]
=
path
env
[
'PATH'
]
=
path
with
open
(
'build.log'
,
'a'
)
as
fd
:
with
open
(
'build.log'
,
'a'
)
as
fd
:
...
@@ -74,7 +76,7 @@ def make_symlinks(env):
...
@@ -74,7 +76,7 @@ def make_symlinks(env):
"""
"""
exec_path
=
Path
(
__file__
).
resolve
()
exec_path
=
Path
(
__file__
).
resolve
()
for
symlink
in
symlinks
:
for
symlink
in
symlinks
:
symlink_path
=
ROOT
DIR
/
symlink
symlink_path
=
TOOLS
DIR
/
symlink
if
not
symlink_path
.
exists
():
if
not
symlink_path
.
exists
():
symlink_path
.
symlink_to
(
exec_path
)
symlink_path
.
symlink_to
(
exec_path
)
if
symlink
==
'c++'
:
if
symlink
==
'c++'
:
...
@@ -87,7 +89,7 @@ def make_symlinks(env):
...
@@ -87,7 +89,7 @@ def make_symlinks(env):
def
capture_compile
(
args
):
def
capture_compile
(
args
):
env
=
dict
(
os
.
environ
)
env
=
dict
(
os
.
environ
)
make_symlinks
(
env
)
make_symlinks
(
env
)
env
[
'PATH'
]
=
str
(
ROOT
DIR
)
+
':'
+
os
.
environ
[
'PATH'
]
env
[
'PATH'
]
=
str
(
TOOLS
DIR
)
+
':'
+
os
.
environ
[
'PATH'
]
result
=
subprocess
.
run
(
result
=
subprocess
.
run
(
[
Path
(
args
.
host
)
/
'bin'
/
'python3'
,
[
Path
(
args
.
host
)
/
'bin'
/
'python3'
,
...
@@ -186,7 +188,7 @@ def clean_out_native_artifacts():
...
@@ -186,7 +188,7 @@ def clean_out_native_artifacts():
path
.
unlink
()
path
.
unlink
()
def
install_for_distribution
():
def
install_for_distribution
(
args
):
subprocess
.
check_call
(
subprocess
.
check_call
(
[
Path
(
args
.
host
)
/
'bin'
/
'python3'
,
[
Path
(
args
.
host
)
/
'bin'
/
'python3'
,
'setup.py'
,
'setup.py'
,
...
@@ -202,11 +204,11 @@ def build_wrap(args):
...
@@ -202,11 +204,11 @@ def build_wrap(args):
capture_compile
(
args
)
capture_compile
(
args
)
clean_out_native_artifacts
()
clean_out_native_artifacts
()
replay_compile
(
args
)
replay_compile
(
args
)
install_for_distribution
()
install_for_distribution
(
args
)
def
parse_args
(
):
def
make_parser
(
parser
):
parser
=
argparse
.
ArgumentParser
(
parser
.
description
=
(
'Cross compile a Python distutils package. '
'Cross compile a Python distutils package. '
'Run from the root directory of the package
\
'
s source'
)
'Run from the root directory of the package
\
'
s source'
)
parser
.
add_argument
(
parser
.
add_argument
(
...
@@ -221,14 +223,19 @@ def parse_args():
...
@@ -221,14 +223,19 @@ def parse_args():
parser
.
add_argument
(
parser
.
add_argument
(
'--target'
,
type
=
str
,
nargs
=
'?'
,
default
=
common
.
TARGETPYTHON
,
'--target'
,
type
=
str
,
nargs
=
'?'
,
default
=
common
.
TARGETPYTHON
,
help
=
'The path to the target Python installation'
)
help
=
'The path to the target Python installation'
)
args
=
parser
.
parse_args
(
)
parser
.
add_argument
(
'basename'
,
type
=
str
,
nargs
=
'?'
)
return
args
return
parser
if
__name__
==
'__main__'
:
def
main
(
args
,
unknown
=
None
)
:
basename
=
Path
(
sys
.
argv
[
0
]).
name
basename
=
Path
(
sys
.
argv
[
0
]).
name
if
basename
in
symlinks
:
if
basename
in
symlinks
:
collect_args
(
basename
)
collect_args
(
basename
)
else
:
else
:
args
=
parse_args
()
build_wrap
(
args
)
build_wrap
(
args
)
if
__name__
==
'__main__'
:
parser
=
make_parser
(
argparse
.
ArgumentParser
())
args
,
unknown
=
parser
.
parse_known_args
()
main
(
args
,
unknown
)
setup.py
0 → 100644
View file @
72293058
from
setuptools
import
setup
,
find_packages
from
pyodide_build
import
__version__
with
open
(
'README.md'
,
'rt'
)
as
fh
:
LONG_DESCRIPTION
=
fh
.
read
()
setup
(
name
=
'pyodide_build'
,
version
=
__version__
,
description
=
'pyodide builder'
,
entry_points
=
{
'console_scripts'
:
[
'pyodide = pyodide_build.__main__:main'
]},
url
=
"https://github.com/iodide-project/pyodide"
,
license
=
'MPL'
,
packages
=
find_packages
())
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment