diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..62ddfec --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,51 @@ +name: Build binaries + +on: + pull_request: + branches: + - master + push: + branches: + - master + +jobs: + linux-elf: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + - run: sudo apt-get install libsdl2-2.0-0 + - run: python -m pip install pyinstaller + - run: python -m pip install --find-links ${WHEELS} wxPython + env: + WHEELS: https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-18.04 + - run: python setup.py clean bundle + - uses: actions/upload-artifact@v2 + with: + name: PythonTurtle + path: ${{ github.workspace }}/dist/PythonTurtle + + macos-app: + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + - run: python -m pip install pyinstaller wxPython + - run: python setup.py clean bundle + - run: rm ${{ github.workspace }}/dist/PythonTurtle + - uses: actions/upload-artifact@v2 + with: + name: PythonTurtle.app + path: ${{ github.workspace }}/dist/ + + windows-exe: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + - run: python -m pip install pyinstaller wxPython + - run: python setup.py clean bundle + - uses: actions/upload-artifact@v2 + with: + name: PythonTurtle.exe + path: ${{ github.workspace }}\dist\PythonTurtle.exe diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..4b207e7 --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,28 @@ +name: Checks + +on: + pull_request: + branches: + - master + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + env: + - flake8 + - pylint + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: '3.x' + - name: Install prerequisites + run: python -m pip install --upgrade setuptools pip wheel tox + - name: Run ${{ matrix.env }} + run: tox -e ${{ matrix.env }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..875e451 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,29 @@ +name: Publish binaries and Python package + +on: + push: + tags: + - "*" + +jobs: + binaries: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + pypi: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: '3.x' + - name: Install prerequisites + run: python -m pip install --upgrade pip setuptools twine wheel + - name: Build package + run: python setup.py sdist bdist_wheel + - name: Upload to PyPI + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: twine upload dist/* diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..0601295 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,36 @@ +name: Tests + +on: + pull_request: + branches: + - master + push: + branches: + - master + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + - macos-latest + - windows-latest + python-version: + - '3.6' + - '3.7' + - '3.8' + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies for Ubuntu + if: matrix.os == 'ubuntu-latest' + run: sudo apt-get install libsdl2-2.0-0 + - name: Install prerequisites + run: python -m pip install --upgrade setuptools pip wheel tox-gh-actions + - name: Run tests + run: tox diff --git a/.gitignore b/.gitignore index 0d3ca64..c5c82e7 100644 --- a/.gitignore +++ b/.gitignore @@ -13,5 +13,7 @@ __pycache__/ # packaging artifacts /build/ /dist/ +/out/ +/PythonTurtle/ /*.egg-info /*.spec diff --git a/.pydevproject b/.pydevproject index 42a154a..56a835d 100644 --- a/.pydevproject +++ b/.pydevproject @@ -2,7 +2,7 @@ -python 2.6 +python 3.6 Default /PythonTurtle diff --git a/.travis.yml b/.travis.yml index a436fa9..0d37109 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,17 @@ --- -dist: xenial -sudo: true +os: linux +dist: bionic language: python python: - 3.6 - 3.7 +- 3.8 install: - pip install tox-travis - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then - sudo apt-get install libsdl-ttf2.0-0 + sudo apt-get install libsdl2-2.0-0 ; fi script: - tox @@ -22,13 +23,11 @@ stages: jobs: allow_failures: - - python: 3.7 - { os: osx, stage: publish } include: - { stage: lint, python: 3.6, env: TOXENV=flake8 } - { stage: lint, python: 3.6, env: TOXENV=pylint } - - { stage: test, os: osx, language: generic, env: TOXENV=py36 } - name: PyPI package stage: publish @@ -39,7 +38,7 @@ jobs: provider: pypi user: coolRR password: - secure: fdbhH+rsqfG9WfILlBZXlNNSXZVHrfBH9zWa7kKiUY55GMYKli+u/MzG1i6Ezn53Vg1wL1NTQMm5rFbbUfBE2l5/+S191saBZGApEhQZhulSkG702FCbpuGs1a26Zm+dhjyiRvuNdnPB8BA61uHSpWFzDgpLurGsZB0TyB2hZqv7LFL1eG56mKh70LTIDO5XmDh5/yDEXfc23M2nS7Zwx2xJEM047Fay/yeZSjo+LEYgCoTM/z9TftyxkyuLOGsiRoBMwL7eb7wKJzk79vSAvgZP/fSuAqc8ut1lrk1S9OIO4I9s7Zpi1QneJSGDJu4IHfV3nlge/+tlN8aeLA6GsSy/RrrzueBdtYTpbt34vO5rVfhJwjHIKTQa4GUF0R6gCiQ0JjJiXLC+UAbePZxzAKQWaxJWWpqq8L9e+LlHWpEtuB4jEqncFs6FeTT7mTWz2HMTQvvIVAsI2xFkItY4yCpE3P5+5f6UgqwqFpuKCXWF6ohQ090wTlNxN5cikNSYdPPQj7hypKzWrYcH5z4Z4pU63mnO2fZgTEZomvYKXa9mcdtZcCBhPNJW9WTgxqKSouPcjYc4me9wk4wv4ncJaCPLlxbuW7T/Nv+Xy/HYn7eljRapnu7/XcVQgB6gG4vxbRkkLkr1Ybj0xcR2neAQcxhBBqzfCyQezh210dPGqF8= + secure: lQ78pXBQXq2hgrgtlgLak15RVzMGpDJP8ncbenJgpdT0EmTc98MRvQeFsNgiwTKLvkyNZzFs1tG2LjdWX5i7DRwxoAXYObzMiexOfTd6tjQt1/KwuZDWpmMqpBmNGRxzpHbX/0gFWlZ6dY5/y5Wh9FSvXfwYzK1dkscgtdOayB3hHR6y/wOodiZa44k49q+dGKGlJnvbaDK6ngescWX+MIwV3LpiWlooB/S6sPbRg991sfuNc+tbO5LVHvlmDy6oECLqZ6uBLHKrSOZMeKULnJKWHFfUBkeb/ajzrP2O3KYD8rvMaeR9a99iQWRcIs97jLNHtcVx1OR79b49A1HnjjuxYdmksSn7sTF0YbugJJbEq0kQLtoNfOY5C+FnSfj8z2CLLAEOKUHgX/JDHoJmwVpnrY1CVLRIR3zR60RchwGO6Y7WqqjQGbpVJN1H+1kY66EXec28kycalbLVprea9YyMkvVNgu4wwiFu5O+2Td3bptqQstSmUZb+fHt334EISFcA3OEn0JEToNPP3ZjmtwJCTNEt+DViZ5gtatsxptGZr5NzJx3BENPyO3jktga1hw9nmY/pjH9Efu8TRdqzGM7WJMgeO6bBlCncwBQHz60r4AOuTFreZ3Cz7DoVDGKBYOk4oOUvbvv1BINAcRhPijSzhh46atakspBKBk0iEn4= distributions: 'sdist bdist_wheel' skip_cleanup: true on: @@ -57,7 +56,7 @@ jobs: - bash -c "mv -v out/Python*AppImage PythonTurtle.AppImage" deploy: provider: releases - api_key: "GITHUB OAUTH TOKEN" + api_key: $GITHUB_TOKEN file: PythonTurtle.AppImage skip_cleanup: true on: @@ -68,12 +67,12 @@ jobs: python: 3.6 install: - pip install PyInstaller - - pip install --find-links https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-16.04 wxPython + - pip install --find-links https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-18.04 wxPython script: - ./setup.py clean bundle deploy: provider: releases - api_key: "GITHUB OAUTH TOKEN" + api_key: $GITHUB_TOKEN file: dist/PythonTurtle skip_cleanup: true on: @@ -91,7 +90,7 @@ jobs: - ./setup.py clean bundle deploy: provider: releases - api_key: "GITHUB OAUTH TOKEN" + api_key: $GITHUB_TOKEN file: dist/PythonTurtle skip_cleanup: true on: diff --git a/README.md b/README.md index 73112fc..609b454 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,13 @@ -Python Turtle -============= +# PythonTurtle -[![Travis CI](https://img.shields.io/travis/cool-RR/PythonTurtle/master.svg?logo=travis)](https://travis-ci.org/cool-RR/PythonTurtle +[![Travis CI](https://img.shields.io/travis/PythonTurtle/PythonTurtle/master.svg?logo=travis)](https://travis-ci.org/PythonTurtle/PythonTurtle ) [![AppVeyor](https://img.shields.io/appveyor/ci/cool-RR/PythonTurtle/master.svg?logo=appveyor)](https://ci.appveyor.com/project/cool-RR/PythonTurtle -) [![GitHub issues](https://img.shields.io/github/issues-raw/cool-RR/PythonTurtle.svg)](https://github.com/cool-RR/PythonTurtle/issues -) [![GitHub PRs](https://img.shields.io/github/issues-pr-raw/cool-RR/PythonTurtle.svg)](https://github.com/cool-RR/PythonTurtle/pulls +) [![Checks](https://img.shields.io/github/workflow/status/PythonTurtle/PythonTurtle/Checks/master?label=Checks&logo=github)](https://github.com/PythonTurtle/PythonTurtle/actions?query=workflow%3AChecks +) [![Tests](https://img.shields.io/github/workflow/status/PythonTurtle/PythonTurtle/Tests/master?label=Tests&logo=github)](https://github.com/PythonTurtle/PythonTurtle/actions?query=workflow%3ATests +) [![GitHub issues](https://img.shields.io/github/issues-raw/PythonTurtle/PythonTurtle.svg)](https://github.com/PythonTurtle/PythonTurtle/issues +) [![GitHub PRs](https://img.shields.io/github/issues-pr-raw/PythonTurtle/PythonTurtle.svg)](https://github.com/PythonTurtle/PythonTurtle/pulls ) [![Python versions](https://img.shields.io/pypi/pyversions/PythonTurtle.svg)](https://pypi.org/project/PythonTurtle/ -) [![MIT license](https://img.shields.io/github/license/cool-RR/PythonTurtle.svg)](https://github.com/cool-RR/PythonTurtle/blob/master/LICENSE +) [![MIT license](https://img.shields.io/github/license/PythonTurtle/PythonTurtle.svg)](https://github.com/PythonTurtle/PythonTurtle/blob/master/LICENSE ) [![Gitter](https://img.shields.io/gitter/room/PythonTurtle/Lobby.svg)](https://gitter.im/PythonTurtle/Lobby) An educational environment for learning Python, suitable for beginners and children. @@ -14,8 +15,7 @@ Inspired by LOGO. Homepage: [http://pythonturtle.org](http://pythonturtle.org) -An Appealing Environment to Learn Python ----------------------------------------- +## An Appealing Environment to Learn Python PythonTurtle strives to provide the lowest-threshold way to learn Python. Students command an interactive Python shell (similar to the [IDLE development @@ -29,12 +29,11 @@ to students. ![Screen shot](http://pythonturtle.org/images/screenshot.gif) -Installation ------------- +## Installation Installers for Microsoft Windows and macOS are available from [pythonturtle.org](http://pythonturtle.org) and [GitHub]( -https://github.com/cool-RR/PythonTurtle/releases). +https://github.com/PythonTurtle/PythonTurtle/releases). Ubuntu Linux: @@ -60,17 +59,23 @@ If you're into automation: [Ansible tasks](https://github.com/painless-software/ansible-role-software/blob/master/tasks/education/programming.yml#L12-L43 ) for setting up PythonTurtle including a desktop shortcut for GNOME. -Compatibility -------------- +## Troubleshooting + +> ImportError: libpng12.so.0: cannot open shared object file: No such file or directory + +See https://askubuntu.com/a/978338/14650 + + +## Compatibility Tested with Python version 3.6 and wxPython version 4.0.1. Reported to run on Windows, macOS, Ubuntu Linux, and Fedora. -Development ------------ + +## Development ```bash -git clone https://github.com/cool-RR/PythonTurtle.git +git clone https://github.com/PythonTurtle/PythonTurtle.git cd PythonTurtle python3 -m pythonturtle ``` @@ -81,13 +86,31 @@ Build application bundles like this: python3 setup.py clean bundle ``` -Please [open a pull request](https://github.com/cool-RR/PythonTurtle/pulls +Please [open a pull request](https://github.com/PythonTurtle/PythonTurtle/pulls ) for contributions or bug fixes. If you can, please also add tests. -About ------ + + +## Citing PythonTurtle + +If you refer to PythonTurtle in academic work, please use this citation format: + +```bibtex +@misc{rachum2009pythonturtle, + author={Rachum, Ram and Bittner, Peter and others}, + title={PythonTurtle: A learning environment for Python suited for beginners and children, inspired by Logo}, + month={may}, + year={2009}, + publisher={GitHub}, + doi={10.5281/zenodo.10465283}, + url={https://github.com/PythonTurtle/PythonTurtle/} +} +``` + + +## License This project is licensed under the MIT license. -PythonTurtle was created by Ram Rachum as a side-project in 2009. I also provide -[freelance Django/Python development services](https://chipmunkdev.com). I [give Python workshops](http://pythonworkshops.co/) to teach people Python and related topics. ([Hebrew website](http://pythonworkshops.co.il/).) + + diff --git a/pythonturtle/__init__.py b/pythonturtle/__init__.py index a245236..2046bd5 100644 --- a/pythonturtle/__init__.py +++ b/pythonturtle/__init__.py @@ -10,6 +10,9 @@ basics of Python programming. """ name = 'PythonTurtle' -__version__ = '0.3.1' +__author__ = 'Ram Rachum and contributors' +__author_email__ = 'ram@rachum.com' __license__ = 'MIT' +__source__ = 'https://github.com/PythonTurtle/PythonTurtle' __url__ = 'http://pythonturtle.org' +__version__ = '0.3.2' diff --git a/pythonturtle/application.py b/pythonturtle/application.py index 74f4066..3eed35e 100644 --- a/pythonturtle/application.py +++ b/pythonturtle/application.py @@ -15,7 +15,7 @@ print("wxPython doesn't seem to be installed. You need to install " "the appropriate prerequisites for your operating system.") print("Please consult the installation instructions in the README at " - "https://github.com/cool-RR/PythonTurtle#installation") + "https://github.com/PythonTurtle/PythonTurtle#installation") import sys sys.exit(255) diff --git a/pythonturtle/shelltoprocess/__init__.py b/pythonturtle/shelltoprocess/__init__.py index 2a8f791..9502531 100644 --- a/pythonturtle/shelltoprocess/__init__.py +++ b/pythonturtle/shelltoprocess/__init__.py @@ -1,6 +1,6 @@ """ This package implements a wxPython shell, based on PyShell, -which controls a seperate Python process, creating with the +which controls a separate Python process, creating with the `multiprocessing` package. Here is the canonical way to use it: diff --git a/pythonturtle/shelltoprocess/forkedpyshell.py b/pythonturtle/shelltoprocess/forkedpyshell.py index 36fb94d..8a08ebb 100644 --- a/pythonturtle/shelltoprocess/forkedpyshell.py +++ b/pythonturtle/shelltoprocess/forkedpyshell.py @@ -1033,11 +1033,11 @@ def write(self, text): def fixLineEndings(self, text): """Return text with line endings replaced by OS-specific endings.""" lines = text.split('\r\n') - for l in range(len(lines)): - chunks = lines[l].split('\r') - for c in range(len(chunks)): - chunks[c] = os.linesep.join(chunks[c].split('\n')) - lines[l] = os.linesep.join(chunks) + for line in range(len(lines)): + chunks = lines[line].split('\r') + for chunk in range(len(chunks)): + chunks[chunk] = os.linesep.join(chunks[chunk].split('\n')) + lines[line] = os.linesep.join(chunks) text = os.linesep.join(lines) return text @@ -1558,7 +1558,7 @@ def OnUpdateUI(self, evt): # self.GetData() # if self.textdo.GetTextLength() > 1: # text = self.textdo.GetText() -# # *** Do somethign with the dragged text here... +# # *** Do something with the dragged text here... # self.textdo.SetText('') # else: # filenames = str(self.filename.GetFilenames()) diff --git a/setup.py b/setup.py index d35f64b..9955f00 100755 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ def run(): """ Create an application bundle (using PyInstaller) """ - import PyInstaller.__main__ + import PyInstaller.__main__ # pylint: disable=import-outside-toplevel resources_folder = os.path.join('pythonturtle', 'resources') @@ -50,8 +50,8 @@ def include_resources(file_glob): '--name=%s' % package.name, '--onefile', '--windowed', - '--add-binary=%s' % include_resources('*.ic*'), - '--add-binary=%s' % include_resources('*.png'), + '--add-data=%s' % include_resources('*.ic*'), + '--add-data=%s' % include_resources('*.png'), '--add-data=%s' % include_resources('*.txt'), '--icon=%s' % resource_path('icon.ico'), os.path.join('pythonturtle', '__main__.py'), @@ -110,15 +110,15 @@ def read_file(filename): setup( name=package.name, version=package.__version__, - license=package.__license__, - author='Ram Rachum', - author_email='ram@rachum.com', + author=package.__author__, + author_email=package.__author_email__, description=package.__doc__.strip().split('\n')[0], + license=package.__license__, long_description_content_type='text/markdown', long_description=read_file('README.md'), url=package.__url__, project_urls={ - 'Source': 'https://github.com/cool-RR/PythonTurtle', + 'Source': package.__source__, }, keywords=['turtle', 'learning', 'children', 'beginners', 'logo'], classifiers=[ @@ -134,6 +134,7 @@ def read_file(filename): 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', 'Topic :: Education', ], python_requires='>=3', diff --git a/shippable.yml b/shippable.yml deleted file mode 100644 index ff42aaf..0000000 --- a/shippable.yml +++ /dev/null @@ -1,56 +0,0 @@ ---- -resources: -- name: pythonturtle_repo - type: gitRepo - integration: github - buildOnPullRequest: true - pointer: - sourceName: cool-RR/PythonTurtle - -jobs: - -- name: windows_build - type: runSh - allowPublicAccess: true - runtime: - nodePool: dyn_win16 - steps: - - IN: pythonturtle_repo - - TASK: - name: System_info - script: - - systeminfo - - Get-Process - - pushd $(shipctl get_resource_state "pythonturtle_repo") - - choco install -y python --version 3.6.3 - - 'C:\Python36\python.exe --version' - - TASK: - name: Prerequisites - script: - - 'C:\Python36\python.exe -m pip install PyInstaller wxPython pypiwin32' - - TASK: - name: Lint - script: - - 'C:\Python36\python.exe -m tox -e flake8' - - 'C:\Python36\python.exe -m tox -e pylint' - - TASK: - name: Test - script: - - 'C:\Python36\python.exe -m tox -e py36' - - TASK: - name: Windows_exe - script: - - 'C:\Python36\python.exe setup.py clean bundle' - -- name: push_artifacts - type: runSh - allowPublicAccess: true - runtime: - nodePool: dyn_win16 - steps: - - IN: windows_build - - TASK: - name: push_artifacts_somewhere - script: - - systeminfo - - dir dist diff --git a/tox.ini b/tox.ini index 5411e8a..1679188 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,7 @@ # - Installing wxPython is non-trivial on GNU/Linux. We need to install wheels from a dedicated repository, # located at https://extras.wxpython.org/wxPython4/extras/linux/. For beackground reading see # https://wiki.wxpython.org/How%20to%20install%20wxPython#Installing_wxPython-Phoenix_using_pip -# - The wheel repository specified via --find-links below matches the build environment on Travis CI. +# - The wheel repository specified via --find-links below matches the build environment on GitHub Actions. # - For local Tox runs adapt the wheel repository URLs to match your local environment. [tox] @@ -13,30 +13,38 @@ envlist = pylint py36 py37 + py38 [testenv] +description = Unit tests deps = pytest commands = - {envpython} -m pip install --find-links https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-16.04 wxPython + {envpython} -m pip install --find-links https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-18.04 wxPython {envpython} -m pytest [testenv:flake8] -basepython = python3.6 +description = Static code analysis and code style deps = flake8 commands = {envpython} -m flake8 {posargs} [testenv:pylint] -basepython = python3.6 +description = Check for errors and code smells deps = - pyinstaller pylint + pyinstaller commands = - {envpython} -m pip install --find-links https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-16.04 wxPython + {envpython} -m pip install --find-links https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-18.04 wxPython {envpython} -m pylint --rcfile tox.ini {posargs:pythonturtle setup} +[gh-actions] +python = + 3.6: py36 + 3.7: py37 + 3.8: py38 + [flake8] exclude = .cache @@ -44,10 +52,16 @@ exclude = .tox build dist + out + PythonTurtle [pylint] disable = attribute-defined-outside-init,invalid-name,missing-docstring,no-member,self-cls-assignment,too-few-public-methods,too-many-instance-attributes,too-many-locals,too-many-statements,unused-argument,fixme,arguments-differ -reports = no [pytest] -addopts = --junitxml=tests/reports/unittests.xml --strict --verbose +addopts = + --color=yes + --ignore=PythonTurtle + --junitxml=tests/reports/unittests.xml + --strict + --verbose