Skip to content

Commit 1929bc0

Browse files
Merge pull request #533 from RustPython/master
Update the demo page and docs website.
2 parents ade4c88 + cbcf7c3 commit 1929bc0

File tree

158 files changed

+9884
-3133
lines changed

Some content is hidden

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

158 files changed

+9884
-3133
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ __pycache__
55
**/*.pytest_cache
66
.*sw*
77
.repl_history.txt
8+
.vscode
89
wasm-pack.log
10+
.idea/

.travis.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ env:
1616
cache: cargo
1717

1818
matrix:
19+
fast_finish: true
1920
include:
2021
# To test the snippets, we use Travis' Python environment (because
2122
# installing rust ourselves is a lot easier than installing Python)
@@ -31,6 +32,7 @@ matrix:
3132
env:
3233
- TRAVIS_RUST_VERSION=stable
3334
- REGULAR_TEST=false
35+
- CODE_COVERAGE=false
3436
script: tests/.travis-runner.sh
3537
- language: python
3638
python: 3.6
@@ -44,6 +46,7 @@ matrix:
4446
env:
4547
- TRAVIS_RUST_VERSION=beta
4648
- REGULAR_TEST=false
49+
- CODE_COVERAGE=false
4750
script: tests/.travis-runner.sh
4851
- name: rustfmt
4952
language: rust
@@ -86,9 +89,36 @@ matrix:
8689
env:
8790
- REGULAR_TEST=false
8891
- DEPLOY_DEMO=true
92+
- name: cargo-clippy
93+
language: rust
94+
rust: stable
95+
cache: cargo
96+
before_script:
97+
- rustup component add clippy
98+
script:
99+
- cargo clippy
100+
env:
101+
- REGULAR_TEST=true
102+
- name: Code Coverage
103+
language: python
104+
python: 3.6
105+
cache:
106+
pip: true
107+
# Because we're using the Python Travis environment, we can't use
108+
# the built-in cargo cacher
109+
directories:
110+
- /home/travis/.cargo
111+
- target
112+
script:
113+
- tests/.travis-runner.sh
114+
env:
115+
- TRAVIS_RUST_VERSION=nightly
116+
- REGULAR_TEST=false
117+
- CODE_COVERAGE=true
89118
allow_failures:
90119
- rust: nightly
91120
env: REGULAR_TEST=true
121+
- name: cargo-clippy
92122

93123
deploy:
94124
- provider: pages

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "rustpython"
33
version = "0.0.1"
44
authors = ["Windel Bouwman", "Shing Lyu <shing.lyu@gmail.com>"]
5+
edition = "2018"
56

67
[workspace]
78
members = [".", "vm", "wasm/lib", "parser"]
@@ -13,6 +14,7 @@ clap = "2.31.2"
1314
rustpython_parser = {path = "parser"}
1415
rustpython_vm = {path = "vm"}
1516
rustyline = "2.1.0"
17+
xdg = "2.2.0"
1618

1719
[profile.release]
1820
opt-level = "s"

README.md

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
A Python-3 (CPython >= 3.5.0) Interpreter written in Rust :snake: :scream: :metal:.
44

55
[![Build Status](https://travis-ci.org/RustPython/RustPython.svg?branch=master)](https://travis-ci.org/RustPython/RustPython)
6+
[![Build Status](https://dev.azure.com/ryan0463/ryan/_apis/build/status/RustPython.RustPython?branchName=master)](https://dev.azure.com/ryan0463/ryan/_build/latest?definitionId=1&branchName=master)
7+
[![codecov](https://codecov.io/gh/RustPython/RustPython/branch/master/graph/badge.svg)](https://codecov.io/gh/RustPython/RustPython)
68
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
79
[![Contributors](https://img.shields.io/github/contributors/RustPython/RustPython.svg)](https://github.com/RustPython/RustPython/graphs/contributors)
810
[![Gitter](https://badges.gitter.im/RustPython/Lobby.svg)](https://gitter.im/rustpython/Lobby)
@@ -25,14 +27,22 @@ Or use the interactive shell:
2527
>>>>> 2+2
2628
4
2729

30+
# Disclaimer
31+
32+
RustPython is in a development phase and should not be used in production or a fault intolerant setting.
33+
34+
Our current build supports only a subset of Python syntax.
35+
36+
Contribution is also more than welcome! See our contribution section for more information on this.
37+
2838
# Goals
2939

3040
- Full Python-3 environment entirely in Rust (not CPython bindings)
3141
- A clean implementation without compatibility hacks
3242

3343
# Documentation
3444

35-
Currently the project is in an early phase, and so is the documentation.
45+
Currently along with other areas of the project, documentation is still in an early phase.
3646

3747
You can read the [online documentation](https://rustpython.github.io/website/rustpython/index.html) for the latest code on master.
3848

@@ -45,7 +55,7 @@ $ cargo doc --no-deps --all # Excluding all dependencies
4555

4656
Documentation HTML files can then be found in the `target/doc` directory.
4757

48-
If you wish to update the online documentation. Push directly to the `release` branch (or ask a maintainer to do so), this will trigger a Travis build that updates the documentation and WebAssembly demo page.
58+
If you wish to update the online documentation, push directly to the `release` branch (or ask a maintainer to do so). This will trigger a Travis build that updates the documentation and WebAssembly demo page.
4959

5060
# Code organization
5161

@@ -56,18 +66,20 @@ If you wish to update the online documentation. Push directly to the `release` b
5666
- `obj`: python builtin types
5767
- `src`: using the other subcrates to bring rustpython to life.
5868
- `docs`: documentation (work in progress)
59-
- `py_code_object`: CPython bytecode to rustpython bytecode convertor (work in progress)
69+
- `py_code_object`: CPython bytecode to rustpython bytecode converter (work in progress)
6070
- `wasm`: Binary crate and resources for WebAssembly build
6171
- `tests`: integration test snippets
6272

6373
# Contributing
6474

65-
To start contributing, there are a lot of things that need to be done.
75+
Contributions are more than welcome, and in many cases we are happy to guide contributors through PRs or on gitter.
76+
77+
With that in mind, please note this project is maintained by volunteers, some of the best ways to get started are below:
6678

6779
Most tasks are listed in the [issue tracker](https://github.com/RustPython/RustPython/issues).
6880
Check issues labeled with `good first issue` if you wish to start coding.
6981

70-
Another approach is to checkout the sourcecode: builtin functions and object methods are often the simplest
82+
Another approach is to checkout the source code: builtin functions and object methods are often the simplest
7183
and easiest way to contribute.
7284

7385
You can also simply run
@@ -81,11 +93,11 @@ To test rustpython, there is a collection of python snippets located in the
8193

8294
```shell
8395
$ cd tests
84-
$ pipenv shell
85-
$ pytest -v
96+
$ pipenv install
97+
$ pipenv run pytest -v
8698
```
8799

88-
There also are some unittests, you can run those will cargo:
100+
There also are some unit tests, you can run those will cargo:
89101

90102
```shell
91103
$ cargo test --all

azure-pipelines.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
trigger:
2+
- master
3+
4+
jobs:
5+
6+
- job: 'Test'
7+
pool:
8+
vmImage: 'vs2017-win2016'
9+
strategy:
10+
matrix:
11+
Python37:
12+
python.version: '3.7'
13+
maxParallel: 10
14+
15+
steps:
16+
- task: UsePythonVersion@0
17+
inputs:
18+
versionSpec: '$(python.version)'
19+
architecture: 'x64'
20+
21+
- script: |
22+
"C:\Program Files\Git\mingw64\bin\curl.exe" -sSf -o rustup-init.exe https://win.rustup.rs/
23+
.\rustup-init.exe -y
24+
set PATH=%PATH%;%USERPROFILE%\.cargo\bin
25+
rustc -V
26+
cargo -V
27+
displayName: 'Installing Rust'
28+
29+
- script: |
30+
set PATH=%PATH%;%USERPROFILE%\.cargo\bin
31+
cargo build --verbose --all
32+
displayName: 'Build'
33+
34+
- script: |
35+
set PATH=%PATH%;%USERPROFILE%\.cargo\bin
36+
cargo test --verbose --all
37+
displayName: 'Run tests'
38+
39+
- script: |
40+
pip install pipenv
41+
pushd tests
42+
pipenv install
43+
popd
44+
displayName: 'Install pipenv and python packages'
45+
46+
- script: |
47+
set PATH=%PATH%;%USERPROFILE%\.cargo\bin
48+
cargo build --verbose --release
49+
displayName: 'Build release'
50+
51+
- script: |
52+
set PATH=%PATH%;%USERPROFILE%\.cargo\bin
53+
pushd tests
54+
pipenv run pytest
55+
popd
56+
displayName: 'Run snippet tests'

docs/builtins.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Byterun
22

3-
* Builtins are exposted to frame.f_builtins
3+
* Builtins are exposed to frame.f_builtins
44
* f_builtins is assigned during frame creation,
55
self.f_builtins = f_locals['__builtins__']
66
if hasattr(self.f_builtins, '__dict__'):
@@ -21,10 +21,10 @@ TODO:
2121
* Implement a new type NativeFunction
2222
* Wrap a function pointer in NativeFunction
2323
* Refactor the CALL_FUNCTION case so it can call both python function and native function
24-
* During frame creation, force push a nativefunction `print` into the namespace
24+
* During frame creation, force push a native function `print` into the namespace
2525
* Modify LOAD_* so they can search for names in builtins
2626

2727
* Create a module type
2828
* In VM initialization, load the builtins module into locals
29-
* During frame creation, create a field that conatins the builtins dict
29+
* During frame creation, create a field that contains the builtins dict
3030

parser/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name = "rustpython_parser"
33
version = "0.0.1"
44
authors = [ "Shing Lyu", "Windel Bouwman" ]
55
build = "build.rs"
6+
edition = "2018"
67

78
[build-dependencies]
89
lalrpop="0.15.1"

parser/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
extern crate lalrpop;
1+
use lalrpop;
22

33
fn main() {
44
lalrpop::process_root().unwrap();

parser/src/ast.rs

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ pub enum Statement {
6565
value: Expression,
6666
},
6767
AugAssign {
68-
target: Expression,
68+
target: Box<Expression>,
6969
op: Operator,
70-
value: Expression,
70+
value: Box<Expression>,
7171
},
7272
Expression {
7373
expression: Expression,
@@ -197,7 +197,7 @@ pub enum Expression {
197197
elements: Vec<Expression>,
198198
},
199199
String {
200-
value: String,
200+
value: StringGroup,
201201
},
202202
Bytes {
203203
value: Vec<u8>,
@@ -219,9 +219,53 @@ pub enum Expression {
219219
None,
220220
}
221221

222+
impl Expression {
223+
/// Returns a short name for the node suitable for use in error messages.
224+
pub fn name(&self) -> &'static str {
225+
use self::Expression::*;
226+
use self::StringGroup::*;
227+
228+
match self {
229+
BoolOp { .. } | Binop { .. } | Unop { .. } => "operator",
230+
Subscript { .. } => "subscript",
231+
Yield { .. } | YieldFrom { .. } => "yield expression",
232+
Compare { .. } => "comparison",
233+
Attribute { .. } => "attribute",
234+
Call { .. } => "function call",
235+
Number { .. }
236+
| String {
237+
value: Constant { .. },
238+
}
239+
| Bytes { .. } => "literal",
240+
List { .. } => "list",
241+
Tuple { .. } => "tuple",
242+
Dict { .. } => "dict display",
243+
Set { .. } => "set display",
244+
Comprehension { kind, .. } => match **kind {
245+
ComprehensionKind::List { .. } => "list comprehension",
246+
ComprehensionKind::Dict { .. } => "dict comprehension",
247+
ComprehensionKind::Set { .. } => "set comprehension",
248+
ComprehensionKind::GeneratorExpression { .. } => "generator expression",
249+
},
250+
Starred { .. } => "starred",
251+
Slice { .. } => "slice",
252+
String {
253+
value: Joined { .. },
254+
}
255+
| String {
256+
value: FormattedValue { .. },
257+
} => "f-string expression",
258+
Identifier { .. } => "named expression",
259+
Lambda { .. } => "lambda",
260+
IfExpression { .. } => "conditional expression",
261+
True | False | None => "keyword",
262+
}
263+
}
264+
}
265+
222266
/*
223267
* In cpython this is called arguments, but we choose parameters to
224-
* distuingish between function parameters and actual call arguments.
268+
* distinguish between function parameters and actual call arguments.
225269
*/
226270
#[derive(Debug, PartialEq, Default)]
227271
pub struct Parameters {
@@ -312,3 +356,17 @@ pub enum Number {
312356
Float { value: f64 },
313357
Complex { real: f64, imag: f64 },
314358
}
359+
360+
#[derive(Debug, PartialEq)]
361+
pub enum StringGroup {
362+
Constant {
363+
value: String,
364+
},
365+
FormattedValue {
366+
value: Box<Expression>,
367+
spec: String,
368+
},
369+
Joined {
370+
values: Vec<StringGroup>,
371+
},
372+
}

0 commit comments

Comments
 (0)