Skip to content

Commit 23e0467

Browse files
committed
Merge remote-tracking branch 'remotes/upstream/master' into feature/mro_resolution
# Conflicts: # vm/src/obj/objsuper.rs # vm/src/obj/objtype.rs
2 parents cb24114 + e07ca66 commit 23e0467

Some content is hidden

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

61 files changed

+10512
-580
lines changed

.github/workflows/ci.yaml

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ jobs:
3131
command: test
3232
args: --verbose --all
3333

34-
snippets:
35-
name: Run snippets tests
34+
snippets_cpython:
35+
name: Run snippets and cpython tests
3636
runs-on: ${{ matrix.os }}
3737
strategy:
3838
matrix:
@@ -68,6 +68,11 @@ jobs:
6868
- name: run snippets
6969
run: pipenv run pytest -v
7070
working-directory: ./tests
71+
- name: run cpython tests
72+
run: cargo run --release -- -m test -v
73+
env:
74+
RUSTPYTHONPATH: ${{ github.workspace }}/Lib
75+
if: runner.os != 'Windows'
7176

7277
format:
7378
name: Check Rust code with rustfmt and clippy
@@ -104,21 +109,6 @@ jobs:
104109
- name: run lint
105110
run: flake8 . --count --exclude=./.*,./Lib,./vm/Lib --select=E9,F63,F7,F82 --show-source --statistics
106111

107-
cpython:
108-
name: Run CPython test suite
109-
runs-on: ubuntu-latest
110-
steps:
111-
- uses: actions/checkout@master
112-
- name: build rustpython
113-
uses: actions-rs/cargo@v1
114-
with:
115-
command: build
116-
args: --verbose --all
117-
- name: run tests
118-
run: |
119-
export RUSTPYTHONPATH=`pwd`/Lib
120-
cargo run -- -m test -v
121-
122112
wasm:
123113
name: Check the WASM package and demo
124114
runs-on: ubuntu-latest

.gitpod.Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM gitpod/workspace-full
2+
3+
USER gitpod
4+
5+
# Update Rust to the latest version
6+
RUN rm -rf ~/.rustup && \
7+
export PATH=$HOME/.cargo/bin:$PATH && \
8+
rustup update stable && \
9+
rustup component add rls && \
10+
# Set up wasm-pack and wasm32-unknown-unknown for rustpython_wasm
11+
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh && \
12+
rustup target add wasm32-unknown-unknown
13+
14+
USER root

.gitpod.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
image:
2+
file: .gitpod.Dockerfile

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/importlib/_bootstrap_external.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,21 +1575,22 @@ def _setup(_bootstrap_module):
15751575
setattr(self_module, builtin_name, builtin_module)
15761576

15771577
# Directly load the os module (needed during bootstrap).
1578-
# XXX Changed to fit RustPython!!!
1579-
builtin_os = "_os"
1580-
if builtin_os in sys.modules:
1581-
os_module = sys.modules[builtin_os]
1578+
os_details = ('posix', ['/']), ('nt', ['\\', '/'])
1579+
for builtin_os, path_separators in os_details:
1580+
# Assumption made in _path_join()
1581+
assert all(len(sep) == 1 for sep in path_separators)
1582+
path_sep = path_separators[0]
1583+
if builtin_os in sys.modules:
1584+
os_module = sys.modules[builtin_os]
1585+
break
1586+
else:
1587+
try:
1588+
os_module = _bootstrap._builtin_from_name(builtin_os)
1589+
break
1590+
except ImportError:
1591+
continue
15821592
else:
1583-
try:
1584-
os_module = _bootstrap._builtin_from_name(builtin_os)
1585-
except ImportError:
1586-
raise ImportError('importlib requires _os')
1587-
path_separators = ['\\', '/'] if os_module.name == 'nt' else ['/']
1588-
1589-
# Assumption made in _path_join()
1590-
assert all(len(sep) == 1 for sep in path_separators)
1591-
path_sep = path_separators[0]
1592-
1593+
raise ImportError('importlib requires posix or nt')
15931594
setattr(self_module, '_os', os_module)
15941595
setattr(self_module, 'path_sep', path_sep)
15951596
setattr(self_module, 'path_separators', ''.join(path_separators))
@@ -1604,7 +1605,8 @@ def _setup(_bootstrap_module):
16041605
setattr(self_module, '_weakref', weakref_module)
16051606

16061607
# Directly load the winreg module (needed during bootstrap).
1607-
if builtin_os == 'nt':
1608+
# XXX RustPython TODO: winreg module
1609+
if builtin_os == 'nt' and False:
16081610
winreg_module = _bootstrap._builtin_from_name('winreg')
16091611
setattr(self_module, '_winreg', winreg_module)
16101612

Lib/os.py

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,50 @@ def _get_exports_list(module):
4343
except AttributeError:
4444
return [n for n in dir(module) if n[0] != '_']
4545

46-
import _os
47-
from _os import *
48-
from _os import _exit
49-
__all__.extend(_get_exports_list(_os))
50-
del _os
51-
5246
# Any new dependencies of the os module and/or changes in path separator
5347
# requires updating importlib as well.
54-
if name == 'nt':
55-
linesep = '\r\n'
56-
import ntpath as path
57-
else:
48+
if 'posix' in _names:
49+
name = 'posix'
5850
linesep = '\n'
51+
from posix import *
52+
try:
53+
from posix import _exit
54+
__all__.append('_exit')
55+
except ImportError:
56+
pass
5957
import posixpath as path
6058

59+
try:
60+
from posix import _have_functions
61+
except ImportError:
62+
pass
63+
64+
import posix
65+
__all__.extend(_get_exports_list(posix))
66+
del posix
67+
68+
elif 'nt' in _names:
69+
name = 'nt'
70+
linesep = '\r\n'
71+
from nt import *
72+
try:
73+
from nt import _exit
74+
__all__.append('_exit')
75+
except ImportError:
76+
pass
77+
import ntpath as path
78+
79+
import nt
80+
__all__.extend(_get_exports_list(nt))
81+
del nt
82+
83+
try:
84+
from nt import _have_functions
85+
except ImportError:
86+
pass
87+
88+
else:
89+
raise ImportError('no os specific module found')
6190

6291
sys.modules['os.path'] = path
6392
from os.path import (curdir, pardir, sep, pathsep, defpath, extsep, altsep,

0 commit comments

Comments
 (0)