How to create a shareable python install? - windows

Is there a way to have an easily shareable python install? I have a python install on my PC, and sometimes coworkers want to use and modify my code. To do so, they often need to replicate my python config. Is there a way I could easily share my config with them? From another angle, is there a way I could send my code so it can be run with a clean install of Python?

Have you tried using virtualenv ? I think it will meet your need to share your python environment after you have customized it to run your code.

As #Jeff Mercado mentionned, Portable Python is the way to go for me. I can zip my whole python install into one file and share it. It contains all the libraries I need.

Related

Making a portable version of Robotframework and RIDE, how to make it clean?

I want to adapt Robotframework and RIDE to be able to use them on a USB key. In order to achieve this, I planned to use a Portable Version of Python on which I would install all necessary modules using pip.
The main advantage of Portable Python is that it doesn't required any installation on the user's computer, they just have to use the Console executable provided by Portable Python to access Python and its modules. A simple insertion of the USB key, and the user would have access to the modules.
Let's say I install Portable Python on a USB key, located on E:\. Using E:\PortablePython\Console-Launcher.exe which uses command-lines code with all Python related files in the PATH, I manage to install all necessary packages for RobotFramework and RIDE with pip. For example, we can find the robot.exe in E:\PortablePython\App\Python\Scripts and the python exe is in E:\PortablePython\App\Python\python.exe like a usual installation of Python.
Everything works like a charm here, I can run my tests without any issue. The problems come when the key is moved. If I try to run ride on D:\:
D:\PortablePython>ride.py
Unable to create process using 'E:\PortablePython\App\Python\python.exe "D:\App\Python\Scripts\ride.py" '
It actually works if I write :
D:\PortablePython>D:\App\Python\python.exe D:\PortablePython\App\Python\Scripts\ride.py
But when I try to run tests within RIDE with the robot execution profile, a similar error appears in the console :
Fatal error in launcher: Unable to create process using '"E:\PortablePython\App\Python\python.exe" "D:\App\Python\Scripts\robot.exe" --version': Le fichier spÚcifiÚ est introuvable.
A workaround is to force the reinstallation of RobotFramework on the USB key to have it use D:\PortablePython\App\Python\python.exe instead of E:\PortablePython\App\Python\python.exe.
So here are my questions:
Is there any tweaks available on pip to have packages moveable in a way ? Using relatives paths instead of absolute paths maybe ?
Is it possible to have execution profiles in RIDE use the python exe on D:\ instead of the non-existing one on E:\ ?
Can virtual environments play a role in this case ?
RIDE uses the $HOME/.robotframework/ride or %APPDATA%\Robotframework\ride directories to create a database of keywords documentation (Help), and the settings.cfg. If you want to preserve this information, you should have a copy in the removable memory, and have some script to create a link to it.
This script may be a better solution to setup RIDE before it is launched. That way you can setup all the needed paths or environment variables, like, for example, PATH, PYTHONPATH.
If your code is Open Source, you can propose improvements to RIDE's portability, at https://github.com/HelioGuilherme66/RIDE
It seems I've been using an incomplete version of a Portable Python. I tried to use WinPython instead, which has a script making the installation moveable, and it solved all the issues I mentionned.
First I downloaded all the packages and libraries needed to do my tests, then I applied the make_winpython_movable.bat provided by WinPython. Everything works now when I move the files or the key.

Install numpy in Python 2.7 without setting environment

I wanted to install numpy in python 2.7 without setting environment path. I do not know if that is possible or not but my Professor wants it like so please any advice would be appreciated.
I am not sure I understand your question correctly. You can simply delete python from your environment path. But normally this is not desirable since you then cannot call python from any directory. Better is to create a virtual environment. Or better use: anaconda. This will allow you to use various version of pythons in separate environments without any confusion or clashes between versions. You then install the respective numpy version within a specific environment. See: https://conda.io/docs/user-guide/tasks/manage-python.html
If you mean want to install numpy but you do not have the previleges then your answer can be found here: (Python) Use a library locally instead of installing it
I hope this helps. If not, then please clarify your question.

Problems installing Flagmatic

