Donnerstag, 15. Oktober 2015

Virtualenv on windows and building python packages

using now conda to manage virtual envs on windows (update 19/12/2015)

http://uoa-eresearch.github.io/eresearch-cookbook/recipe/2014/11/20/conda/

for interop with pycharm see:

http://stackoverflow.com/questions/28390961/using-anaconda-within-pycharm

Very helpful (notice got it running only with python 2.7):

http://www.tylerbutler.com/2012/05/how-to-install-python-pip-and-virtualenv-on-windows-with-powershell/

Once you have set up the virtual env and you want to use it in a new powershell just edit the shortcut to PS so that :
Target: %SystemRoot%\syswow64\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Unrestricted
Start In: %HOMEDRIVE%%HOMEPATH%

Creating virtual environment:
Import-Module virtualenvwrapper
New-VirtualEnvironment applicake


Loading a virtual env:

Import-Module virtualenvwrapper 
(not sure if it is actually necessary?)

# I have already these environments
Set-VirtualEnvironment engineer
Set-VirtualEnvironment applicake
Set-VirtualEnvironment mspy

Virtual env on linux

source virtenvs/systemmhc/bin/activate

Building native python packages on windows just download:

Microsoft Visual C++ Compiler for Python 2.7


afterwards you can install numpy by executing
pip install numpy

Some package are more difficult to build because of their dependencies. In such a case visit:
http://www.lfd.uci.edu/~gohlke/pythonlibs/

Building python packages

Just create a folder in the folder create a setup.py file, create a subfolder, place in the subfolder your .py files and an __init__.py file (see my tiny python project cakeme).

install package in user directory  (no virtual env but --user directory):

pip install --user cakeme

install package locally in development mode:

pip install --user -e . (begin in the package directory)

create local whl file

python setup.py bdist_wheel

Register package with pypi.python.org


python setup.py register

Pushing changes in python package to pypi:


python setup.py bdist_wheel upload




How to install a whl file:

pip install some-package.whl

Some more tipps for powershell users:

$env:Path += ";C:\Program Files\Sublime Text 2\"

Keine Kommentare:

Kommentar veröffentlichen