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
584c61ed
Commit
584c61ed
authored
Mar 12, 2019
by
Roman Yurchak
Committed by
GitHub
Mar 12, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #331 from mdboom/mkpkg
Add a mkpkg tool to make new packages.
parents
de7cb8f4
1b867058
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
1 deletion
+77
-1
docs/new_packages.md
docs/new_packages.md
+7
-0
pyodide_build/__main__.py
pyodide_build/__main__.py
+3
-1
pyodide_build/mkpkg.py
pyodide_build/mkpkg.py
+67
-0
No files found.
docs/new_packages.md
View file @
584c61ed
...
...
@@ -41,6 +41,13 @@ expect Conda packages to "just work" with Pyodide. (In the longer term, Pyodide
may use conda as its packaging system, and this should hopefully ease that
transition.)
There is a helper tool that will generate a
`meta.yaml`
for packages on PyPI
that will work for many pure Python packages. This tool will populate the latest
version, download link and sha256 hash by querying PyPI. It doesn't currently
handle package dependencies. To run it, do:
`bin/pyodide mkpkg $PACKAGE_NAME`
The supported keys in the
`meta.yaml`
file are described below.
### `package`
...
...
pyodide_build/__main__.py
View file @
584c61ed
...
...
@@ -5,6 +5,7 @@ from . import buildall
from
.
import
buildpkg
from
.
import
pywasmcross
from
.
import
serve
from
.
import
mkpkg
def
main
():
...
...
@@ -14,7 +15,8 @@ def main():
for
command_name
,
module
in
((
"buildpkg"
,
buildpkg
),
(
"buildall"
,
buildall
),
(
"pywasmcross"
,
pywasmcross
),
(
"serve"
,
serve
)):
(
"serve"
,
serve
),
(
"mkpkg"
,
mkpkg
)):
parser
=
module
.
make_parser
(
subparsers
.
add_parser
(
command_name
))
parser
.
set_defaults
(
func
=
module
.
main
)
...
...
pyodide_build/mkpkg.py
0 → 100755
View file @
584c61ed
#!/usr/bin/env python3
import
argparse
import
json
import
os
from
pathlib
import
Path
import
urllib.request
PACKAGES_ROOT
=
Path
(
__file__
).
parent
.
parent
/
'packages'
def
make_package
(
package
):
import
yaml
url
=
f'https://pypi.org/pypi/
{
package
}
/json'
with
urllib
.
request
.
urlopen
(
url
)
as
fd
:
json_content
=
json
.
load
(
fd
)
entry
=
json_content
[
'urls'
][
0
]
download_url
=
entry
[
'url'
]
sha256
=
entry
[
'digests'
][
'sha256'
]
version
=
json_content
[
'info'
][
'version'
]
yaml_content
=
{
'package'
:
{
'name'
:
package
,
'version'
:
version
},
'source'
:
{
'url'
:
download_url
,
'sha256'
:
sha256
},
'test'
:
{
'imports'
:
[
package
]
}
}
if
not
(
PACKAGES_ROOT
/
package
).
is_dir
():
os
.
makedirs
(
PACKAGES_ROOT
/
package
)
with
open
(
PACKAGES_ROOT
/
package
/
'meta.yaml'
,
'w'
)
as
fd
:
yaml
.
dump
(
yaml_content
,
fd
,
default_flow_style
=
False
)
def
make_parser
(
parser
):
parser
.
description
=
'''
Make a new pyodide package. Creates a simple template that will work
for most pure Python packages, but will have to be edited for more wv
complex things.'''
.
strip
()
parser
.
add_argument
(
'package'
,
type
=
str
,
nargs
=
1
,
help
=
"The package name on PyPI"
)
return
parser
def
main
(
args
):
package
=
args
.
package
[
0
]
make_package
(
package
)
if
__name__
==
'__main__'
:
parser
=
make_parser
(
argparse
.
ArgumentParser
())
args
=
parser
.
parse_args
()
main
(
args
)
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