MrYsLab / s3-extend

Control an Arduino Uno, Circuit Playground Express, Raspberry Pi Pico, ESP-8266, ESP-32, Picoboard, Robohat MM1, or Rasberry Pi From Scratch 3
GNU Affero General Public License v3.0
28 stars 13 forks source link

ABSOLUT PATH ON S3A #46

Closed Lusher92 closed 5 months ago

Lusher92 commented 5 months ago

Hello,

I'm a french student doing an internship and I'm developing a software that allows us to use scratch with an arduino board. We import s3-extand and pigpio but the problem is that the s3-extand path seems to be absolute and prevents us from embedding our python. Is there a way around this problem?

Best regards Guillaume DŒUVRE

MrYsLab commented 5 months ago

Hi, I am assuming you are referring to the s3a script's execution path. The path is selected by the Python setuptools when an installation is performed. The pyproject.taml file specifies "project.scripts" to create command line executables. Setuptools creates the command line executable files that are specific to the operating system that is being used. It also specifies where the executables are installed. For example, when I install s3-extend in a virtual environment on my RPi4, here is what I see when I run "which" for s3a:

(myvenv) afy@RPi4:~/myvenv/s3extend $ which s3a
/home/afy/myvenv/bin/s3a

Could you please explain how the path is preventing you from modifying s3-extend? I would be happy to help you find a solution to your problem, but I first need to understand the specifics of the problem.

Lusher92 commented 5 months ago

Hi,

I don't have a pyproject.taml file, but I do have a pyprojecttaml.py file which doesn't specify "project.scripts". However, we have a python312._path file that we've modified to add paths :

python312.zip
.
.\Lib
.\Lib\site-packages
.\Scripts

# Uncomment to run site.main() automatically
#import site

I'm using python 3.12, could this be the problem?

I'll tell you more about what we did during the python configuration:

In PC1, I use the python embed zip : https://www.python.org/ftp/python/3.12.3/python-3.12.3-embed-amd64.zip In PC2, I used the python installer : https://www.python.org/ftp/python/3.12.3/python-3.12.3-amd64.exe

First of all, everything runs correctly locally. We take our PC1 computer, we create a portable python, with pip we install the extensions then we run "s3a.exe" with cmd from its folder.

image

To check its portability, we follow the same steps but on a different machine, PC2. We create our portable python directly in a USB key called "LA_BLEU". The same windows open as on our PC1 to show us that everything works. We come back to our PC1, insert the USB key LA_BLEU, python is working, so we try to run s3a.exe without success.

image

To make sure the problem doesn't come from installing Python on the LA_BLEU USB key, we take our portable python that we created on PC1 and move it to our other USB key called LA_VERTE.

image

However, we suspect that python has created dependencies, so we test the portability of our python on a VIRGIN PC. We connect LA_VERTE to our VIRGIN PC and we test Python :

image

Ok, python is working, so we run s3a.exe :

image

We find the same error as with the LA_BLEU key.

I hope I've been clear in my explanations, thanks again for helping me.

MrYsLab commented 5 months ago

Thanks for the detailed information.

You will need to create a virtual environment on the USB stick. Information about virtual environments can be found here, and here are the steps to do so:

  1. After installing embedded Python on the USB stick, type the following command on the USB drive:

    py -m venv .venv
  2. Activate the virtual environment:

    .venv\Scripts\activate
  3. Install s3-extend

    pip install s3-extend

After the installation is completed, you should be able to run s3a.

So you know, the drive letter for the USB stick must be the same when plugging it in from one computer to another. If you did the installation above on drive D: then if you use the same USB stick on another computer, it must also assign the USB stick the same drive letter—in this case, D:.

Also, as shown in step 2 above, you must activate the virtual environment each time you power up the computer or close the terminal window.

You might be able to put that in a .bat file.

Please let me know if this solves your issue, and if so, please close the issue.

MrYsLab commented 5 months ago

I am closing this issue. If you have any further questions about it, please enter them here, and I will look at them.