I'm trying to install Flagmatic on Mac OS X Yosemite, a software package used to solve problems in extremal graph theory using the "flag algebras" developed by Razborov. I'd like to use Flagmatic to help with a research problem I'm working on, but I'm finding it very difficult to install. I'm a mathematician and while I've had some experience using Sage and Python through the Terminal I don't really know how to fix the sort of problems that I'm running into here. Here's the most up-to-date user guide so you can follow what I'm trying to do. I can broadly break down the problem as follows:
First, there is a link in the user guide to download the semidefinite programming package CSDP which Flagmatic needs in order to do some calculations. You then need to move CSDP to somewhere Flagmatic can find it, so I typed
sudo cp ~/Downloads/csdp/usr/local/bin/
into Terminal, which seemed to work. Then the user guide says by typing
csdp
into Terminal it should launch CSDP. This doesn't work - I get a permission denied message even though I typed sudo. Can anyone explain why this is happening and how to remedy it?
Secondly, when I run Sage (maths software) in the Terminal, I then want to be able to change directory to the pkg folder where there is a script called setup.py. When I run sage and type
python setup.py install
or
-python setup.py install
while in the pkg directory, I get an invalid syntax message with a pointer to the particular phrase setup.py. This is what the user guide tells you to do. If I instead try to install outside of Sage I get an error message The environment variable SAGE_ROOT must be defined. Can anyone provide some explanation and help with how to fix this?
Wow, this is somewhat dated information that they provide, since for well over a year csdp is an experimental Sage package. You should be able to just do
sage -i csdp
to install it (if you have compiler tools, which you probably do in this case). I guess the old instructions would still work but are a little brittle w.r.t. Sage.
Anyway, to the actual problem. You need to do the exact command given in the instructions:
sage -python setup.py install
However, this assumes (!) that you have a sage command in your PATH. Which you may not!
In this case, I recommend you use whatever command you use to run Sage, but instead of just typing /commmand/for/sage do /command/for/sage -python setup.py install in that directory. It will have all the right environment variables set up so that it installs in the right place, I am guessing.
Now, I'm not sure why flagmatic isn't just having themselves become an upstream package on the Sage servers, but that is a question that is harder to answer.
I might udpate the documentation in the near future. For now, however, you might want to visit this: https://github.com/jsliacan/flagmatic-2.0.git. I keep Emil's copy of Flagmatic 2.0 with updated install info. If you follow the README file, you should be fine.
I just built sage on Yosemite from source (worked fine) and then installed Flagmatic 2.0 (or Flagmatic-dev) without difficulties. It should work for you too.
I hope this helps.

What's the best way to list a non-ruby dependency of a gem?

I am writing a ruby gem that I would like to use an open source program distributed as python. I don't have the time to port the python program to ruby, and I want to manage the external dependency as automatically as possible.
I'm thinking of using the Gem.pre_install hook to automatically easy_install the python package I'm interested in.
http://rubygems.rubyforge.org/rubygems-update/Gem.html#method-c-pre_install
I'd appreciate suggestions of better ways, or support of pre_install, if it's the accepted practice.
Quite an old question, but worth a reply. Sorry, I haven't been checking stackoverflow for babushka-related questions :)
If the python package is available as a pip, then you could do something like this:
dep 'blah.gem' do
requires 'something.pip'
end
dep 'something.pip'
Then, babushka blah.gem would handle the install, including installing rubygems and pip as required.
Ben
You may want to look at Babushka for describing non-ruby dependencies.
I don't know whether installing the python package in the pre_install hook would be polite behaviour.

Can Ruby + Crate + Windows work?

I've got a project for work I'd like to do in Ruby that will have to run on Windows, but perturbing the filesystem for a Ruby install or RubyScript2Exe unpack isn't an option (this is supposed to be the harness for a testing system). Has anyone successfully used Crate to package up something on Windows? If so, what was your build environment like and can you pass on any other hints?
I've tried and worked in getting Crate work under Windows, but is a more complicated system than I would expect.
If extraction of code for your system is your problem. I recommend take a look to Exerb, and specially: exerb-mingw hosted on GitHub exerb-mingw
It will generate a single executable like Ocra or RubyScript2Exe, but with the difference that the source code will not be extracted and extensions will be dynamically loaded.
This works perfectly with RubyInstaller packages, and is being used with Pik (Ruby version manager for Windows).
Hope this helps.
You can embed a Ruby interpreter and script into a C program, which may be easier than trying to run Crate. Here are some helpful links that describe how to do this, and may provide enough sample code to use as a skeleton for what you are trying to build.

Resources