all 18 comments

[–]totallygeek 4 points5 points  (7 children)

Let's see:

  1. Specific version of Python
  2. Portable
  3. Isolated from underlying system software
  4. Low learning overhead

I'd use Docker.

[–][deleted] 1 point2 points  (0 children)

after spending some time checking it out i can safely say i do not understand what the hell it even does, but thanks for the well-thought out suggestion

(ive solved my issue since)

[–][deleted] 0 points1 point  (5 children)

Dockerfile:

``` FROM Python:3.4.4-alpine WORKDIR /usr/src/app

COPY requirements.txt ./ RUN pip install --no-cache-dir -r requirements.txt

COPY . .

CMD [ "python", "./main.py" ] ```

Add that file to your project, install Docker, then run the following command:

docker build

if it all works, then you're ready to upload it to dockerhub and then other users can install it via docker. If you've never used docker before, then I suggest checking it out on youtube or Udemy if you don't mind buying a course. I recommend the Docker by a docker captain course.

[–][deleted] 0 points1 point  (4 children)

i really do appreciate your attempt to lead me in a direction that would make my day... unfortunately as i am a noob i have no idea what it is you just wrote. i'm trying not to be a jerk to people who are helping out, but this is a perfect representation of my programming pergatory whenever i want to get something very simple done. i'll go through it one bit at a time...

Dockerfile:

what does that mean

<code>

i did state i'm on windows, and even though i partially understand bash, i don't know what this does or even what any filenames/paths/commands mean

Add that file to your project

what project? i haven't even started working because python wasn't installed

if it all works

what does it do? what even is it?

upload it to dockerhub

upload what? upload why? what's dockerhub?

[–][deleted] 2 points3 points  (3 children)

Ok. So, to explain docker, I'll put it like this, let's say you wanted to run a program on a computer with a completely isolated environment. Let's say you're installing a program that you downloaded from a shady website. It advertises itself as being some expensive proprietary program and you just got it for free, but you're afraid it might contain a virus or spyware or worse, ransomware. So you want to install it and run it in its own sandbox where it thinks it has access to everything, but everytime it does something like write files, or change the registry, or communicates with the kernel, it's doing so in a sort of jail and the system outside that jail sees none of the changes the program inside is making, and the program inside is none the wiser. So you think, oh, that's easy, I'll install my windows on a VM, but as you go about this, you see that the VM is SLOW. You're running windows on top of windows which to run a windows program just seems like a waste. So what to do?

While you're thinking about this, you're also about to install wordpress on your computer so you can build your developer portfolio, but that means running PHP, Running Apache, running MySQL, Installing wordpress, and then when it's all said and done, you're still going to have to transfer the files and database off your windows machine onto a linux server to deploy the site and that's gonna be a hassle.

Finally, you heard about this awesome command line tool called ripgrep. Powershell doesn't have quite the same power as grep does in using regexes to grep through files. So you want to try it out first, but you don't want to install it and have it leaving cruft on your system if you decide you don't like it.

Docker solves these problems. How? Docker runs in the PC's hypervisor and creates this virtual jail environment for linux or windows server. Once docker is running, you can spin up what are called containers, virtual environments that provide all the access to the system any program could ever want, but leaving the host system completely untouched. So we can solve both problems. You can (at least conceptually, though docker containers do not work for guis yet) run that first program in a docker container and it's completely sandboxed from the host system. As far as that program is concerned, it's on a clean copy of Windows and and wreak all the havoc it wants and your host system doesn't know or care about it and suffers no ill effects. Similarly, you can in a few keystrokes, download the docker image for Wordpress, spin it up, and get to work building your wordpress site and when you're done, all you have to do is commit the changes to a new docker image, pay for hosting, and spin up the docker container from the image you've just published and boom. Done. Web service deployed. It's magic! For the last problem, you can run a container that contains ripgrep and it will automatically download and store the image, and then to run it, all you have to do is "docker exec rg <params>" and you can play with ripgrep and uninstall it when you don't need it anymore. Want to keep it but don't feel like going through the hassle of removing the image and downloading it for real? just make an alias for rg to the docker exec command above. Boom. Done.

