Skip to content

Commit 29c541a

Browse files
authored
Merge pull request #1 from micropython/master
Merging in changes since last checked
2 parents 61f9dd8 + e439624 commit 29c541a

File tree

257 files changed

+8123
-683
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

257 files changed

+8123
-683
lines changed

README.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
11
micropython-lib
22
===============
33
micropython-lib is a project to develop a non-monolothic standard library
4-
for MicroPython (https://github.com/micropython/micropython). Each module
5-
or package is available as a separate distribution package from PyPI. Each
6-
module comes from one of the following sources (and thus each module has
7-
its own licensing terms):
4+
for "advanced" MicroPython fork (https://github.com/pfalcon/micropython).
5+
Each module or package is available as a separate distribution package from
6+
PyPI. Each module comes from one of the following sources (and thus each
7+
module has its own licensing terms):
88

99
* written from scratch specifically for MicroPython
1010
* ported from CPython
1111
* ported from some other Python implementation, e.g. PyPy
1212
* some modules actually aren't implemented yet and are dummy
1313

14-
Note that the main target of micropython-lib is a "Unix" port of MicroPython.
15-
Actual system requirements vary per module. For example, if a module is not
16-
related to I/O, it may work without problems on bare-metal ports too (e.g.
17-
pyboard).
14+
Note that the main target of micropython-lib is a "Unix" port of the
15+
aforementioned fork of MicroPython. Actual system requirements vary per
16+
module. Majority of modules are compatible with the upstream MicroPython,
17+
though some may require additional functionality/optimizations present in
18+
the "advanced" fork. Modules not related to I/O may also work without
19+
problems on bare-metal ports, not just on "Unix" port (e.g. pyboard).
1820

1921

2022
Usage
2123
-----
2224
micropython-lib packages are published on PyPI (Python Package Index),
23-
the standard Python community package repository: http://pypi.python.org/ .
25+
the standard Python community package repository: https://pypi.org/ .
2426
On PyPI, you can search for MicroPython related packages and read
2527
additional package information. By convention, all micropython-lib package
2628
names are prefixed with "micropython-" (the reverse is not true - some
2729
package starting with "micropython-" aren't part of micropython-lib and
2830
were released by 3rd parties).
2931

30-
Browse available packages
31-
[via this URL](https://pypi.python.org/pypi?%3Aaction=search&term=micropython).
32+
Browse available packages [via this
33+
URL](https://pypi.org/search/?q=&o=&c=Programming+Language+%3A%3A+Python+%3A%3A+Implementation+%3A%3A+MicroPython).
3234

3335
To install packages from PyPI for usage on your local system, use the
3436
`upip` tool, which is MicroPython's native package manager, similar to

__future__/setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
sys.path.pop(0)
55
from setuptools import setup
66
sys.path.append("..")
7-
import optimize_upip
7+
import sdist_upip
88

99
setup(name='micropython-future',
1010
version='0.0.3',
1111
description='Dummy __future__ module for MicroPython',
1212
long_description='This is a dummy implementation of a module for MicroPython standard library.\nIt contains zero or very little functionality, and primarily intended to\navoid import errors (using idea that even if an application imports a\nmodule, it may be not using it onevery code path, so may work at least\npartially). It is expected that more complete implementation of the module\nwill be provided later. Please help with the development if you are\ninterested in this module.',
1313
url='https://github.com/micropython/micropython-lib',
14-
author='MicroPython Developers',
14+
author='micropython-lib Developers',
1515
author_email='[email protected]',
16-
maintainer='MicroPython Developers',
16+
maintainer='micropython-lib Developers',
1717
maintainer_email='[email protected]',
1818
license='MIT',
19-
cmdclass={'optimize_upip': optimize_upip.OptimizeUpip},
19+
cmdclass={'sdist': sdist_upip.sdist},
2020
py_modules=['__future__'])

_libc/setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
sys.path.pop(0)
55
from setuptools import setup
66
sys.path.append("..")
7-
import optimize_upip
7+
import sdist_upip
88

99
setup(name='micropython-libc',
1010
version='0.3.1',
@@ -13,8 +13,8 @@
1313
url='https://github.com/micropython/micropython-lib',
1414
author='Paul Sokolovsky',
1515
author_email='[email protected]',
16-
maintainer='MicroPython Developers',
16+
maintainer='micropython-lib Developers',
1717
maintainer_email='[email protected]',
1818
license='MIT',
19-
cmdclass={'optimize_upip': optimize_upip.OptimizeUpip},
19+
cmdclass={'sdist': sdist_upip.sdist},
2020
py_modules=['_libc'])

_markupbase/setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
sys.path.pop(0)
55
from setuptools import setup
66
sys.path.append("..")
7-
import optimize_upip
7+
import sdist_upip
88

99
setup(name='micropython-_markupbase',
1010
version='3.3.3-1',
@@ -13,9 +13,9 @@
1313
url='https://github.com/micropython/micropython-lib',
1414
author='CPython Developers',
1515
author_email='[email protected]',
16-
maintainer='MicroPython Developers',
16+
maintainer='micropython-lib Developers',
1717
maintainer_email='[email protected]',
1818
license='Python',
19-
cmdclass={'optimize_upip': optimize_upip.OptimizeUpip},
19+
cmdclass={'sdist': sdist_upip.sdist},
2020
py_modules=['_markupbase'],
2121
install_requires=['micropython-re-pcre'])

abc/setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
sys.path.pop(0)
55
from setuptools import setup
66
sys.path.append("..")
7-
import optimize_upip
7+
import sdist_upip
88

99
setup(name='micropython-abc',
1010
version='0.0.1',
1111
description='Dummy abc module for MicroPython',
1212
long_description='This is a dummy implementation of a module for MicroPython standard library.\nIt contains zero or very little functionality, and primarily intended to\navoid import errors (using idea that even if an application imports a\nmodule, it may be not using it onevery code path, so may work at least\npartially). It is expected that more complete implementation of the module\nwill be provided later. Please help with the development if you are\ninterested in this module.',
1313
url='https://github.com/micropython/micropython-lib',
14-
author='MicroPython Developers',
14+
author='micropython-lib Developers',
1515
author_email='[email protected]',
16-
maintainer='MicroPython Developers',
16+
maintainer='micropython-lib Developers',
1717
maintainer_email='[email protected]',
1818
license='MIT',
19-
cmdclass={'optimize_upip': optimize_upip.OptimizeUpip},
19+
cmdclass={'sdist': sdist_upip.sdist},
2020
py_modules=['abc'])

argparse/argparse.py

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,25 +144,37 @@ def render_arg(arg):
144144
print(" %-16s%s" % (', '.join(opt.names) + render_arg(opt), opt.help))
145145

146146
def parse_args(self, args=None):
147+
return self._parse_args_impl(args, False)
148+
149+
def parse_known_args(self, args=None):
150+
return self._parse_args_impl(args, True)
151+
152+
def _parse_args_impl(self, args, return_unknown):
147153
if args is None:
148154
args = sys.argv[1:]
149155
else:
150156
args = args[:]
151157
try:
152-
return self._parse_args(args)
158+
return self._parse_args(args, return_unknown)
153159
except _ArgError as e:
154160
self.usage(False)
155161
print("error:", e)
156162
sys.exit(2)
157163

158-
def _parse_args(self, args):
164+
def _parse_args(self, args, return_unknown):
159165
# add optional args with defaults
160166
arg_dest = []
161167
arg_vals = []
162168
for opt in self.opt:
163169
arg_dest.append(opt.dest)
164170
arg_vals.append(opt.default)
165171

172+
# deal with unknown arguments, if needed
173+
unknown = []
174+
def consume_unknown():
175+
while args and not args[0].startswith("-"):
176+
unknown.append(args.pop(0))
177+
166178
# parse all args
167179
parsed_pos = False
168180
while args or not parsed_pos:
@@ -179,15 +191,26 @@ def _parse_args(self, args):
179191
found = True
180192
break
181193
if not found:
182-
raise _ArgError("unknown option %s" % a)
194+
if return_unknown:
195+
unknown.append(a)
196+
consume_unknown()
197+
else:
198+
raise _ArgError("unknown option %s" % a)
183199
else:
184200
# positional arg
185201
if parsed_pos:
186-
raise _ArgError("extra args: %s" % " ".join(args))
202+
if return_unknown:
203+
unknown = unknown + args
204+
break
205+
else:
206+
raise _ArgError("extra args: %s" % " ".join(args))
187207
for pos in self.pos:
188208
arg_dest.append(pos.dest)
189209
arg_vals.append(pos.parse(pos.names[0], args))
190210
parsed_pos = True
211+
if return_unknown:
212+
consume_unknown()
191213

192214
# build and return named tuple with arg values
193-
return namedtuple("args", arg_dest)(*arg_vals)
215+
values = namedtuple("args", arg_dest)(*arg_vals)
216+
return (values, unknown) if return_unknown else values

argparse/metadata.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
srctype = micropython-lib
22
type = module
3-
version = 0.3.3
3+
version = 0.4
44
author = Damien George

argparse/setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
sys.path.pop(0)
55
from setuptools import setup
66
sys.path.append("..")
7-
import optimize_upip
7+
import sdist_upip
88

99
setup(name='micropython-argparse',
10-
version='0.3.3',
10+
version='0.4',
1111
description='argparse module for MicroPython',
1212
long_description="This is a module reimplemented specifically for MicroPython standard library,\nwith efficient and lean design in mind. Note that this module is likely work\nin progress and likely supports just a subset of CPython's corresponding\nmodule. Please help with the development if you are interested in this\nmodule.",
1313
url='https://github.com/micropython/micropython-lib',
1414
author='Damien George',
1515
author_email='[email protected]',
16-
maintainer='MicroPython Developers',
16+
maintainer='micropython-lib Developers',
1717
maintainer_email='[email protected]',
1818
license='MIT',
19-
cmdclass={'optimize_upip': optimize_upip.OptimizeUpip},
19+
cmdclass={'sdist': sdist_upip.sdist},
2020
py_modules=['argparse'])

argparse/test_argparse.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,25 @@
4444
assert args.files1 == ["a", "b"] and args.files2 == []
4545
args = parser.parse_args(["a", "b", "c"])
4646
assert args.files1 == ["a", "b"] and args.files2 == ["c"]
47+
48+
parser = argparse.ArgumentParser()
49+
parser.add_argument("a", nargs=2)
50+
parser.add_argument("-b")
51+
args, rest = parser.parse_known_args(["a", "b", "-b", "2"])
52+
assert args.a == ["a", "b"] and args.b == "2"
53+
assert rest == []
54+
args, rest = parser.parse_known_args(["-b", "2", "a", "b", "c"])
55+
assert args.a == ["a", "b"] and args.b == "2"
56+
assert rest == ["c"]
57+
args, rest = parser.parse_known_args(["a", "b", "-b", "2", "c"])
58+
assert args.a == ["a", "b"] and args.b == "2"
59+
assert rest == ["c"]
60+
args, rest = parser.parse_known_args(["-b", "2", "a", "b", "-", "c"])
61+
assert args.a == ["a", "b"] and args.b == "2"
62+
assert rest == ["-", "c"]
63+
args, rest = parser.parse_known_args(["a", "b", "-b", "2", "-", "x", "y"])
64+
assert args.a == ["a", "b"] and args.b == "2"
65+
assert rest == ["-", "x", "y"]
66+
args, rest = parser.parse_known_args(["a", "b", "c", "-b", "2", "--x", "5", "1"])
67+
assert args.a == ["a", "b"] and args.b == "2"
68+
assert rest == ["c", "--x", "5", "1"]

array/metadata.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
srctype = dummy
2+
type = module
3+
version = 0.0.0

array/setup.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import sys
2+
# Remove current dir from sys.path, otherwise setuptools will peek up our
3+
# module instead of system's.
4+
sys.path.pop(0)
5+
from setuptools import setup
6+
sys.path.append("..")
7+
import sdist_upip
8+
9+
setup(name='micropython-array',
10+
version='0.0.0',
11+
description='Dummy array module for MicroPython',
12+
long_description='This is a dummy implementation of a module for MicroPython standard library.\nIt contains zero or very little functionality, and primarily intended to\navoid import errors (using idea that even if an application imports a\nmodule, it may be not using it onevery code path, so may work at least\npartially). It is expected that more complete implementation of the module\nwill be provided later. Please help with the development if you are\ninterested in this module.',
13+
url='https://github.com/micropython/micropython-lib',
14+
author='micropython-lib Developers',
15+
author_email='[email protected]',
16+
maintainer='micropython-lib Developers',
17+
maintainer_email='[email protected]',
18+
license='MIT',
19+
cmdclass={'sdist': sdist_upip.sdist},
20+
py_modules=['array'])

asyncio/setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
sys.path.pop(0)
55
from setuptools import setup
66
sys.path.append("..")
7-
import optimize_upip
7+
import sdist_upip
88

99
setup(name='micropython-asyncio',
1010
version='0.0.0',
1111
description='Dummy asyncio module for MicroPython',
1212
long_description='This is a dummy implementation of a module for MicroPython standard library.\nIt contains zero or very little functionality, and primarily intended to\navoid import errors (using idea that even if an application imports a\nmodule, it may be not using it onevery code path, so may work at least\npartially). It is expected that more complete implementation of the module\nwill be provided later. Please help with the development if you are\ninterested in this module.',
1313
url='https://github.com/micropython/micropython-lib',
14-
author='MicroPython Developers',
14+
author='micropython-lib Developers',
1515
author_email='[email protected]',
16-
maintainer='MicroPython Developers',
16+
maintainer='micropython-lib Developers',
1717
maintainer_email='[email protected]',
1818
license='MIT',
19-
cmdclass={'optimize_upip': optimize_upip.OptimizeUpip},
19+
cmdclass={'sdist': sdist_upip.sdist},
2020
py_modules=['asyncio'])

base64/setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
sys.path.pop(0)
55
from setuptools import setup
66
sys.path.append("..")
7-
import optimize_upip
7+
import sdist_upip
88

99
setup(name='micropython-base64',
1010
version='3.3.3-4',
@@ -13,9 +13,9 @@
1313
url='https://github.com/micropython/micropython-lib',
1414
author='CPython Developers',
1515
author_email='[email protected]',
16-
maintainer='MicroPython Developers',
16+
maintainer='micropython-lib Developers',
1717
maintainer_email='[email protected]',
1818
license='Python',
19-
cmdclass={'optimize_upip': optimize_upip.OptimizeUpip},
19+
cmdclass={'sdist': sdist_upip.sdist},
2020
py_modules=['base64'],
2121
install_requires=['micropython-binascii', 'micropython-re-pcre', 'micropython-struct'])

binascii/setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
sys.path.pop(0)
55
from setuptools import setup
66
sys.path.append("..")
7-
import optimize_upip
7+
import sdist_upip
88

99
setup(name='micropython-binascii',
1010
version='2.4.0-5',
@@ -13,8 +13,8 @@
1313
url='https://github.com/micropython/micropython-lib',
1414
author='PyPy Developers',
1515
author_email='[email protected]',
16-
maintainer='MicroPython Developers',
16+
maintainer='micropython-lib Developers',
1717
maintainer_email='[email protected]',
1818
license='MIT',
19-
cmdclass={'optimize_upip': optimize_upip.OptimizeUpip},
19+
cmdclass={'sdist': sdist_upip.sdist},
2020
py_modules=['binascii'])

binhex/setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
sys.path.pop(0)
55
from setuptools import setup
66
sys.path.append("..")
7-
import optimize_upip
7+
import sdist_upip
88

99
setup(name='micropython-binhex',
1010
version='0.0.2',
1111
description='Dummy binhex module for MicroPython',
1212
long_description='This is a dummy implementation of a module for MicroPython standard library.\nIt contains zero or very little functionality, and primarily intended to\navoid import errors (using idea that even if an application imports a\nmodule, it may be not using it onevery code path, so may work at least\npartially). It is expected that more complete implementation of the module\nwill be provided later. Please help with the development if you are\ninterested in this module.',
1313
url='https://github.com/micropython/micropython-lib',
14-
author='MicroPython Developers',
14+
author='micropython-lib Developers',
1515
author_email='[email protected]',
16-
maintainer='MicroPython Developers',
16+
maintainer='micropython-lib Developers',
1717
maintainer_email='[email protected]',
1818
license='MIT',
19-
cmdclass={'optimize_upip': optimize_upip.OptimizeUpip},
19+
cmdclass={'sdist': sdist_upip.sdist},
2020
py_modules=['binhex'])

calendar/setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
sys.path.pop(0)
55
from setuptools import setup
66
sys.path.append("..")
7-
import optimize_upip
7+
import sdist_upip
88

99
setup(name='micropython-calendar',
1010
version='0.0.1',
1111
description='Dummy calendar module for MicroPython',
1212
long_description='This is a dummy implementation of a module for MicroPython standard library.\nIt contains zero or very little functionality, and primarily intended to\navoid import errors (using idea that even if an application imports a\nmodule, it may be not using it onevery code path, so may work at least\npartially). It is expected that more complete implementation of the module\nwill be provided later. Please help with the development if you are\ninterested in this module.',
1313
url='https://github.com/micropython/micropython-lib',
14-
author='MicroPython Developers',
14+
author='micropython-lib Developers',
1515
author_email='[email protected]',
16-
maintainer='MicroPython Developers',
16+
maintainer='micropython-lib Developers',
1717
maintainer_email='[email protected]',
1818
license='MIT',
19-
cmdclass={'optimize_upip': optimize_upip.OptimizeUpip},
19+
cmdclass={'sdist': sdist_upip.sdist},
2020
py_modules=['calendar'])

0 commit comments

Comments
 (0)