Skip to content

Commit bd88531

Browse files
committed
Merge pull request #1 from micropython/master
update from original micropython-lib
2 parents 286ead8 + ad7b1ad commit bd88531

Some content is hidden

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

70 files changed

+598
-48
lines changed

README.md

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,61 @@
1+
~~~~
2+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
3+
micropython-lib is highly experimental community project.
4+
5+
Please help to drive it to just "expiremental" state by testing
6+
provided packages with MicroPython.
7+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
8+
~~~~
9+
110
micropython-lib
211
===============
12+
micropython-lib is a project to develop non-monolothic standard library
13+
for MicroPython. Each module or package is available as a seprate
14+
distribution package from PyPI. Modules either written from scratch or
15+
ported from CPython. Note that main target of micropython-lib is so
16+
far "Unix" port of MicroPython. Actual requirements vary per module
17+
(basicly, if module is not related to I/O, it should work without
18+
problem on baremetal ports too).
19+
20+
Usage
21+
-----
22+
micropython-lib packages are published on PyPI (Python Package Index),
23+
standard Python community package repository: http://pypi.python.org/ .
24+
You can search for MicroPython related packages, read additional info,
25+
etc.
26+
27+
To install packages from PyPI for usage on your local system, use
28+
"pip-micropython" tool, which is a simple wrapper around a standard
29+
"pip" tool, which is used to install package for CPython.
30+
"pip-micropython" tool can be found in "tools" subdirectory of the main
31+
MicroPython repository (https://github.com/micropython/micropython).
32+
Just install "pip-micropython" script somewhere on your PATH.
33+
34+
Afterwards, just use pip-micropython in a way similar to pip:
35+
36+
~~~~
37+
$ pip-micropython install micropython-copy
38+
$ micropython
39+
>>> import copy
40+
>>> copy.copy([1, 2, 3])
41+
[1, 2, 3]
42+
~~~~
43+
44+
Review pip-micropython source code for more info.
45+
46+
Development
47+
-----------
48+
To install modules during development, use "make install". By default, it
49+
will install all available packages. You can pass MOD=<module> parameter
50+
to install specific module.
51+
52+
Links
53+
-----
54+
More info:
55+
56+
* https://github.com/micropython/micropython/issues/405
57+
* http://forum.micropython.org/viewtopic.php?f=5&t=70
58+
59+
Basic guidelines for installing packages from PyPI:
360

4-
Core Python libraries ported to Micro Python
61+
* https://github.com/micropython/micropython/issues/413

_libc/_libc.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import ffi
2+
3+
4+
_h = None
5+
6+
names = ('libc.so', 'libc.so.0', 'libc.so.6')
7+
8+
def get():
9+
global _h
10+
if _h:
11+
return _h
12+
err = None
13+
for n in names:
14+
try:
15+
_h = ffi.open(n)
16+
return _h
17+
except OSError as e:
18+
err = e
19+
raise err
20+
21+
22+
def set_names(n):
23+
global names
24+
names = n

_libc/metadata.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
dist_name = libc
2+
srctype = micropython-lib
3+
type = module
4+
version = 0.1
5+
author = Paul Sokolovsky
6+
desc = MicroPython FFI helper module
7+
long_desc = MicroPython FFI helper module to interface with underlying libc

_libc/setup.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import sys
2+
# Remove current dir from sys.path, otherwise setuptools will peek up our
3+
# module instead of system.
4+
sys.path.pop(0)
5+
from setuptools import setup
6+
7+
8+
setup(name='micropython-libc',
9+
version='0.1',
10+
description='MicroPython FFI helper module',
11+
long_description='MicroPython FFI helper module to interface with underlying libc',
12+
url='https://github.com/micropython/micropython/issues/405',
13+
author='Paul Sokolovsky',
14+
author_email='[email protected]',
15+
maintainer='MicroPython Developers',
16+
maintainer_email='[email protected]',
17+
license='MIT',
18+
py_modules=['_libc'])

fcntl/fcntl.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import ffi
2+
import _libc
23

34

4-
libc = ffi.open("libc.so.6")
5+
libc = _libc.get()
56

67
fcntl_l = libc.func("i", "fcntl", "iil")
78
fcntl_s = libc.func("i", "fcntl", "iip")

fcntl/metadata.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
srctype = micropython-lib
2+
type = module
3+
version = 0.0.2
4+
author = Paul Sokolovsky
5+
depends = libc

fcntl/setup.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1-
from distutils.core import setup
1+
import sys
2+
# Remove current dir from sys.path, otherwise setuptools will peek up our
3+
# module instead of system.
4+
sys.path.pop(0)
5+
from setuptools import setup
6+
27

38
setup(name='micropython-fcntl',
4-
version='0.0.1',
9+
version='0.0.2',
510
description='fcntl module for MicroPython',
11+
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.",
612
url='https://github.com/micropython/micropython/issues/405',
7-
author='MicroPython Developers',
13+
author='Paul Sokolovsky',
814
author_email='[email protected]',
15+
maintainer='MicroPython Developers',
16+
maintainer_email='[email protected]',
917
license='MIT',
10-
py_modules=['fcntl'])
18+
py_modules=['fcntl'],
19+
install_requires=['micropython-libc'])

