25

Each Python distribution I found contains a lot of libs I don't need (numpy, scipy, PyQt etc.) I am looking for portable CPython analogue that doesn't require installation, doesn't touch anything but its directory, and is small to download over a slow or metered Internet connection.

  • I don't mean specifically http://portablepython.com/. I can choose packages to unpack manually. There is no way to make installer silent.
  • There is https://winpython.github.io/. I have to unpack 1.5GB first and uninstall unused packages.
  • PyPy -- http://pypy.org/. As far as I understand, is portable too but it seems it don't support all packages I need. (I will investigate that later.)

Why I need that. Project is required to be copy-deployed on Windows machines with no prerequisites. Second, building project directory with Python interpreter and packages (including mine) must be completely automated and should use project's repository and files that can be easily downloaded from Internet.

George Sovetov
  • 4,942
  • 5
  • 36
  • 57
  • 8
    To be honest, I don't understand why question is being downvoted. I googled a lot and tried different approaches but nothing meets exactly my goals. – George Sovetov Apr 06 '15 at 14:34
  • What's wrong with grabbing the official msi from http://python.org , installing it, then repacking it? I have not tried this, but does it not work? I guess you're looking for a maintained package that already exists? As an aside, the msi can be installed in silent mode, but it is not portable. – Preet Kukreti Apr 06 '15 at 14:56
  • 1
    @PreetKukreti I tried that but, first, couldn't install it silently because I already have a system-wide Python installation. Also, I have doubts that CPython standard installer is portable: why are there a lot of distributions claimed portable and there is no ZIP archive at python.org? – George Sovetov Apr 06 '15 at 15:01
  • It would be helpful to know why you need this (To deploy a python app on a computer where you dont have admin priviledges? or to do development on such a machine? etc). There is a way to package up libs in a zip next to executable and dll : http://stackoverflow.com/questions/2678702/install-python-2-6-without-using-installer-on-win32 Not sure if that will solve your problem, because its not entirely clear what your end goal is. – Preet Kukreti Apr 06 '15 at 15:04
  • @PreetKukreti OK. Project is required to be copy-deployed on Windows machines with no prerequisites. Second, building project directory with Python interpreter and packages (including mine) must be completely automated and should use project's repository and files that can be easily downloaded from Internet. – George Sovetov Apr 06 '15 at 15:12
  • 4
    also, now, you have "WinPython-2.7.12.3Zero" with nearly nothing out of the box. – stonebig Sep 08 '16 at 17:18
  • @stonebig It looks like exactly something I needed at that time! – George Sovetov Sep 08 '16 at 18:21
  • Added for historical interest: something that works well enough is the command line [`apt `for Osgeo4W](https://trac.osgeo.org/osgeo4w/wiki/pkg-apt/AptFromScratch). By default you're restricted to programs within the Osgeo4W packaging system, but you can build your own package repository if willing to come to grips with Cygwin setup.ini format. It can get you a barebones python install with a minimum of fuss: `set osgeo4w_root=X:\path && apt setup && apt install shell python`. (disclaimer: it's my project, still functional but largely dormant) – matt wilkie Mar 13 '17 at 19:29

2 Answers2

5

suggestion:

  • install a winpython,

  • remove all packages you don't want,

  • add all packages you want,

  • zip the result, and unzip it on any PCs.

stonebig
  • 1,193
  • 1
  • 9
  • 13
  • I did exactly the same. But, as I mentioned before, it cannot be easily automated. Need a lot of time, disk space and many of packages to delete. – George Sovetov Apr 06 '15 at 20:17
  • Here's a more specific suggestion to what I offered earlier. Install Python and prep it for customization on a host computer. This will allow you to package it for later, effectively solving the initial "large" space requirement. There's got to be some CLI flags you can use to minimize the installation. If not, you can uninstall packages or progs using native powershell/batch commands. This can be put into a `.py`, `.ps1`, `.bat` script for automation. From here, I agree w/ StoneBig, zip it up for the target. You can further automate unzipping/execution using more `.py`, `.bat`, `.ps1` –  Apr 06 '15 at 21:12
  • It's been working very well for me. – ozgur May 09 '16 at 11:47
  • i downloaded winpython and ran `setup.py`. i don't see any python.exe in the folder. how can i add/remove packages and run a script ? – mrid May 01 '18 at 10:25
  • "WinPython Command Prompt.exe" to go to command line – stonebig May 01 '18 at 12:54
  • "pip list" to see installed packages – stonebig May 01 '18 at 12:55
  • "pip uninstall a_package " to remove a_package – stonebig May 01 '18 at 12:55
  • "pip install another_package" to install another_package. – stonebig May 01 '18 at 12:55
  • Script\upgrade_pip.bat to upgrade pip without loosing the ability to move the winpython directory, if you feel the annoyance – stonebig May 01 '18 at 12:58
-2

There is Portable Python. But as you said, it comes with some extra (and very useful) libs. What's wrong with this extra libs? I mean, if you will not use, just leave there.

Mauro Baraldi
  • 6,346
  • 2
  • 32
  • 43
  • 1
    Thanks for your answer. Despite libraries are very useful, I don't need them. For example, unpacked WinPython contains 28k files having total size of 1.5TB. Storage is cheap but internet broadband is not. Copying and archiving all of that take a long time. That's why I need something smaller. – George Sovetov Apr 06 '15 at 13:53
  • Take a look at [here](https://groups.google.com/forum/#!searchin/portablepython/remove$20libs/portablepython/LUA_qKUCbDA/WeS9E6Ue__QJ) – Mauro Baraldi Apr 06 '15 at 13:59
  • Great, Portable Python allows to choose packages to unpack. Maybe, is there any way to unpack it silently? – George Sovetov Apr 06 '15 at 14:16
  • I believe that a good approach should be unpack only what you need, re-pack and distribute. ;-) – Mauro Baraldi Apr 06 '15 at 14:18
  • I came up with that already using WinPython but anyway, it would be very nice to have process fully automated. There is a problem to solve and this question. I am looking for a way to solve latter :) – George Sovetov Apr 06 '15 at 14:25
  • I don't think you're going to be able to get the results you're looking for without some customization on your part. I can suggest `www.Cameyo.com` (still going to include extra libs but it will be portable and customizable). You can use `py2exe` to automatically filter out and include ONLY the libs/dependancies being used by your specific script. It would also be helpful to know the intended implementation of your .py script because there's probably windows PowerShell, native commands, progs, etc... you can include in your `.py` to "trim the fat" regarding dependencies and requirements. –  Apr 06 '15 at 15:21
  • @George: "having total size of 1.5TB" - jesus crap what!? That's four times the size of my drive and 30,000 times the size of my Python installation. – user2357112 Apr 06 '15 at 19:15
  • @user2357112 I meant 1.5 GB. Sorry :-) – George Sovetov Apr 06 '15 at 20:14
  • @BiTinerary I'll take a look at that. Thanks for suggestion. I'm going to install some packages anyway. py2exe is probably good tool but I need merely Python portable interpreter. – George Sovetov Apr 06 '15 at 20:22
  • 4
    -1 for persuading OP against his "small to download over a slow or metered Internet connection" requirement, to like those "very useful libraries" instead. ;-p (Well, the answer may have been posted before OP added that requirement, but still: I appreciate OP's effort to find a "frugal" solution, if exists, and dislike the approach suggested. *Gigantic* masses of unused crap tend to grow quickly on the fertile soil of ignorance on all the machines I can see around, and disagree with the implied "buy bigger storage, it's cheap" argument.) – Sz. Jan 03 '16 at 22:14