Showing posts with label virtualenv. Show all posts
Showing posts with label virtualenv. Show all posts

Tuesday, May 28, 2013

stockticker (flask/mongodb) on Heroku

Creating an App

1. Create ~/.gitconfig (if not already there)

$ git config --global user.name "My Name"
$ git config --global user.email emailname@mailhost.com

2. Set-up Project Specific Development environment:

$ mkdir ~/dev/stock-fh
$ virtualenv venv
$ work stock-fh
$ git init
$ gedit .gitignore
$ gedit README.md
$ git add .
$ git commit -m "initial commit"
$ mkdir static static/css static/js static/img static/ico templates

create favicon.ico file at favicon.cc and add to static/ico

add any necessary css, js, and img files, html goes in templates dir


3. Go to bitbucket.org and create a new repo called stock.fh and then:

$ git remote add origin ssh://git@bitbucket.org/gbiglow/stock-fh.git
$ git push -u origin --all

4. install required python components and generate requirements.txt

$ pip install flask
$ pip freeze > requirements.txt
$ git add requirements.txt
$ git commit -m "added initial requirements.txt"
$ git push origin master

5. create a Procfile for heroku and foreman

$ echo "web: python app.py" > Procfile
$ git add Procfile
$ git commit -m "added initial Procfile"
$ git push origin master

6. Create heroku app (this also creates a heroku remote for git)

$ heroku create stock-fh
$ git push heroku master

7. use mongoDB on heroku




todo:
  • pip add pymongo etc. update requirements.txt
  • twitter bootstrap
  • investigate flask app generator. code. (possible automation of steps 2-6 above into a single command. hmm...

Notes:
  • This is all based on this great article.
  • The command 'work' (above) is a local script to activate a virtualenv
  • I use bitbucket rather than github as bitbucket has unlimited private repos as part of a free account.









Monday, May 13, 2013

install Python 2.7.5 on Linux Mint

To begin, install all the development packages required to build python. Some of these may already be on your system and you may need others beyond these. These are the ones I had to add.

$ sudo apt-get install {the packages below...}
  • build-essential
  • libreadline6-dev 
  • libncursesw5-dev
  • libncurses5-dev
  • libssl-dev 
  • libsqlite3-dev 
  • tk-dev 
  • libgdbm-dev 
  • libc6-dev 
  • libbz2-dev
  • libltdl-dev
Download Python 2.7.5 tarball from python.org
Extract it and cd into that dir.

Review the README file for hints etc.
$ pg README

Generate a make file
$ ./configure

Run generated make file to compile Python executable
$ make
NOTE: renamed /usr/local/bin/python to python2.75 so apps like minkupdate would not be broken. need to get pygtk built into /usr/local/bin/python before things are fully happy. stay tuned for resolution......



Install the new Python
$ su root
# make altinstall


Notes: 
  • If you need to restart or repeat the running of make 
    • $ make clean 
    • will delete all files from previous runs of make
  • 2.7.5 will be installed in /usr/local/bin while 2.7.3 remains in /usr/bin
  • The installation of build-essential is require as explained here. Note the other packages listed above are required to compile a fully functioning python executable. if some are missing compile will still work but functionality may be missing (like readline which is required for python shell command recall)
  • Use of altinstall explained here
  • To use this new version of python with virtual environments:
    • change to dir you want to create a vitual environment in
    • $ virtualenv -v -p /usr/local/bin/python venv
    • above command will run in verbose mode and use specified python to create a virt env called "venv".
    • If above command fails with error like can't import zlib it means you did not have all the required packages installed to your system prior to compiling and installing your new version of python.
    • Carefully read the error messages at the end of the running of Make to see you are still missing any required packages
Outstanding:
  • ensure Pycharm works as expected with 2.7.4