virtual environment approach for packages - pythonpath

I'm starting to use virtual environments. I'm a little unclear on how to efficiently work with them and globally installed packages. For example, if I want to use Numpy in my project within a virtual environment, does it make sense to install Numpy into the environment for the project? I'm assuming no, since I will then have to install Numpy many times for different projects. So maybe I need to set environment $PYTHONPATH for each project? Is it correct that there should be a separate $PYTHONPATH variable for each project? Or is there some other way to manage this correctly? Thanks for any recommendations you may have to offer.

I have personally adopted the habit of making a virtual environment (venv) for each significant project, plus a default venv in my home directory. This might help you also. Python venvs are cheap!
I name each venv the same as my python project.
Bonus tip: Imagine a project called blah, then there would also be a venv at ~/venvs/blah. A bash alias could be defined called blah that activates the venv and cds into the project directory:
alias blah="source ~/.venv/blah/bin/activate; cd ~/work/blah"
Now you type blah at a shell prompt and you are working on that project. Boom!

Related

As a project user, what do I need to do to make a project with Cmake?

I'm working with a project that [used to] support both Autotools and Cmake. In the past, I would:
cd project/build
...
../llvm/configure --enable-optimized --enable-cxx11 $OTHER_OPTIONS --prefix=/usr/local
make -j2
sudo make install
The project has kind of abandoned it support for Autotools, so I have to use Cmake now. Using Cmake to configure seems like it should be relatively easy.
Unfortunately, Mac OS X lacks man pages for Cmake, so I can't RTFM. And the search hits I am finding discuss how to build Cmake packages (and other stuff package maintainers would do), and not how to use it as a dumb project user.
I tried to simply use Cmake in place of Configure, but it did not work:
$ cd project/build
$ OTHER_OPTIONS=" --enable-libcpp"; cmake ../llvm --enable-optimized --enable-cxx11 "$OTHER_OPTIONS" --prefix=/usr/local
CMake Error: The source directory ".../clang-3.6/build/--prefix=/usr/local" does not exist.
Why is Cmake treating a configuration option like a directory (--prefix=/usr/local)?
How do I configure and build a project that uses Cmake as a dumb project user?
You're trying to configure a CMake project like it was autotools. The syntax of the command is;
cmake -Doptions -Dmore_options src_dir
src directory is the last argument, which is why it treats --prefix that way. You will need to know the name of the parameters available to you though. If you're new to CMake, your best bet is to run, either the Qt gui or the curses gui ( ccmake /path/to/src while your in the build directory ). Those gui tools will let you pick your options, configure then generate. Then all you need is to type make ....
Note
cmake --help
does provide info even if your man pages aren't installed. Also, if you have access to google and the internet, searching "cmake man page" should give you access the your missing man pages.

Weird Cuda C installation (Ubuntu14.04)

I just came across a weird situation after installing cuda... I literally followed every single step suggested by the nvidia website: http://docs.nvidia.com/cuda/cuda-getting-started-guide-for-linux/#axzz3H0tm46yY.... everything seems to be fine, even the samples work... however when I try to run the "hello world" program presented in Cuda by Example documentation, the terminal displays:
The program 'nvcc' is currently not installed. You can install it by typing:
sudo apt-get install nvidia-cuda-toolkit
This is quite strange since nvcc should already be installed during the procedure suggested by the nvidia website....
Does anyone have any idea?
The PATH variable needs to include your cuda /bin directory (by default it is /usr/local/cuda-6.5/bin)
On Ubuntu you can edit the .bashrc file on your $HOME directory, adding the following;
export PATH=/usr/local/cuda-6.5/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-6.5/lib64:$LD_LIBRARY_PATH
If you are running a 32-bit Ubuntu version, then the paths are:
export PATH=/usr/local/cuda-6.5/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-6.5/lib:$LD_LIBRARY_PATH
After editing the bashrc file, source it (or simply restart the terminal):
source ~/.bashrc
Of course, if you have changed the default location of your CUDA directory you must change the PATHS accordingly.
PLUS: there are another options to tell the system where to find a library, a program, etc. like using enviromental modules, specify the complete path to the libraries and programs manually are another options. There are many methods out there!

How to create binary Debian package (s) for several architectures?

I'm trying to create packages for some robot controller code that will support different architectures, such as i386 and armhf (for Raspberry Pi). I don't know how Debian intends this to be done. Is there a way to create a single .deb package that contains both binaries? Or must I create a separate .deb package for each architecture, which I do know how to do?
In the latter case, if I give the two packages the same package name, I can't put them both in the same repository, but if they have different names, users will have to specify which package they want to install using apt-get. Is there a solution to this problem?
You need to have different binary packages for different architectures unless what you're packaging is interpreted and not compiled.
If the package you're making is compatible with all architectures, then the Architecture: field of your debian/control file must be any. This is telling you that the package can be built in any Debian supported architecture. Then you'll just compile it and cross-compile it to i386 and armhf.
About your second question, you can. In fact, this is how is done in the official Debian repositories. The binary packages have a suffix in the file name containing the architecture. See this example. When users install your package, they won't need to specify the architecture as it's automatically detected.

Symbolic integration in Octave? (Need to Install extantion? How? - Using Ubuntu 12.04)

I would like to calculate the following symbolic expression in GNU Octave:
int(exp(ikx-|k|^n),k,-infinity,infinity) , (- it would a function of 'x' of-course, where 'x' is an array of data.)
I don't succeed.
I understood, searching a bit in the internet, that Octave does not come initially with a built-in 'Symbolic math' suite.
Is this true?
How do I download and install it (using Ubuntu 12.04, from the 'Terminal'?)?
Thanking u on advance!
Yes. GNU octave is the core program and language. What you are looking for are functions from the symbolic package that belong to Octave-Forge. They are two different but related projects. Let me remind you that the symbolic maths toolbox is also not part of Matlab core, it's a different product.
To install them in Ubuntu, it depends on how you installed Octave:
from the Ubuntu repositories? If so, sudo apt-get install octave-symbolic.
compiled it Octave yourself? Start Octave and at the Octave prompt pkg install -forge symbolic
from one of the up to date PPAs? Check if they also have the sybolic package and install that one
I can tell you in advance that the symbolic package has been unmaintained for a long time, and doesn't work very well with latest Octave versions (it was written for a very old version of Octave). The advice usually is to switch to Maxima which is designed exactly for that. Since 2015 the symbolic package is again actively maintained. However, Octave is still a programming language aimed at numerical computing. If all your problems require symbolic computations, then consider using a computer algebra system. Maxima is often recommended.

Tcpdump on openwrt

I'm looking for a tcpdump binary that runs on openwrt. The website only shows source code that must be built. Anybody point me to a location that contains a prebuild binary? Thanks.
I suggest to set up a working repository, i.e.:
https://downloads.openwrt.org/chaos_calmer/15.05-rc2/x86/generic/packages/base/
You can put the url on your OpenWRT system under /etc/opkg.conf.
Using opkg you do not have to deal with all the dependencies.
opkg update
opkg install tcpdump
If there is no internet connection on the Openwrt system, and there is no local repository deployed, the solution above works as well, but it is more painful and consumes more time.
You find binaries at
http://downloads.openwrt.org/snapshots/trunk/
but you have to use the right one for your hardware plattform
e.g for x86
http://downloads.openwrt.org/snapshots/trunk/x86/packages/tcpdump_4.2.1-1_x86.ipk
The prefered method is to use opkg to install the package