The document discusses the author's approach to setting up a development environment for Django projects. It describes establishing a project layout with separate folders for source code, virtual environments, requirements files, and more. It also covers tools and practices for tasks like dependency management, testing, debugging, deployment, and overall software development philosophy.
4. Software Development
Environment (1)
refers to a server tier designated to a specific stage in a
release process.
List of tiers: Local, Development, Integration, Test/QA, UAT,
Stage/Pre-production, Production/Live
Hm…!
https://en.wikipedia.org/wiki/Development_environment_
%28software_development_process%29
5. Software Development
Environment (2)
a collection of procedures and tools for developing, testing
and debugging an application or program.
Getting closer …!
http://www.techopedia.com/definition/16376/development-environment
6. Integrated development
environment - IDE
!
software application that provides comprehensive facilities to
computer programmers for software development.
… source code editor, build automation tools and a debugger...
Intelligent code completion features ... compiler, interpreter, ...
version control system and various tools are integrated to simplify
the construction of a GUI ... class browser, an object browser,
and a class hierarchy diagram.
Closer and closer …!
https://en.wikipedia.org/wiki/Integrated_development_environment
7. Software Development
Environment (3)
contains everything required by a team to build and
deploy software-intensive systems (where software is an
essential and indispensable element)
I approve!!
http://www.ibm.com/developerworks/rational/library/define-scope-development-
environment/index.html
8. What is “everything”?
Software development lifecycle (SDLC)
• Planning
• Designing
• Implementation, testing and documenting
• Deployment and maintenance
https://en.wikipedia.org/wiki/Software_development
!
9. What about “a team”?
Interacts with:
• Software project management - organisation,
coordination, covers: risk, change, software configuration
and release management
https://en.wikipedia.org/wiki/Software_project_management
• Software development process a.k.a. software
development methodology - e.g. waterfall, agile …
https://en.wikipedia.org/wiki/Software_development_process
10. My priorities
1. implement at least 90% of the most important
requested features
2. shortest possible time needed for “from request
to deploy” cycle
3. low-cost scaling - human/machines - initial
setup of DevEnv or running system
4. ensure high quality deliverables
11. !
now, the real stuff
!
btw. where has Django disappeared?
18. File and directory naming
• very careful in naming !
• naming convention - inherit existing +
adaptations!
• very careful in choosing folder/structure!
• bigger files better than many files!
• less files/folders is better than more!
19. Project dependencies
• as small as possible - more components -> more complex -> more integration/
upgrade/other issues
• choose very carefully
• proven, stable, I/team is familiar with
• easily installable/upgradeable
• adaptable (when possible)
• when choosing new
• read documentation/read reviews/choose several/experiment/make
decision
• bigger community -> better
20. Project dependencies
• solutions
1. make a script to setup everything from the
scratch
2. install manually/reuse existing images and
then freeze state in VM, Vagrant, Docker
image
3. combine both
21. Project dependencies
• make a shell script
• two types of dependencies
• pip installable
pip install -r reqs/dev.txt
• pip non-installable
• set of shell commands to install everything that is missing
• Problem: different OS-es, e.g. OSX, Linux CentOS?
if [ $(uname) == 'Linux' ] …
26. Project management shell script
• why?
• to have one central place where to do project management
• what? everything that needs automation
• setup initial environment, update environment
• open editor/IDE
• run tests
• deployment, remote management
27. Project management shell script
!
# biz
!
Usage:
!
*env - will initialize dev environment
!
redis - start redis in background
elas - start elasticsearch in background
cel - start celery worker in background
!
doc-update/du - will update doc/build/html wiki doc
doc - will open doc/build/html/index.html - home of wiki
!
log2 - will tail app log (if located in local var directory)
!
run/n - django-admin runserver
django/d - django-admin
sp - django-admin shell_plus
!
test-ping/tp - ping production
test/t - django-admin test --settings=test_settings
trans-make|tm - TRANSLATION - calls makemessages
!
r/remote - will call fabric script for deployment and remote operations
!
migrate|mig - do south migration - only dev system
mig-auto - create new south auto-migration - only dev system
!
browse|b - browse to localhost:8000
issues - browse to opened issues on bitbucket
!
* - should be called with source/.
28. Editor: ViM
• although steep learning curve, is:
• very adaptable
• unique features philosophy
• not in the way, very effective
• personal preference:
• I don’t feel comfortable in IDE
• I like to be close to “bare metal”
• to use editor designed for source code editing
29. • personal preference:
Editor: ViM
• I don’t like plugins too much, only .vimrc
• when working on the server to have the same possibilities
• configuration
• server
scp ~/.vimrc user@server:/home/user/
• local development machine
ln -s ~/Dropbox/env/.vimrc ~
• flavors
• gVim / MacVim - GUI, ViM - on every server
30. Development on the server
• with project shell script one can do directly on
the server
• devenv setup/upgrade
• webapp setup/upgrade
• vim & shell-script -> do “live” development
• run dev server
31. File browser
• personal preference:
• I like side by side file browsers
• usual file operations: create folders, check files,
search for files, zip etc.
• easy integration with editor (F4)
• not found “one-to-rule-them-all”
• TotalCommander, FreeCommander, DoubleCmd …
32. Idea evaluation
• evaluate a new idea or to test concept
• ipython / django shell_plus
• use reload:
from biz import models
models.test_something()
# change models and save
reload(models)
models.test_something()
• next step is - create a module/function
33. • I use a lot
Debugging
• plain-old pdb or sometimes ipdb
• conditional breakpoints:
if i==500:
import pdb; pdb.set_trace()
• conditional breakpoints (2):
try:
bad_bad_code()
except:
import pdb; pdb.set_trace()
• server side - logging, send emails on error
logger.error(“this will be send by email)
logger.error(“in try/except - will be send by email with traceback”)
34. • Unit tests
• integration tests
Testing
• “click-testing” - local development server
• automating http requests to staging/production
servers (from curl, nagios to dedicated services)
• “click-testing” - staging/production servers
35. Deployment
• must be simple, automated, fast and reliable
• usually:
• setup environment
• git push+pull / collectstatic / restart server
• analyse logs
• run integration tests on server instance
• example:
git ci -am”very important fix”
biz r test upgrade prod upgrade
36. Philosophy
• “Unix philosophy by Mike Gancarz” filtered:
Make each program do one thing well.
Use software leverage to your advantage.
Use shell scripts to increase leverage and
portability.
(btw. Store data in flat text files)
https://en.wikipedia.org/wiki/Unix_philosophy
37. Thanks for the patience!
Questions?
!
robert.lujo@gmail.com
@trebor74hr