Skip to content

Commit

Permalink
Merge branch 'master' into pyqt6
Browse files Browse the repository at this point in the history
  • Loading branch information
JeongJun-Lee committed Nov 17, 2024
2 parents 56d72aa + f76006b commit 3cf7414
Show file tree
Hide file tree
Showing 97 changed files with 4,824 additions and 2,270 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
pip list
- run: mkdir upload
- name: Build Linux AppImage
run: xvfb-run make linux
run: QT_QPA_PLATFORM=offscreen make linux
# GitHub actions upload artifact breaks permissions, workaround using tar
# https://github.com/actions/upload-artifact/issues/38
- name: Tar AppImage to maintain permissions
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
analyze:
timeout-minutes: 20
name: Analyze
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
permissions:
actions: read
contents: read
Expand Down
29 changes: 20 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,17 @@ jobs:
timeout-minutes: 30
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-latest, macos-11, macos-latest, windows-2019, windows-latest]
python-version: ['3.8', '3.9', '3.10', '3.11']
# macos-13 is the latest release on x86, and macos-14 is arm64
os: [ubuntu-20.04, ubuntu-latest, macos-11, macos-13, macos-14, windows-2019, windows-latest]
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
exclude:
# These Python versions are not available in macOS arm64
- os: macos-14
python-version: '3.7'
- os: macos-14
python-version: '3.8'
- os: macos-14
python-version: '3.9'
fail-fast: false
runs-on: ${{ matrix.os }}
name: Test Py ${{ matrix.python-version }} - ${{ matrix.os }}
Expand Down Expand Up @@ -103,7 +112,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
docker-tag: ['buster-2021-05-28', 'buster-legacy-2022-04-07']
docker-tag: ['buster-2021-05-28', 'buster-legacy-2023-05-03', 'bullseye-2023-05-03']
fail-fast: false
services:
rpios:
Expand All @@ -115,7 +124,7 @@ jobs:
- name: Wait 2m30s for the docker image to start up QEMU and Raspberry Pi OS
run: sleep 150
- name: Clone project & setup it as the bash entry directory
uses: appleboy/ssh-action@master
uses: appleboy/ssh-action@v1.0.0
with:
host: rpios
username: pi
Expand All @@ -130,7 +139,7 @@ jobs:
echo "cd ~/mu" > ~/.bashrc_new && cat ~/.bashrc >> ~/.bashrc_new
rm ~/.bashrc && mv ~/.bashrc_new ~/.bashrc
- name: Install Mu extra apt dependencies
uses: appleboy/ssh-action@master
uses: appleboy/ssh-action@v1.0.0
with:
host: rpios
username: pi
Expand All @@ -140,22 +149,24 @@ jobs:
sudo apt-get update
sudo apt-get install -y python3-virtualenv
- name: Create venv and install Python dependencies
uses: appleboy/ssh-action@master
uses: appleboy/ssh-action@v1.0.0
with:
host: rpios
username: pi
password: raspberry
port: ${{ job.services.rpios.ports[5022] }}
command_timeout: 20m
# Some compiled packages take a while to be built in piwheels, so to
# avoid intermittent pip install failures we use `--prefer-binary`
script: |
python3 -m virtualenv ~/mu/.venv -v --python=python3 --system-site-packages
echo "source ~/mu/.venv/bin/activate" > ~/.bashrc_new && cat ~/.bashrc >> ~/.bashrc_new
rm ~/.bashrc && mv ~/.bashrc_new ~/.bashrc
source .venv/bin/activate
python -m pip list
python -m pip install ."[dev]"
python -m pip install ."[dev]" --prefer-binary
- name: Environment info
uses: appleboy/ssh-action@master
uses: appleboy/ssh-action@v1.0.0
with:
host: rpios
username: pi
Expand All @@ -168,7 +179,7 @@ jobs:
python3 -m pip --version
python3 -m pip list
- name: Run tests
uses: appleboy/ssh-action@master
uses: appleboy/ssh-action@v1.0.0
with:
host: rpios
username: pi
Expand Down
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ include mu/resources/css/*
include mu/resources/images/*
include mu/resources/fonts/*
include mu/resources/pygamezero/*
include mu/resources/pico/*
include mu/resources/neopia/*
recursive-include mu/resources/web *
include run.py
recursive-include mu/locale *
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ macos: check
# 1. Not really needed.
# 2. Previously active venv would be "gone" on venv-pup deactivation.
# Installing pup from a fork with the --pip-platform flag proof of concept
# and using it to install wheels for the `macosx_10_12_x86_64` platform
# and using it to install wheels for the `macosx_10_15_x86_64` platform
./venv-pup/bin/pip install git+https://github.com/carlosperate/pup.git@pip-platform
./venv-pup/bin/pup package --launch-module=mu --nice-name="Mu Editor" --icon-path=./package/icons/mac_icon.icns --license-path=./LICENSE --pip-platform=macosx_10_12_x86_64 .
./venv-pup/bin/pup package --launch-module=mu --nice-name="Mu Editor" --icon-path=./package/icons/mac_icon.icns --license-path=./LICENSE --pip-platform=macosx_10_15_x86_64 .
rm -r venv-pup
ls -la ./build/pup/
ls -la ./dist/
Expand Down
56 changes: 37 additions & 19 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,26 +1,44 @@
Mu - A Simple Python Code Editor
Custom Mu - Custom version of A Simple Python Code Editor `Mu <https://madewith.mu/>`_
================================

.. image:: https://mu.readthedocs.io/en/latest/_images/logo.png
[How to make dev env.]

1. install miniconda

``https://docs.conda.io/projects/miniconda/en/latest/miniconda-install.html``

2. Create virtual environment

``conda create -n mu python=3.8``

3. Activate the created virtual env.


``conda activate mu``

4. Clone source codes

``git clone https://github.com/roboticsware/mu``

5. Enter the directory of source codes


``cd mu``


6. Install dev dependencies

``pip install -e ".[dev]"``

7. Run Mu


``python run.py``

8. Build Mu

``make win64 or macos``


You can also reivew more information about extensive developer documentation `here <https://mu.readthedocs.io/>`_.

Mu is a simple code editor for beginner programmers based on extensive feedback
from teachers and learners. Having said that, Mu is for anyone who wants to use
a simple "no frills" editor.

Mu is a modal editor with modes for many different ways to use Python to create
cool and interesting things.

Mu is written in Python and works on Windows, macOS, Linux and Raspberry Pi.
The project's public facing website is
`https://codewith.mu/ <https://codewith.mu/>`_. We celebrate the work done by
users of mu at `https://madewith.mu/ <https://madewith.mu/>`_.

We have `extensive developer documentation <https://mu.readthedocs.io/>`_
including a guide for
`setting up a development environment <https://mu.readthedocs.io/en/latest/setup.html>`_,
`contributor guidelines <https://mu.readthedocs.io/en/latest/contributing.html>`_ and
`some suggested first steps <https://mu.readthedocs.io/en/latest/first-steps.html>`_.

We want our community to be a friendly place. Therefore, we expect contributors
and collaborators to follow our
`Code of Conduct <https://mu.readthedocs.io/en/latest/code_of_conduct.html>`_.
2 changes: 1 addition & 1 deletion mu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
__title__ = "mu-editor"
__description__ = "A simple Python editor for beginner programmers."

__version__ = "1.2.3"
__version__ = "1.2.7"

__license__ = "GPL3"
__url__ = "https://github.com/mu-editor/mu"
Expand Down
3 changes: 3 additions & 0 deletions mu/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,9 @@ def load_theme(theme):
find_again_handlers = (editor.find_again, editor.find_again_backward)
editor_window.connect_find_again(find_again_handlers, "F3")
editor_window.connect_toggle_comments(editor.toggle_comments, "Ctrl+K")
editor_window.connect_close_tab(editor.close_tab, "Ctrl+W")
editor_window.connect_move_forward_tab(editor.move_forward_tab, "Ctrl+.")
editor_window.connect_move_backward_tab(editor.move_backward_tab, "Ctrl+,")
editor.connect_to_status_bar(editor_window.status_bar)

# Restore the previous session along with files passed by the os
Expand Down
32 changes: 17 additions & 15 deletions mu/contrib/microfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def get_serial():
return Serial(port, SERIAL_BAUD_RATE, timeout=1, parity="N")


def execute(commands, serial=None):
def execute(commands, serial=None, show_progress=False, callback=None):
"""
Sends the command to the connected micro:bit via serial and returns the
result. If no serial connection is provided, attempts to autodetect the
Expand All @@ -139,17 +139,22 @@ def execute(commands, serial=None):
raw_on(serial)
time.sleep(0.1)
# Write the actual command and send CTRL-D to evaluate.
for command in commands:
total_size = len(commands)
for cnt, command in enumerate(commands):
command_bytes = command.encode("utf-8")
# Up to 32 bytes can be stored separately in both transmit and receive modes of the UART
for i in range(0, len(command_bytes), 32):
serial.write(command_bytes[i : min(i + 32, len(command_bytes))])
time.sleep(0.01)
serial.write(b"\x04")
serial.write(b"\x04") # Soft Reset with CTRL-D
response = serial.read_until(b"\x04>") # Read until prompt.
out, err = response[2:-2].split(b"\x04", 1) # Split stdout, stderr
result += out
if err:
return b"", err
if len(response) > 3: # Check if the split is possible
out, err = response[2:-2].split(b"\x04", 1) # Split stdout, stderr
result += out
if err:
return b"", err
if show_progress:
callback.emit(round(cnt / total_size * 100))
time.sleep(0.1)
raw_off(serial)
if close_serial:
Expand Down Expand Up @@ -204,7 +209,7 @@ def rm(filename, serial=None):
return True


def put(filename, target=None, serial=None):
def put(self, filename, target=None, serial=None):
"""
Puts a referenced file on the LOCAL file system onto the
file system on the BBC micro:bit.
Expand All @@ -214,7 +219,7 @@ def put(filename, target=None, serial=None):
Returns True for success or raises an IOError if there's a problem.
"""
if not os.path.isfile(filename):
if os.path.isdir(filename) or not os.path.isfile(filename):
raise IOError("No such file.")
with open(filename, "rb") as local:
content = local.read()
Expand All @@ -230,13 +235,13 @@ def put(filename, target=None, serial=None):
commands.append("f(" + repr(line) + ")")
content = content[64:]
commands.append("fd.close()")
out, err = execute(commands, serial)
out, err = execute(commands, serial, True, self.on_put_update_file)
if err:
raise IOError(clean_error(err))
return True


def get(filename, target=None, serial=None):
def get(self, filename, target=None, serial=None):
"""
Gets a referenced file on the device's file system and copies it to the
target (or current working directory if unspecified).
Expand Down Expand Up @@ -270,12 +275,9 @@ def get(filename, target=None, serial=None):
"while result:\n result = r(32)\n if result:\n u.write(result)\n",
"f.close()",
]
out, err = execute(commands, serial)
out, err = execute(commands, serial, True, self.on_put_update_file)
if err:
raise IOError(clean_error(err))
# Recombine the bytes while removing "b'" from start and "'" from end.
with open(target, "wb") as f:
f.write(out)
return True


Expand Down
6 changes: 3 additions & 3 deletions mu/interface/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def setup(self, modes, current_mode):
for name, item in modes.items():
if not item.is_debugger:
litem = ModeItem(
item.name, item.description, item.icon, self.mode_list
item.name, _(item.description), item.icon, self.mode_list
)
if item.icon == current_mode:
self.mode_list.setCurrentItem(litem)
Expand Down Expand Up @@ -585,7 +585,7 @@ def setup(self, log, settings, packages, mode, device_list):
self.log_widget = LogWidget(self)
self.log_widget.setup(log)
self.tabs.addTab(self.log_widget, _("Current Log"))
if mode.short_name in ["python", "web", "pygamezero", "neobot"]:
if mode.short_name in ["python", "web", "pygamezero", "neopia"]:
self.envar_widget = EnvironmentVariablesWidget(self)
self.envar_widget.setup(settings.get("envars", ""))
self.tabs.addTab(self.envar_widget, _("Python3 Environment"))
Expand All @@ -596,7 +596,7 @@ def setup(self, log, settings, packages, mode, device_list):
settings.get("microbit_runtime", ""),
)
self.tabs.addTab(self.microbit_widget, _("BBC micro:bit Settings"))
if mode.short_name in ["python", "web", "pygamezero", "neobot"]:
if mode.short_name in ["python", "web", "pygamezero", "neopia"]:
self.package_widget = PackagesWidget(self)
self.package_widget.setup(packages)
self.tabs.addTab(self.package_widget, _("Third Party Packages"))
Expand Down
3 changes: 3 additions & 0 deletions mu/interface/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ class EditorPane(QsciScintilla):
open_file = pyqtSignal(str)
# Signal fired when a context menu is requested.
context_menu = pyqtSignal()
# Signal fired when a text selection is changed.
selected_text = pyqtSignal(str)

def __init__(self, path, text, newline=NEWLINE):
super().__init__()
Expand Down Expand Up @@ -511,6 +513,7 @@ def highlight_selected_matches(self):
# valid identifier-type word.
#
selected_text = self.selectedText()
self.selected_text.emit(selected_text)
if not RE_VALID_WORD.match(selected_text):
return

Expand Down
Loading

0 comments on commit 3cf7414

Please sign in to comment.