MrYsLab / s2m

Scratch to micro:bit bridge.
https://mryslab.github.io/s2m/
GNU Affero General Public License v3.0
35 stars 19 forks source link

Add a script to auto install and launch s2m under Windows #21

Closed lyshie closed 6 years ago

lyshie commented 6 years ago

It is difficult to launch s2m program without the correct path name. I created a simple script to launch s2m and do something automatically. Maybe it would be helpful for one-click installation.

  1. determine the the version of installed Python3 (32-bit or 64-bit)
  2. check if Python3 is installed
  3. auto install s2m and uflash
  4. upload s2mb_min.py to Micro:Bit using uflash
  5. launch s2m and Scratch2
MrYsLab commented 6 years ago

In testing the Windows version, after the install, s2m.exe is not installed and I can only launch s2m through the cmd file.

Is there a way to have the script install s2m.exe as well?

If I install s2m using

pip install s2m --upgrade

s2m .exe will be installed.

For the linux version, I corrected a typo and then ran the script. Here is my output:

afy@afy-VirtualBox:~$ ./linux_s2m.sh
Collecting s2m
  Using cached s2m-2.5-py2.py3-none-any.whl
Requirement already up-to-date: pyserial>=2.7 in /usr/local/lib/python3.6/site-packages (from s2m)
Requirement already up-to-date: psutil in ./.local/lib/python3.6/site-packages (from s2m)
Installing collected packages: s2m
Successfully installed s2m-2.5
Requirement already up-to-date: uflash in ./.local/lib/python3.6/site-packages
Error flashing /home/afy/.local/lib/python2.7/site-packages
 (doesn/s2m/micro_bit_scripts/s2mb_min.py to microbit: [Errno 2] No such file or directory: '/home/afy/.local/lib/python2.7/site-packages\n (doesn/s2m/micro_bit_scripts/s2mb_min.py'

s2m version 2.5  Copyright(C) 2018 Alan Yorinks  All rights reserved.

Python Version 3.6.0 (default, Jan 11 2017, 14:11:08) 
[GCC 4.8.4]
Autodetecting serial port. Please wait...
Using COM Port:/dev/ttyACM0

s2mb Version: s2mb.py Version 1.08 5 April 2018

Auto launching Scratch
Starting HTTP Server!
/bin/sh: 1: /opt/Scratch: not found
/bin/sh: 2: Syntax error: end of file unexpected (expecting ")")
Use <Ctrl-C> to exit the extension.
Please make sure you save your Scratch project BEFORE pressing Ctrl-C.

If I install using

sudo pip3 install s2m

Here is where things are installed

/usr/local/lib/python3.6/site-packages/s2m

Using the script, things are installed in

~/.local/lib/python3.6/site-packages/s2m

.local is not on my path

lyshie commented 6 years ago

I tested these scripts in Fedora 27 and Windows 10. In Linux, without the root permission, user should install s2m in their user home.

  1. global install (root permission) $ sudo pip install s2m /usr/lib/python2.7/site-packages/s2m
  2. user install $ pip install --user s2m /home/lyshie/.local/lib/python2.7/site-packages/s2m

In Windows 10, the default installation path of python 3.6 (python-3.6.5-amd64) is C:\Users\user\AppData\Local\Programs\Python\Python36\python.exe and %localappdata% is mapping to C:\Users\{username}\AppData\Local.

  1. gloabl install (%localappdata%) > pip install s2m C:\Users\user\AppData\Local\Programs\Python\Python36\Lib\site-packages\s2m C:\Users\user\AppData\Local\Programs\Python\Python36\Scripts\s2m.exe

  2. user install (%appdata%) > pip install --user s2m C:\Users\user\appdata\roaming\Python\Python36\site-packages\s2m C:\Users\user\appdata\roaming\Python\Python36\Scripts\s2m.exe

MrYsLab commented 6 years ago

BTW Thanks for the efforts. I am still not understanding a few things. The way s2m currently works is for the user to open up a terminal window and type "s2m" after a pip install.

This no longer works for either Windows or Linux (at least on Ubuntu) after running the scripts.

  1. Is this your intention or should s2m still be able to start by typing s2m?

  2. There is a problem with the Linux script in that it does not install the s2m blocks into Scratch.

  3. How does the user get the install scripts? Do they download the .zip flle from github, extract it and then execute it?

lyshie commented 6 years ago

I thought that only the users who installed s2m in their user home may use these scripts. If the path of s2m did not in default $PATH value, it can't be launched by typing s2m directly.

$ pip install s2m The location of s2m executable file is /usr/bin/s2m or /usr/local/bin/s2m. Install s2m in global site packages directory, it worked fine. I should close this request.

MrYsLab commented 6 years ago

Thanks. I really do appreciate your efforts and your idea was a good one, but it can lead to a lot of unforeseen issues. Please feel free to propose any other ideas you have and I would be glad to incorporate them if possible.