Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Upgrade your Web Development Toolchain by Blaise Laflamme

PyCon 2014
April 12, 2014
1.1k

Upgrade your Web Development Toolchain by Blaise Laflamme

PyCon 2014

April 12, 2014
Tweet

More Decks by PyCon 2014

Transcript

  1. About Me • Full-Stack Web Development • Lead Projects •

    Lead Teams • Still learning a lot everyday
  2. What This Talk is About • Ideas and patterns •

    Combining tools • Working with people on projects
  3. What This Talk is not About • Strong opinions •

    Cookbook recipes • In-depth technical examples
  4. Best Practices & Patterns • Dogmatism is never a good

    thing • Should always have a significant benefit • Stick to what really makes a difference
  5. Problems to Solve • Tie up multiple in-development projects •

    Tie up multiple environments & tools • Mix up development teams
  6. Provisioning & Deployment • Developer’s machine • Dedicated, Linode, Rackspace,

    Heroku, … • Ansible, Saltstack, Chef, Puppet, Docker, …
  7. WebApp Development • Back end • Python, frameworks, template engines,

    … • Front end • HTML, CSS, Javascript, frameworks, …
  8. Package Management Back end Package Management $ easy_install pyramid
 $

    easy_install pyramid==1.5
 $ pip install pyramid
 $ pip install pyramid==1.5 Front end Package Management $ bower install jquery
 $ bower install jquery#1.11.0
  9. Package Management Back end Package Management setup(
 name='myproject',
 version=0.1.0,
 install_requires=[‘pyramid==1.5’]


    ) Front end Package Management {
 "name": "myproject-resources",
 "version": "0.1.0",
 "dependencies": {
 "jquery": “1.11.0”
 }
 }
  10. Assets Management Back end Assets Management from webassets import Bundle

    all_js = Bundle(
 Bundle('common/libs/jquery/jquery.js'),
 filters='jsmin',
 output='gen/packed.js'
 )
 
 >>> env['all_js'].urls() ('/media/gen/packed.js',)
  11. Assets Management Front end Assets Management module.exports = function (grunt)

    {
 grunt.initConfig({
 jsmin-sourcemap: {
 dist: {
 src: 'common/libs/jquery/jquery.js',
 dest: 'gen/packed.js'
 }
 },
 });
 grunt.loadNpmTasks('grunt-jsmin-sourcemap');
 grunt.registerTask('dist', [
 'jsmin-sourcemap:dist'
 ]);
 };
  12. Frontend also need Front end dependencies and requirements require.config({
 paths:

    {
 jquery: 'libs/jquery-1.11.0'
 }
 });
 
 …
 
 require( ['jquery'], function( $ ) {
 
 });
  13. You reach a point of separation • Advanced hybrid-application •

    SPA (Single Page App) • Backend as an API
  14. You’ll benefit from splitting to multiple projects • One project

    per team or «concerns» • Use same global app or project environment • Share common set of tools and patterns
  15. Buildout [buildout] extensions = mr.developer extends = https://raw.github.com/reebalazs/ buildout.javascript.yeoman/master/yeoman.cfg parts+

    = dirs eggs bower_modules develop = src/myapp1 src/myapp2 ! [dirs] recipe = z3c.recipe.mkdir paths = var
  16. Buildout [sources] myapp1 = git [email protected]:blaflamme/myapp1.git myapp2 = git [email protected]:blaflamme/myapp2.git

    ! [eggs] recipe = zc.recipe.egg dependent-scripts = true eggs = appenlight-client myapp1 myapp2 interpreter = py
  17. myapp-dev project .
 ├── Gruntfile.js
 ├── Makefile
 ├── bootstrap.py
 ├──

    bower.json
 ├── buildout.cfg
 ├── etc
 └── package.json
  18. Buildout Project Setting the project $ git clone [email protected]:blaflamme/myapp-dev.git
 $

    cd myapp-dev
 $ virtualenv .
 $ bin/python bootstrap.py
 $ bin/buildout
  19. myapp-dev project . ├── Gruntfile.js
 ├── Makefile
 ├── bin
 ├──

    bootstrap.py
 ├── bower.json
 ├── buildout.cfg
 ├── components
 ├── develop-eggs
 ├── eggs
 ├── etc
 ├── include
 ├── lib
 ├── node_modules
 ├── package.json
 ├── parts
 ├── src
 └── var
  20. Command Line API • Wrap multiple commands under simpler API

    • Use Makefiles, Make is a good tool for this ;)
  21. Makefile HERE = $(shell pwd)
 BIN = $(HERE)/bin
 VIRTUALENV =

    virtualenv
 PYTHON = $(HERE)/bin/python
 
 virtualenv:
 $(VIRTUALENV) . bootstrap:
 $(PYTHON) bootstrap.py buildout:
 $(BIN)/buildout
 
 setup:
 virtualenv bootstrap buildout
  22. Conclusion • Isolate Application Environment • Organize projects in a

    flexible way • Give more power to user & team