SlideShare a Scribd company logo
1 of 20
E D
ENVIRONMENTAL DEPENDENCIES IN PYTHON
Building Highly Complex Systems
Many pieces acting as one
Image by Alan_D from Crawley, United Kingdom - Nissan GTR Cutaway, CC BY 2.0, https://commons.wikimedia.org/w/index.php?curid=18072247
Building Open Source Business Systems
Using what you can find to build what you need
Image byy Mick from England (Go Kart Buggy) [CC BY 2.0 (http://creativecommons.org/licenses/by/2.0)], via Wikimedia Commons
Python Tools
Core tools for dependency management in
Python
Image by Alexander Baxevanis (Flickr: Cooper's tools) [CC BY 2.0 (http://creativecommons.org/licenses/by/2.0)], via Wikimedia Commons
One Language Multiple Tools
Dependency Management
 Easy Install – deprecated
 Distutils – deprecated
 Setuptools – project dependencies
 PIP – environment dependencies
Environment Management
 venv – Python 3.3+
 Virtualenv – Virtual environments
 Virtualenvwrapper – Enhancements for
Virtualenv
setuptools
Project dependency management
Image by ParentingPatch (Own work) [CC BY-SA 3.0 (http://creativecommons.org/licenses/by-sa/3.0)], via Wikimedia Commons
Setuptools – Project Dependency Tool
 Defines package information: name, version, authors, etc.
 Defines package and test dependency requirements for project source
 Should define as wide a range as possible for dependency versions
 Builds distributions
 Publishes distributions to PyPI
 Defines scripts to install as binaries
 Provides runtime support for C modules
 Can be used for test bootstrapping
Project Dependency
LaunchKey
SDK pycrypto
requests
six
Setuptools setup.py
…
setup(name='launchkey-python',
version='1.3.0',
…
install_requires= [
'pycrypto >= 2.6.1', 'pycrypto < 3.0.0',
'requests >= 2.5.1', 'requests < 3.0.0',
'six >= 1.10.0', 'six < 2.0.0',
],
tests_require=[
'Mocker==1.1.1',
'mock==1.3.0'
],
)
pip
Environment dependency management
Image © Dietmar Rabich, rabich.de - Own work, CC BY-SA 4.0, https://commons.wikimedia.org/w/index.php?curid=34239265
PIP Requirements File
Overview
 Contains information for repeatable
installs
 Can include command line options
 Can use a constraints file for multi-project
dependency version overrides. Helpful for
using patched forks
 Can be built with the freeze command
Example
--index-url=https://my-pypi.example.com
pycrypto==2.6.1
requests==2.10.0
six==1.10.0
PIP Freeze
$ pip freeze > requirements.txt
cat requirements.txt
launchkey-python==1.3.0
pycrypto==2.6.1
requests==2.10.0
six==1.10.0
Use the PIP freeze command to
generate a requirements file
based on the currently installed
versions.
Virtual
Environments
Different parts for different projects
Image by EncMstr (Own work) [GFDL (http://www.gnu.org/copyleft/fdl.html) or CC BY-SA 4.0-3.0-2.5-2.0-1.0 (http://creativecommons.org/licenses/by-sa/4.0-3.0-2.5-2.0-1.0)], via Wikimedia Commons
Virtualenv
 Can be installed via PIP
 Allows you to switch between “virtual” environments
 Virtual environments are full copies with symbolically linked, or optionally copied,
python binaries including pip.
 Private set of environment variables
 Private set of installed packages
 Can be told which Python executable to use
 Environments can be easily activated and deactivated
 Deleting created directory remove virtual environments
Usage
$ which python
/usr/local/bin/python
$ virtualenv --prompt "(sdk) ” .venv
…
Installing setuptools, pip, wheel...done.
$ source .venv/bin/activate
(sdk) $ which python
/.venv/bin/python
(sdk) $ deactivate
$ which python
/usr/local/bin/python
Simple example for creating,
activating, and deactivating
virtual environments with
Virtualenv
Virtualenvwrapper
 Can be installed via PIP
 Adds additional functionality to Virtualenv
 Uses named rather than location based environments
 Places reusable environments in user directory
 Auto-complete for enabling and removing environments
 Defaults prompt prefix to environment name
 If directory is same name as project. Enable with directory location
Usage
$ which python
/usr/local/bin/python
$ mkvirtualenv example
…
Installing setuptools, pip, wheel...done.
(example) $ which python
~/.virtualenvs/example/bin/python
(sdk) $ deactivate
$ which python
/usr/local/bin/python
Simple example for creating,
activating, and deactivating
virtual environments
Pyenv
 Manage any number of Python executable versions
 Great for open source projects that need to run on multiple versions
 Has Virtualenv support via an add-on to support mixing Python executable
versions and virtual environments in a manner similar to rbenv.
 On Mac, make sure XCode and Command Line Developer Tools are up to date.
Usage
$ which python3
$ pyenv install 3.5.2
Downloading Python-3.5.2.tgz...
->
https://www.python.org/ftp/python/3.5.2/Python-
3.5.2.tgz
Installing Python-3.5.2...
Installed Python-3.5.2 to ~/.pyenv/versions/3.5.2
$ pyenv global 3.5.2
$ python3 --version
Python 3.5.2
Simple example for installing and
using a Python version
Further Reading
 Packaging: https://packaging.python.org/
 Python Versioning: https://www.python.org/dev/peps/pep-0440/
 Setuptools: https://setuptools.readthedocs.io/en/latest/
 PIP: https://pip.pypa.io/en/stable/
 PIP Version Resolving: https://github.com/pypa/pip/issues/988
 Virtualenv: https://virtualenv.pypa.io/en/stable/
 Virtualenvwrapper: http://virtualenvwrapper.readthedocs.io/en/latest/index.html
 Pyenv: https://github.com/yyuu/pyenv

More Related Content

What's hot

What's hot (20)

Django로 만든 웹 애플리케이션 도커라이징하기 + 도커 컴포즈로 개발 환경 구축하기
Django로 만든 웹 애플리케이션 도커라이징하기 + 도커 컴포즈로 개발 환경 구축하기Django로 만든 웹 애플리케이션 도커라이징하기 + 도커 컴포즈로 개발 환경 구축하기
Django로 만든 웹 애플리케이션 도커라이징하기 + 도커 컴포즈로 개발 환경 구축하기
 
Releasing and deploying python tools
Releasing and deploying python toolsReleasing and deploying python tools
Releasing and deploying python tools
 
Docker on ARM Raspberry Pi
Docker on ARM Raspberry PiDocker on ARM Raspberry Pi
Docker on ARM Raspberry Pi
 
Introduction to Project atomic (CentOS Dojo Bangalore)
Introduction to Project atomic (CentOS Dojo Bangalore)Introduction to Project atomic (CentOS Dojo Bangalore)
Introduction to Project atomic (CentOS Dojo Bangalore)
 
Programming IoT with Docker: How to Start?
Programming IoT with Docker: How to Start?Programming IoT with Docker: How to Start?
Programming IoT with Docker: How to Start?
 
Coscup x ruby conf tw 2021 google cloud buildpacks 剖析與實踐
Coscup x ruby conf tw 2021  google cloud buildpacks 剖析與實踐Coscup x ruby conf tw 2021  google cloud buildpacks 剖析與實踐
Coscup x ruby conf tw 2021 google cloud buildpacks 剖析與實踐
 
DCSF 19 Deploying Rootless buildkit on Kubernetes
DCSF 19 Deploying Rootless buildkit on KubernetesDCSF 19 Deploying Rootless buildkit on Kubernetes
DCSF 19 Deploying Rootless buildkit on Kubernetes
 
DCSF19 Tips and Tricks of the Docker Captains
DCSF19 Tips and Tricks of the Docker Captains  DCSF19 Tips and Tricks of the Docker Captains
DCSF19 Tips and Tricks of the Docker Captains
 
Arbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenvArbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenv
 
Streamline your development environment with docker
Streamline your development environment with dockerStreamline your development environment with docker
Streamline your development environment with docker
 
The overview of lazypull with containerd Remote Snapshotter & Stargz Snapshotter
The overview of lazypull with containerd Remote Snapshotter & Stargz SnapshotterThe overview of lazypull with containerd Remote Snapshotter & Stargz Snapshotter
The overview of lazypull with containerd Remote Snapshotter & Stargz Snapshotter
 
App container rkt
App container rktApp container rkt
App container rkt
 
Scripting Support in GFv3 Prelude - Full Version
Scripting Support in GFv3 Prelude - Full VersionScripting Support in GFv3 Prelude - Full Version
Scripting Support in GFv3 Prelude - Full Version
 
Container sig#1 ansible-container
Container sig#1 ansible-containerContainer sig#1 ansible-container
Container sig#1 ansible-container
 
Jump into Squeak - Integrate Squeak projects with Docker & Github
Jump into Squeak - Integrate Squeak projects with Docker & GithubJump into Squeak - Integrate Squeak projects with Docker & Github
Jump into Squeak - Integrate Squeak projects with Docker & Github
 
eStargzイメージとlazy pullingによる高速なコンテナ起動
eStargzイメージとlazy pullingによる高速なコンテナ起動eStargzイメージとlazy pullingによる高速なコンテナ起動
eStargzイメージとlazy pullingによる高速なコンテナ起動
 
Container Deployment and Management with kubernetes
Container Deployment and Management with kubernetesContainer Deployment and Management with kubernetes
Container Deployment and Management with kubernetes
 
Docker for the Internet of Things (IoT): An Introduction
Docker for the Internet of Things (IoT): An IntroductionDocker for the Internet of Things (IoT): An Introduction
Docker for the Internet of Things (IoT): An Introduction
 
Check the version with fixes. Link in description
Check the version with fixes. Link in descriptionCheck the version with fixes. Link in description
Check the version with fixes. Link in description
 
手把手帶你學Docker 03042017
手把手帶你學Docker 03042017手把手帶你學Docker 03042017
手把手帶你學Docker 03042017
 

Viewers also liked

Behavior Driven Development - How To Start with Behat
Behavior Driven Development - How To Start with BehatBehavior Driven Development - How To Start with Behat
Behavior Driven Development - How To Start with Behat
imoneytech
 
Coding standards PSR-1 & PSR-2
Coding standards PSR-1 & PSR-2Coding standards PSR-1 & PSR-2
Coding standards PSR-1 & PSR-2
Aram Baghdasaryan
 

Viewers also liked (20)

Php[tek] 2016 - BDD with Behat for Beginners
Php[tek] 2016 - BDD with Behat for BeginnersPhp[tek] 2016 - BDD with Behat for Beginners
Php[tek] 2016 - BDD with Behat for Beginners
 
Continuous Deployment at Scale, Rootconf 2016
Continuous Deployment at Scale, Rootconf 2016Continuous Deployment at Scale, Rootconf 2016
Continuous Deployment at Scale, Rootconf 2016
 
Behat, Behavioral Driven Development (BDD) in PHP
Behat, Behavioral Driven Development (BDD) in PHPBehat, Behavioral Driven Development (BDD) in PHP
Behat, Behavioral Driven Development (BDD) in PHP
 
Behat入門
Behat入門Behat入門
Behat入門
 
Introduction to Behaviour Driven Development
Introduction to Behaviour Driven DevelopmentIntroduction to Behaviour Driven Development
Introduction to Behaviour Driven Development
 
Behavior Driven Development - How To Start with Behat
Behavior Driven Development - How To Start with BehatBehavior Driven Development - How To Start with Behat
Behavior Driven Development - How To Start with Behat
 
Asynchronous Python with Twisted
Asynchronous Python with TwistedAsynchronous Python with Twisted
Asynchronous Python with Twisted
 
Ashley Madison - Lessons Learned
Ashley Madison - Lessons LearnedAshley Madison - Lessons Learned
Ashley Madison - Lessons Learned
 
BDD with Behat
BDD with BehatBDD with Behat
BDD with Behat
 
Internet of Things With PHP
Internet of Things With PHPInternet of Things With PHP
Internet of Things With PHP
 
Python and the internet of things
Python and the internet of thingsPython and the internet of things
Python and the internet of things
 
PHPConf.asia 2016 - BDD with Behat for Beginners
PHPConf.asia 2016 - BDD with Behat for BeginnersPHPConf.asia 2016 - BDD with Behat for Beginners
PHPConf.asia 2016 - BDD with Behat for Beginners
 
Bdd and Behat
Bdd and BehatBdd and Behat
Bdd and Behat
 
Coding standards PSR-1 & PSR-2
Coding standards PSR-1 & PSR-2Coding standards PSR-1 & PSR-2
Coding standards PSR-1 & PSR-2
 
Democratizing the Internet of Things
Democratizing the Internet of ThingsDemocratizing the Internet of Things
Democratizing the Internet of Things
 
PHP's FIG and PSRs
PHP's FIG and PSRsPHP's FIG and PSRs
PHP's FIG and PSRs
 
Got Python I/O: IoT Develoment in Python via GPIO
Got Python I/O: IoT Develoment in Python via GPIOGot Python I/O: IoT Develoment in Python via GPIO
Got Python I/O: IoT Develoment in Python via GPIO
 
BDD and Behave
BDD and BehaveBDD and Behave
BDD and Behave
 
Python Bluetooth
Python BluetoothPython Bluetooth
Python Bluetooth
 
IoT Lockdown
IoT LockdownIoT Lockdown
IoT Lockdown
 

Similar to E D - Environmental Dependencies in Python

5 minute intro to virtualenv
5 minute intro to virtualenv5 minute intro to virtualenv
5 minute intro to virtualenv
amenasse
 

Similar to E D - Environmental Dependencies in Python (20)

Develop with docker 2014 aug
Develop with docker 2014 augDevelop with docker 2014 aug
Develop with docker 2014 aug
 
Building a data warehouse with Pentaho and Docker
Building a data warehouse with Pentaho and DockerBuilding a data warehouse with Pentaho and Docker
Building a data warehouse with Pentaho and Docker
 
Jenkins, Bhyve, and Webdriver: Continuous Integration testing on FreeNAS by C...
Jenkins, Bhyve, and Webdriver: Continuous Integration testing on FreeNAS by C...Jenkins, Bhyve, and Webdriver: Continuous Integration testing on FreeNAS by C...
Jenkins, Bhyve, and Webdriver: Continuous Integration testing on FreeNAS by C...
 
Red Hat Forum Benelux 2015
Red Hat Forum Benelux 2015Red Hat Forum Benelux 2015
Red Hat Forum Benelux 2015
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
 
Docker module 1
Docker module 1Docker module 1
Docker module 1
 
Software Quality Assurance Tooling - Wintersession 2024
Software Quality Assurance Tooling - Wintersession 2024Software Quality Assurance Tooling - Wintersession 2024
Software Quality Assurance Tooling - Wintersession 2024
 
DevNet Associate : Python introduction
DevNet Associate : Python introductionDevNet Associate : Python introduction
DevNet Associate : Python introduction
 
Docker Azure Friday OSS March 2017 - Developing and deploying Java & Linux on...
Docker Azure Friday OSS March 2017 - Developing and deploying Java & Linux on...Docker Azure Friday OSS March 2017 - Developing and deploying Java & Linux on...
Docker Azure Friday OSS March 2017 - Developing and deploying Java & Linux on...
 
Common primitives in Docker environments
Common primitives in Docker environmentsCommon primitives in Docker environments
Common primitives in Docker environments
 
Lean Drupal Repositories with Composer and Drush
Lean Drupal Repositories with Composer and DrushLean Drupal Repositories with Composer and Drush
Lean Drupal Repositories with Composer and Drush
 
Django Architecture Introduction
Django Architecture IntroductionDjango Architecture Introduction
Django Architecture Introduction
 
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
5 minute intro to virtualenv
5 minute intro to virtualenv5 minute intro to virtualenv
5 minute intro to virtualenv
 
Django Deployment
Django DeploymentDjango Deployment
Django Deployment
 
Containers: DevOp Enablers of Technical Solutions
Containers: DevOp Enablers of Technical SolutionsContainers: DevOp Enablers of Technical Solutions
Containers: DevOp Enablers of Technical Solutions
 
Docker - BWI Innovation Talk
Docker - BWI Innovation TalkDocker - BWI Innovation Talk
Docker - BWI Innovation Talk
 
Chicago Docker Meetup Presentation - Mediafly
Chicago Docker Meetup Presentation - MediaflyChicago Docker Meetup Presentation - Mediafly
Chicago Docker Meetup Presentation - Mediafly
 
AWS EC2 Ubuntu Instance - Step-by-Step Deployment Guide
AWS EC2 Ubuntu Instance - Step-by-Step Deployment GuideAWS EC2 Ubuntu Instance - Step-by-Step Deployment Guide
AWS EC2 Ubuntu Instance - Step-by-Step Deployment Guide
 

More from Adam Englander

More from Adam Englander (20)

Making PHP Smarter - Dutch PHP 2023.pptx
Making PHP Smarter - Dutch PHP 2023.pptxMaking PHP Smarter - Dutch PHP 2023.pptx
Making PHP Smarter - Dutch PHP 2023.pptx
 
Practical API Security - PyCon 2019
Practical API Security - PyCon 2019Practical API Security - PyCon 2019
Practical API Security - PyCon 2019
 
Threat Modeling for Dummies
Threat Modeling for DummiesThreat Modeling for Dummies
Threat Modeling for Dummies
 
ZendCon 2018 - Practical API Security
ZendCon 2018 - Practical API SecurityZendCon 2018 - Practical API Security
ZendCon 2018 - Practical API Security
 
ZendCon 2018 - Cryptography in Depth
ZendCon 2018 - Cryptography in DepthZendCon 2018 - Cryptography in Depth
ZendCon 2018 - Cryptography in Depth
 
Threat Modeling for Dummies - Cascadia PHP 2018
Threat Modeling for Dummies - Cascadia PHP 2018Threat Modeling for Dummies - Cascadia PHP 2018
Threat Modeling for Dummies - Cascadia PHP 2018
 
Dutch PHP 2018 - Cryptography for Beginners
Dutch PHP 2018 - Cryptography for BeginnersDutch PHP 2018 - Cryptography for Beginners
Dutch PHP 2018 - Cryptography for Beginners
 
php[tek] 2108 - Cryptography Advances in PHP 7.2
php[tek] 2108 - Cryptography Advances in PHP 7.2php[tek] 2108 - Cryptography Advances in PHP 7.2
php[tek] 2108 - Cryptography Advances in PHP 7.2
 
php[tek] 2018 - Biometrics, fantastic failure point of the future
php[tek] 2018 - Biometrics, fantastic failure point of the futurephp[tek] 2018 - Biometrics, fantastic failure point of the future
php[tek] 2018 - Biometrics, fantastic failure point of the future
 
Biometrics: Sexy, Secure and... Stupid - RSAC 2018
Biometrics: Sexy, Secure and... Stupid - RSAC 2018Biometrics: Sexy, Secure and... Stupid - RSAC 2018
Biometrics: Sexy, Secure and... Stupid - RSAC 2018
 
Practical API Security - PyCon 2018
Practical API Security - PyCon 2018Practical API Security - PyCon 2018
Practical API Security - PyCon 2018
 
Practical API Security - Midwest PHP 2018
Practical API Security - Midwest PHP 2018Practical API Security - Midwest PHP 2018
Practical API Security - Midwest PHP 2018
 
Cryptography for Beginners - Midwest PHP 2018
Cryptography for Beginners - Midwest PHP 2018Cryptography for Beginners - Midwest PHP 2018
Cryptography for Beginners - Midwest PHP 2018
 
Cryptography for Beginners - Sunshine PHP 2018
Cryptography for Beginners - Sunshine PHP 2018Cryptography for Beginners - Sunshine PHP 2018
Cryptography for Beginners - Sunshine PHP 2018
 
ConFoo Vancouver 2017 - Biometrics: Fantastic Failure Point of the Future
ConFoo Vancouver 2017 - Biometrics: Fantastic Failure Point of the FutureConFoo Vancouver 2017 - Biometrics: Fantastic Failure Point of the Future
ConFoo Vancouver 2017 - Biometrics: Fantastic Failure Point of the Future
 
Con Foo 2017 - Don't Loose Sleep - Secure Your REST
Con Foo 2017 - Don't Loose Sleep - Secure Your RESTCon Foo 2017 - Don't Loose Sleep - Secure Your REST
Con Foo 2017 - Don't Loose Sleep - Secure Your REST
 
ZendCon 2017 - Cryptography for Beginners
ZendCon 2017 - Cryptography for BeginnersZendCon 2017 - Cryptography for Beginners
ZendCon 2017 - Cryptography for Beginners
 
ZendCon 2017: The Red Team is Coming
ZendCon 2017: The Red Team is ComingZendCon 2017: The Red Team is Coming
ZendCon 2017: The Red Team is Coming
 
ZendCon 2017 - Build a Bot Workshop - Async Primer
ZendCon 2017 - Build a Bot Workshop - Async PrimerZendCon 2017 - Build a Bot Workshop - Async Primer
ZendCon 2017 - Build a Bot Workshop - Async Primer
 
Symfony Live San Franciso 2017 - BDD API Development with Symfony and Behat
Symfony Live San Franciso 2017 - BDD API Development with Symfony and BehatSymfony Live San Franciso 2017 - BDD API Development with Symfony and Behat
Symfony Live San Franciso 2017 - BDD API Development with Symfony and Behat
 

Recently uploaded

CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 

Recently uploaded (20)

VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 

E D - Environmental Dependencies in Python

  • 2. Building Highly Complex Systems Many pieces acting as one Image by Alan_D from Crawley, United Kingdom - Nissan GTR Cutaway, CC BY 2.0, https://commons.wikimedia.org/w/index.php?curid=18072247
  • 3. Building Open Source Business Systems Using what you can find to build what you need Image byy Mick from England (Go Kart Buggy) [CC BY 2.0 (http://creativecommons.org/licenses/by/2.0)], via Wikimedia Commons
  • 4. Python Tools Core tools for dependency management in Python Image by Alexander Baxevanis (Flickr: Cooper's tools) [CC BY 2.0 (http://creativecommons.org/licenses/by/2.0)], via Wikimedia Commons
  • 5. One Language Multiple Tools Dependency Management  Easy Install – deprecated  Distutils – deprecated  Setuptools – project dependencies  PIP – environment dependencies Environment Management  venv – Python 3.3+  Virtualenv – Virtual environments  Virtualenvwrapper – Enhancements for Virtualenv
  • 6. setuptools Project dependency management Image by ParentingPatch (Own work) [CC BY-SA 3.0 (http://creativecommons.org/licenses/by-sa/3.0)], via Wikimedia Commons
  • 7. Setuptools – Project Dependency Tool  Defines package information: name, version, authors, etc.  Defines package and test dependency requirements for project source  Should define as wide a range as possible for dependency versions  Builds distributions  Publishes distributions to PyPI  Defines scripts to install as binaries  Provides runtime support for C modules  Can be used for test bootstrapping
  • 9. Setuptools setup.py … setup(name='launchkey-python', version='1.3.0', … install_requires= [ 'pycrypto >= 2.6.1', 'pycrypto < 3.0.0', 'requests >= 2.5.1', 'requests < 3.0.0', 'six >= 1.10.0', 'six < 2.0.0', ], tests_require=[ 'Mocker==1.1.1', 'mock==1.3.0' ], )
  • 10. pip Environment dependency management Image © Dietmar Rabich, rabich.de - Own work, CC BY-SA 4.0, https://commons.wikimedia.org/w/index.php?curid=34239265
  • 11. PIP Requirements File Overview  Contains information for repeatable installs  Can include command line options  Can use a constraints file for multi-project dependency version overrides. Helpful for using patched forks  Can be built with the freeze command Example --index-url=https://my-pypi.example.com pycrypto==2.6.1 requests==2.10.0 six==1.10.0
  • 12. PIP Freeze $ pip freeze > requirements.txt cat requirements.txt launchkey-python==1.3.0 pycrypto==2.6.1 requests==2.10.0 six==1.10.0 Use the PIP freeze command to generate a requirements file based on the currently installed versions.
  • 13. Virtual Environments Different parts for different projects Image by EncMstr (Own work) [GFDL (http://www.gnu.org/copyleft/fdl.html) or CC BY-SA 4.0-3.0-2.5-2.0-1.0 (http://creativecommons.org/licenses/by-sa/4.0-3.0-2.5-2.0-1.0)], via Wikimedia Commons
  • 14. Virtualenv  Can be installed via PIP  Allows you to switch between “virtual” environments  Virtual environments are full copies with symbolically linked, or optionally copied, python binaries including pip.  Private set of environment variables  Private set of installed packages  Can be told which Python executable to use  Environments can be easily activated and deactivated  Deleting created directory remove virtual environments
  • 15. Usage $ which python /usr/local/bin/python $ virtualenv --prompt "(sdk) ” .venv … Installing setuptools, pip, wheel...done. $ source .venv/bin/activate (sdk) $ which python /.venv/bin/python (sdk) $ deactivate $ which python /usr/local/bin/python Simple example for creating, activating, and deactivating virtual environments with Virtualenv
  • 16. Virtualenvwrapper  Can be installed via PIP  Adds additional functionality to Virtualenv  Uses named rather than location based environments  Places reusable environments in user directory  Auto-complete for enabling and removing environments  Defaults prompt prefix to environment name  If directory is same name as project. Enable with directory location
  • 17. Usage $ which python /usr/local/bin/python $ mkvirtualenv example … Installing setuptools, pip, wheel...done. (example) $ which python ~/.virtualenvs/example/bin/python (sdk) $ deactivate $ which python /usr/local/bin/python Simple example for creating, activating, and deactivating virtual environments
  • 18. Pyenv  Manage any number of Python executable versions  Great for open source projects that need to run on multiple versions  Has Virtualenv support via an add-on to support mixing Python executable versions and virtual environments in a manner similar to rbenv.  On Mac, make sure XCode and Command Line Developer Tools are up to date.
  • 19. Usage $ which python3 $ pyenv install 3.5.2 Downloading Python-3.5.2.tgz... -> https://www.python.org/ftp/python/3.5.2/Python- 3.5.2.tgz Installing Python-3.5.2... Installed Python-3.5.2 to ~/.pyenv/versions/3.5.2 $ pyenv global 3.5.2 $ python3 --version Python 3.5.2 Simple example for installing and using a Python version
  • 20. Further Reading  Packaging: https://packaging.python.org/  Python Versioning: https://www.python.org/dev/peps/pep-0440/  Setuptools: https://setuptools.readthedocs.io/en/latest/  PIP: https://pip.pypa.io/en/stable/  PIP Version Resolving: https://github.com/pypa/pip/issues/988  Virtualenv: https://virtualenv.pypa.io/en/stable/  Virtualenvwrapper: http://virtualenvwrapper.readthedocs.io/en/latest/index.html  Pyenv: https://github.com/yyuu/pyenv

Editor's Notes

  1. Modern applications are much like this Nissan GTR. Users of your application see a pleasantly crafter user interface. The myriad of dependent systems are hidden away. These systems interact via well defined interfaces and can be swapped out for a newer version of the part as it comes along and the user wouldn’t know the difference. In many vehicles, entire subsystems are built by entirely different companies and available either as stock or aftermarket upgrades. Your application is no different.
  2. Go karts are very similar to a GT-R. They are four wheeled rear wheel drive automobiles. They don’t have as many features as GT-R but they both do basically the same thing: go, stop, and turn. The biggest difference between them is the amount of design and engineering time put into them. For the car alone, it takes two to four years of design. Remember that that includes mostly ready made parts. The amount of time and engineering it takes for those is astronomical as well. They make up for the time in those parts by using them on multiple products. What most of us build are much less complex and we don’t build most of the pieces. We start with a framework and cobble together bits and pieces to build a functional application as quickly and efficiently as possible.
  3. Environments refer to python interpreter and a set of installed modules and extensions. Much like a factory, without environment tools, you would need reset the line by uninstalling current modules and extensions and installing the ones you need. By default, each Python executable has only one environment. You can make pseudo-environments by altering paths and setting environment variables but there is a better way. You can get project specific virtual environments with a few simple tools.