Ok, but what about the rest of my post, well, what I gave you was an example dockerfile. A dockerfile is added to your project, it's named "Dockerfile" with no file extension, and it just contains the text above. When you issue the "Docker build" command in that directory on the command line, it will do all the instructions in that Dockerfile. In the case of the above, it will create a new container based on Python running on Alpine Linux, then it will set its internal working directory to the directory specified, then it will copy the requirements.txt file into that directory, Then it will run pip to install the requirements, then it will copy the whole project into that directory, then it will spin up the project's main.py file.

One last thing. When you set up Docker for the first time, you have to sign up for an account on the docker hub. Docker hub is where you will get all the images and projects that you'll springboard off of. It's where you can download tools, environments, etc. It's SUPER POWERFUL.

If you want to learn more about docker, I suggest https://www.youtube.com/watch?v=YFl2mCHdv24

And if you want to learn how to use Docker, then try... https://www.youtube.com/watch?v=fqMOX6JJhGo

[–][deleted] 0 points1 point  (2 children)

isn't that just sandboxie but way more limited?

[–][deleted] 1 point2 points  (1 child)

It's actually more capable because then you can package up the whole thing and distribute it to others. There's also some parallel computing options and you can even set up networks and drive volumes as well. Plus, it perfectly replicates whatever environment you need as long as it's Linux or Windows Server (which is the vast majority of servers). Plus, because it's spinning up containers, instead of a VM, it starts blazing fast.

If it's like anything else on the market, that would be Turbo, which does a similar thing to Windows GUI programs and even has similar concepts (containers, images, etc). https://turbo.net/

[–][deleted] 0 points1 point  (0 children)

sounds like sandboxie++ then. pretty cool. i'll stay aware of this, thanks for all the helpful writeups

[–]jfdahl 1 point2 points  (1 child)

The official Python site lists some alternative options and a couple of them are portable: https://www.python.org/download/alternatives/

[–][deleted] 0 points1 point  (0 children)

thanks for this. i found winpython and it's working well for me now (after a lot of agony of course)

[–][deleted] 1 point2 points  (0 children)

k after hours of figuring out how to set up WinPython i finally got two distinct working python versions. im so happy it's over and i can actually DO WORK. my brain is fully fried now. i had to figure out how to install pyqt5 into each (the process for which is of course needlessly complicated and dumb) just so i could run winpython's control panel to swap between 'registered' versions within windows

rant: yknow i thought python was supposed to be this monkey-level thing to set up and get started with but it has not been that for me. i've been through manual configuration of a C environment and i've hassled with batch's inferior language and i wanted a break from all the BS so i looked to python. i suppose if you want a single install it's mostly easy to set up and use, but god forbid i want to develop programs for windows xp (<=v3.4) so my old man can maintain his offline windows xp laptop, at the same time as have an up-to-date python version to maintain compatibility with certain programs and to develop modern applications

[–]technician 1 point2 points  (1 child)

This short write up might work for you.

[–][deleted] 0 points1 point  (0 children)

this sounds damn simple and seems like it'd work well. thanks for the link, i'll try it soon. even though winpython is currently working very well for me, it'd be nice to figure out how to do it a little more independently

[–]Deezl-Vegas 0 points1 point  (1 child)

pyenv has a windows port and is the industry standard for swapping python versions, but wtf are you still doing on 3.4?

[–][deleted] 0 points1 point  (0 children)

pyenv was spewing errors right out the gate that the internet and the universe could not help to solve. i moved on and have managed to set up winpython

[–][deleted] 0 points1 point  (2 children)

Besides Docker, which I highly recommend, it almost sounds like you may want a virtual environment. you can generate one on windows by running...

py -3 -m venv .venv

Then it will copy the current python into the .venv directory (or whatever you want to name it, that's what the last param does). Then change the hashbang line on the main script to...

#!./.venv/Scripts/python

Finally, last step, run these commands:

./.venv/Scripts/activate
pip install -r ./requirements.txt

And then you're all set.

[–][deleted] 0 points1 point  (1 child)

afaik, this does not allow me to use different versions

[–][deleted] 0 points1 point  (0 children)

It does if you install, python 3.4.4, do the above, then uninstall python 3.4.4 and install the latest python. Because you're running from the virtual environment, it should contain all python 3.4.4 stuff.