functools/functools.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,13 @@ def _partial(*more_args, **more_kwargs):
44
kw.update(more_kwargs)
55
func(*(args + more_args), **kw)
66
return _partial
7+
8+
9+
def update_wrapper(wrapper, wrapped):
10+
# Dummy impl
11+
return wrapper
12+
13+
14+
def wraps(wrapped):
15+
# Dummy impl
16+
return wrapped

functools/metadata.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
srctype = micropython-lib
22
type = module
3-
version = 0.0.1
3+
version = 0.0.2

functools/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
setup(name='micropython-functools',
9-
version='0.0.1',
9+
version='0.0.2',
1010
description='functools module for MicroPython',
1111
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.",
1212
url='https://github.com/micropython/micropython/issues/405',

getpass/getpass.py

Whitespace-only changes.

getpass/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

getpass/setup.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import sys
2+
# Remove current dir from sys.path, otherwise setuptools will peek up our
3+
# module instead of system.
4+
sys.path.pop(0)
5+
from setuptools import setup
6+
7+
8+
setup(name='micropython-getpass',
9+
version='0.0.0',
10+
description='Dummy getpass module for MicroPython',
11+
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.',
12+
url='https://github.com/micropython/micropython/issues/405',
13+
author='MicroPython Developers',
14+
author_email='[email protected]',
15+
maintainer='MicroPython Developers',
16+
maintainer_email='[email protected]',
17+
license='MIT',
18+
py_modules=['getpass'])

glob/glob.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Filename globbing utility."""
22

33
import os
4+
import os.path
45
import re
56
import fnmatch
67

glob/metadata.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
srctype = cpython
22
type = module
3-
version = 0.5
3+
version = 0.5.1
44
depends = os, re-pcre, fnmatch

glob/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
setup(name='micropython-glob',
9-
version='0.5',
9+
version='0.5.1',
1010
description='CPython glob module ported to MicroPython',
1111
long_description='This is a module ported from CPython standard library to be compatible with\nMicroPython interpreter. Usually, this means applying small patches for\nfeatures not supported (yet, or at all) in MicroPython. Sometimes, heavier\nchanges are required. Note that CPython modules are written with availability\nof vast resources in mind, and may not work for MicroPython ports with\nlimited heap. If you are affected by such a case, please help reimplement\nthe module from scratch.',
1212
url='https://github.com/micropython/micropython/issues/405',

heapq/heapq.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
# Original code by Kevin O'Connor, augmented by Tim Peters and Raymond Hettinger
3232

33-
__about__ = """Heap queues
33+
"""Heap queues
3434
3535
[explanation by François Pinard]
3636
@@ -127,7 +127,7 @@
127127
__all__ = ['heappush', 'heappop', 'heapify', 'heapreplace', 'merge',
128128
'nlargest', 'nsmallest', 'heappushpop']
129129

130-
from itertools import islice, count, tee, chain
130+
#from itertools import count, tee, chain
131131

132132
def heappush(heap, item):
133133
"""Push item onto heap, maintaining the heap invariant."""
@@ -197,6 +197,7 @@ def nlargest(n, iterable):
197197
198198
Equivalent to: sorted(iterable, reverse=True)[:n]
199199
"""
200+
from itertools import islice, count, tee, chain
200201
if n < 0:
201202
return []
202203
it = iter(iterable)
@@ -215,6 +216,7 @@ def nsmallest(n, iterable):
215216
216217
Equivalent to: sorted(iterable)[:n]
217218
"""
219+
from itertools import islice, count, tee, chain
218220
if n < 0:
219221
return []
220222
it = iter(iterable)
@@ -392,6 +394,7 @@ def nsmallest(n, iterable, key=None):
392394
393395
Equivalent to: sorted(iterable, key=key)[:n]
394396
"""
397+
from itertools import islice, count, tee, chain
395398
# Short-cut for n==1 is to use min() when len(iterable)>0
396399
if n == 1:
397400
it = iter(iterable)
@@ -430,6 +433,7 @@ def nlargest(n, iterable, key=None):
430433
Equivalent to: sorted(iterable, key=key, reverse=True)[:n]
431434
"""
432435

436+
from itertools import islice, count, tee, chain
433437
# Short-cut for n==1 is to use max() when len(iterable)>0
434438
if n == 1:
435439
it = iter(iterable)

heapq/metadata.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
srctype = cpython
2+
type = module
3+
version = 0.9.2
4+
# Module uses in *some* functions, but we don't want to depend on it
5+
#depends = itertools

heapq/setup.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
import sys
2-
# Remove current dir from sys.path, otherwise distutils will peek up our
3-
# copy module instead of system.
2+
# Remove current dir from sys.path, otherwise setuptools will peek up our
3+
# module instead of system.
44
sys.path.pop(0)
55
from setuptools import setup
66

7+
78
setup(name='micropython-heapq',
8-
version='0.9',
9+
version='0.9.2',
910
description='CPython heapq module ported to MicroPython',
11+
long_description='This is a module ported from CPython standard library to be compatible with\nMicroPython interpreter. Usually, this means applying small patches for\nfeatures not supported (yet, or at all) in MicroPython. Sometimes, heavier\nchanges are required. Note that CPython modules are written with availability\nof vast resources in mind, and may not work for MicroPython ports with\nlimited heap. If you are affected by such a case, please help reimplement\nthe module from scratch.',
1012
url='https://github.com/micropython/micropython/issues/405',
1113
author='CPython Developers',
14+
author_email='[email protected]',
1215
maintainer='MicroPython Developers',
1316
maintainer_email='[email protected]',
1417
license='Python',
15-
install_requires=['micropython-itertools'],
1618
py_modules=['heapq'])

http.client/metadata.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
srctype = cpython
2+
type = package
3+
version = 0.5
4+
depends = email.parser, email.message, socket, collections, urllib.parse, warnings

http.client/setup.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import sys
2+
# Remove current dir from sys.path, otherwise setuptools will peek up our
3+
# module instead of system.
4+
sys.path.pop(0)
5+
from setuptools import setup
6+
7+
8+
setup(name='micropython-http.client',
9+
version='0.5',
10+
description='CPython http.client module ported to MicroPython',
11+
long_description='This is a module ported from CPython standard library to be compatible with\nMicroPython interpreter. Usually, this means applying small patches for\nfeatures not supported (yet, or at all) in MicroPython. Sometimes, heavier\nchanges are required. Note that CPython modules are written with availability\nof vast resources in mind, and may not work for MicroPython ports with\nlimited heap. If you are affected by such a case, please help reimplement\nthe module from scratch.',
12+
url='https://github.com/micropython/micropython/issues/405',
13+
author='CPython Developers',
14+
author_email='[email protected]',
15+
maintainer='MicroPython Developers',
16+
maintainer_email='[email protected]',
17+
license='Python',
18+
packages=['http'],
19+
install_requires=['micropython-email.parser', 'micropython-email.message', 'micropython-socket', 'micropython-collections', 'micropython-urllib.parse', 'micropython-warnings'])

http.client/test_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
conn = HTTPConnection("localhost")
5-
#conn = HTTPConnection("micropython.org")
5+
#conn = HTTPConnection("python.org")
66
conn.request("GET", "/")
77
resp = conn.getresponse()
88
print(resp)

io/io.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from _io import *

io/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.1

io/setup.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import sys
2+
# Remove current dir from sys.path, otherwise setuptools will peek up our
3+
# module instead of system.
4+
sys.path.pop(0)
5+
from setuptools import setup
6+
7+
8+
setup(name='micropython-io',
9+
version='0.0.1',
10+
description='Dummy io module for MicroPython',
11+
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.',
12+
url='https://github.com/micropython/micropython/issues/405',
13+
author='MicroPython Developers',
14+
author_email='[email protected]',
15+
maintainer='MicroPython Developers',
16+
maintainer_email='[email protected]',
17+
license='MIT',
18+
py_modules=['io'])

ipaddress/ipaddress.py

Whitespace-only changes.

ipaddress/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

ipaddress/setup.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import sys
2+
# Remove current dir from sys.path, otherwise setuptools will peek up our
3+
# module instead of system.
4+
sys.path.pop(0)
5+
from setuptools import setup
6+
7+
8+
setup(name='micropython-ipaddress',
9+
version='0.0.0',
10+
description='Dummy ipaddress module for MicroPython',
11+
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.',
12+
url='https://github.com/micropython/micropython/issues/405',
13+
author='MicroPython Developers',
14+
author_email='[email protected]',
15+
maintainer='MicroPython Developers',
16+
maintainer_email='[email protected]',
17+
license='MIT',
18+
py_modules=['ipaddress'])

mailbox/mailbox.py

Whitespace-only changes.

mailbox/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

0 commit comments

Comments
 (0)