True to be told, when I’ve heard that I will as coach @djangogirls.org guiding people how to start with Python and Django using Windows I was scared a bit! I’ve thought installing dev stuff on Windows will be ass-pain, but I have to admit it was only a bit harder than on Linux, but anyway way easier than on OS X.
So, let’s go!
To be installed:
PowerShell (if not already installed)
Open powershell and run following commands:
[System.Environment]::SetEnvironmentVariable("PATH", $Env:Path + ";C:\Python34") [System.Environment]::SetEnvironmentVariable("PATH", $Env:Path + ";C:\Python34\Scripts")
If you have choosen another version, the number in above command will just differ. Then open once more PowerShell and check if you see python idle prompt
>>> after entering
SQLite (nothing to install)
"By default, the configuration uses SQLite. If you’re new to databases, or you’re just interested in trying Django, this is the easiest choice. SQLite is included in Python, so you won’t need to install anything else to support your database." FROM: https://docs.djangoproject.com/en/1.7/intro/tutorial01/
enable installation of 3-rd party packages: View -> Show console and copy-paste piece of script from: https://sublime.wbond.net/installation to the console. Then
shift + ctrl + Pand start typing: install packages and install
IMPORTANT! Choose installation mode exactly as shown in screenhots here: http://tech.pro/tutorial/1840/setting-up-git-and-github-from-the-windows-command-prompt
[HINT] PowerShell COPY and PASTE
- To SELECT text in PowerShell with the mouse, just select it as usual.
- To COPY the selected text to the clipboard you have to either hit Enter, or right-click.
- To PASTE into the Powershell window, right click
navigate in directories structure, access history with keys down/up -arrows basic commands: ls (dir), pwd, cd, mv, cp, mkdir, cat, >, <, clear, tree,
pip install virtualenv
PIP - is cool! You can install useful python libraries with it. If you know that for ceratin project it is neccesary to have certain libs, just create plain text file with listing them, e.g:
we call this file
requirements.txt by convention
INSTALL MULTIPLE LIBRARIES AT ONCE
and you know what is beautiful? You install all listed there librariers (for bigger project it can be dozens of them!!) with runing just:
pip install -r requirments.txt
Wait a moment… what IF I develope multiple projects with completly different libraries, or would like to play with different python versions?
The way to go is using a isolated environments called virtualenvs!
BASIC VIRTUALENV WORKFLOW:
C:\ create directory
virtualenvs, and navigate there
create new virtualenv named
wirtuoz by running:
C:\Python34\python -m venv wirtuoz
activate the created virtualenv:
while being in acitve desired virtualenv givn denoted in prompt like
(wirtuoz) you install libraries by:
pip install django
Due to powershell security restrictions issue (setup only once):
- Run PowerShell as admin !!
Execute this command:
Set-ExecutionPolicy Unrestricted -Scope CurrentUser
WHAT IS INSIDE MY CURRENT VIRTUALENV?
check it by listing installed libraries:
by the way if you want to create
reuqirements.txtfor your project just:
pip freeze > reuqirements.txt
GIT + Github.com
GIT != github.com
Git is advanced revision control system allowing teams easy parallel development. Github is a kind of cool online hosting with nice GUI functionality and especially features making work of distributed teams on code in mostly open source projects easier.
####Setup github repo on github.com
- SignUp if not yet
- Create new repo
- In web browser on github.com edit README.md of the repo with some content (just to know this are changes made by you). Save(commit).
- copy SSH clone URL, it should look something like: firstname.lastname@example.org:github_username/repo_name.git
####Clone the repo
1) Before we clone, we need to generate on our computers SSH keys
Navigate to your home directory:
mkdir .ssh cd .ssh ssh-keygen -t rsa -C "email@example.com"
id_rsa name, by typing it explicitly. It will be then used
as default key and will allow us to skip bit more sophisticated configuration
Display value of publick key:
copy it co clipboard and add it to github on https://github.com/settings/ssh
If you get lost, have a look here: http://tech.pro/tutorial/1840/setting-up-git-and-github-from-the-windows-command-prompt
2) Now time for cloning:
git clone firstname.lastname@example.org:github_username/repo_name.git
OK, I lied to you a little bit, to motivate you to generate all that stuff, but you can clone all PUBLIC repos from github just by running git clone wihtout any keys. But it won’t work for your PRIVATE repos. And anyway we will need it to made (push) any changes we made localy to remote version of repository, so it was worth anyway ;)
3) The definitive test (if we have really access to made some changes to remote version):
Made some changes and save file. See the output off:
Commit the changes you made to repo:
git commit -am "some memo about changes"
git push origin master
Go to https://github.com/ and check if your commit was really pushed.
####Basic commands demo:
pull, push, commit, diff, status, checkout
####If still some time and power remains:
- branches - merging