SlideShare a Scribd company logo
Pipfile, pipenv, pip…
what?!
Ivan Chernov, November 2017
About me
● Python developer @ Ostrovok.ru
● Maintain and develop:
○ Site backend
○ Email marketing platform
○ Booking service
Agenda
● Your project workflow
● Improve it with <spoiler>
● Why we need Pipfile?
● Quick intro to pipenv
● Summary
Setup your project
$ pip install django
Setup your project
$ pip install django
$ pip freeze > requirements.txt
Setup your project
$ pip install django
$ pip freeze > requirements.txt
$ cat requirements.txt
Setup your project
$ pip install django
$ pip freeze > requirements.txt
$ cat requirements.txt
...
docker-compose==1.16.1
docker-pycreds==0.2.1
Django==1.11.5
...
>_< Virtualenv first
$ python -m venv .venv
>_< Virtualenv first
$ python -m venv .venv
$ . .venv/bin/activate
>_< Virtualenv first
$ python -m venv .venv
$ . .venv/bin/activate
(.venv) $ pip install django
>_< Virtualenv first
$ python -m venv .venv
$ . .venv/bin/activate
(.venv) $ pip install django
(.venv) $ pip freeze > requirements.txt
>_< Virtualenv first
$ python -m venv .venv
$ . .venv/bin/activate
(.venv) $ pip install django
(.venv) $ pip freeze > requirements.txt
(.venv) $ cat requirements.txt
>_< Virtualenv first
$ python -m venv .venv
$ . .venv/bin/activate
(.venv) $ pip install django
(.venv) $ pip freeze > requirements.txt
(.venv) $ cat requirements.txt
Django==1.11.5
pytz==2017.2
How many deps?
$ cat requirements.txt | wc -l
Too many...
$ cat requirements.txt | wc -l
125
Deps question I
$ cat requirements.txt | wc -l
125
● Are all of deps pinned?
Deps question II
$ cat requirements.txt | wc -l
125
● Are all of deps pinned?
● No conflicts in sub-deps?
Deps question III
$ cat requirements.txt | wc -l
125
● Are all of deps pinned?
● No conflicts in sub-deps?
● How to view dependency tree?
Deps question IV
$ cat requirements.txt | wc -l
125
● Are all of deps pinned?
● No conflicts in sub-deps?
● How to view dependency tree?
● How to divide prod/dev/test deps?
Use pipenv pip-tools
Intro to pip-tools
$ [sudo] pip install pip-tools
Intro to pip-tools
$ [sudo] pip install pip-tools
$ echo django >> requirements.in
Intro to pip-tools
$ [sudo] pip install pip-tools
$ echo django >> requirements.in
$ pip-compile --output-file requirements.txt requirements.in
Intro to pip-tools
$ [sudo] pip install pip-tools
$ echo django >> requirements.in
$ pip-compile --output-file requirements.txt requirements.in
$ cat requirements.txt
Intro to pip-tools
$ [sudo] pip install pip-tools
$ echo django >> requirements.in
$ pip-compile --output-file requirements.txt requirements.in
$ cat requirements.txt
django==1.11.5
pytz==2017.2 # via django
Intro to pip-tools
$ [sudo] pip install pip-tools
$ echo django >> requirements.in
$ pip-compile --output-file requirements.txt requirements.in
$ cat requirements.txt
django==1.11.5
pytz==2017.2 # via django
Problem solved(?)
Moving to libraries
● We have setuptools
Moving to libraries
● We have setuptools
● Which is used in setup.py
Moving to libraries
● We have setuptools
● Which is used in setup.py
● And what if setup.py contains external deps?
Moving to libraries
● We have setuptools
● Which is used in setup.py
● And what if setup.py contains external deps?
● Pip will fail to install
Pipfile (PEP 518)
● Rationale: give dev ability to specify build system
● Implementation:
○ toml file in root called Pipfile
○ json file for locking Pipfile.lock
○ WIP installation through pip install -p
Rejected formats (from PEP)
● JSON - human-readable, but not human-editable
Rejected formats (from PEP)
● JSON - human-readable, but not human-editable
● Configparser - Python stdlib, but confusing
Rejected formats (from PEP)
● JSON - human-readable, but not human-editable
● Configparser - Python stdlib, but confusing
● Python literals (dict) - Cannot be parsed in other
languages
Rejected formats (from PEP)
● JSON - human-readable, but not human-editable
● Configparser - Python stdlib, but confusing
● Python literals (dict) - Cannot be parsed in other
languages
● YAML
Rejected formats (from PEP)
● JSON - human-readable, but not human-editable
● Configparser - Python stdlib, but confusing
● Python literals (dict) - Cannot be parsed in other
languages
● YAML
○ Specification == 86 pages (== too difficult)
Rejected formats (from PEP)
● JSON - human-readable, but not human-editable
● Configparser - Python stdlib, but confusing
● Python literals (dict) - Cannot be parsed in other
languages
● YAML
○ Specification == 86 pages (== too difficult)
○ Is not safe by default (command execution vuln.)
Rejected formats (from PEP)
● JSON - human-readable, but not human-editable
● Configparser - Python stdlib, but confusing
● Python literals (dict) - Cannot be parsed in other
languages
● YAML
○ Specification == 86 pages (== too difficult)
○ Is not safe by default (command execution vuln.)
○ Pip will need to vendor PyYAML (~1k LOC Python & C code)
Pipfile I
[[source]]
url = 'https://pypi.python.org/simple'
verify_ssl = true
name = 'pypi'
Pipfile I
[[source]]
url = 'https://pypi.python.org/simple'
verify_ssl = true
name = 'pypi'
Pipfile I
[[source]]
url = 'https://pypi.python.org/simple'
verify_ssl = true
name = 'pypi'
Pipfile II
[packages]
requests = '>2'
django = { git = 'https://github.com/django/django.git', ref
= '1.11.5', editable = true }
pywinusb = { version = "*", os_name = "=='nt'",
index="pypi"}
[dev-packages]
pytest = '*'
Pipfile II
[packages]
requests = '>2'
django = { git = 'https://github.com/django/django.git', ref
= '1.11.5', editable = true }
pywinusb = { version = "*", os_name = "=='nt'",
index="pypi"}
[dev-packages]
pytest = '*'
Pipfile II
[packages]
requests = '>2'
django = { git = 'https://github.com/django/django.git', ref
= '1.11.5', editable = true }
pywinusb = { version = "*", os_name = "=='nt'",
index="pypi"}
[dev-packages]
pytest = '*'
Pipfile II
[packages]
requests = '>2'
django = { git = 'https://github.com/django/django.git', ref
= '1.11.5', editable = true }
pywinusb = { version = "*", os_name = "=='nt'",
index="pypi"}
[dev-packages]
pytest = '*'
Pipfile II
[packages]
requests = '>2'
django = { git = 'https://github.com/django/django.git', ref
= '1.11.5', editable = true }
pywinusb = { version = "*", os_name = "=='nt'",
index="pypi"}
[dev-packages]
pytest = '*'
How to use it?
[sudo] pip install pipenv
What is Pipenv?
● Sacred Marriage of Pipfile, Pip, Pip-tools, & Virtualenv.
● From Kenneth Reitz: requests, autoenv
● Automatically manages
○ Pipfile
○ Pipfile.lock
○ virtualenv
Project with requirements.txt
$ cd your/project/dir
$ pipenv install
Requirements.txt found, instead of Pipfile! Converting…
Custom pypi fail :(
$ cd your/project/dir
$ pipenv install
Requirements.txt found, instead of Pipfile! Converting…
# but for custom pypi, there will be error on lock :(
$ sed -i s/pypi.python.org/pypi.example.org/g Pipfile
$ cd your/project/dir
$ pipenv run python django-admin startproject
How to use? I
$ cd your/project/dir
$ pipenv shell
(.venv) $ django-admin
How to use? II
How to use with Docker?
$ pipenv lock
# In Dockerfile
WORKDIR /your/dir/
COPY Pipfile Pipfile.lock /your/dir/
RUN pipenv install --system
# to install libs in system folder
Summary
Pros
● All your deps are locked
Cons
Summary
Pros
● All your deps are locked
● All your venvs are in .local
Cons
Summary
Pros
● All your deps are locked
● All your venvs are in .local
● Ability to separate dev/prod
Cons
Summary
Pros
● All your deps are locked
● All your venvs are in .local
● Ability to separate dev/prod
● Pip will support this file
Cons
Summary
Pros
● All your deps are locked
● All your venvs are in .local
● Ability to separate dev/prod
● Pip will support this file
Cons
● Not mature :(
Summary
Pros
● All your deps are locked
● All your venvs are in .local
● Ability to separate dev/prod
● Pip will support this file
Cons
● Not mature :(
● Dockerfile will miss cache
Summary
Pros
● All your deps are locked
● All your venvs are in .local
● Ability to separate dev/prod
● Pip will support this file
Cons
● Not mature :(
● Dockerfile will miss cache
● Harder to update package
Links
● PEP https://www.python.org/dev/peps/pep-0518/
● Pipfile repo https://github.com/pypa/pipfile
● Pipenv repo https://github.com/pypa/pipfile
● Cheetsheet
https://robots.thoughtbot.com/how-to-manage-your-python-projects-with-
pipenv
Hiring!
Yes, t.me/vanadium23
Questions?
P.S. follow me → @vanadium23

More Related Content

What's hot

Test Driven Development with Puppet - PuppetConf 2014
Test Driven Development with Puppet - PuppetConf 2014Test Driven Development with Puppet - PuppetConf 2014
Test Driven Development with Puppet - PuppetConf 2014
Puppet
 
Tracking huge files with Git LFS (GlueCon 2016)
Tracking huge files with Git LFS (GlueCon 2016)Tracking huge files with Git LFS (GlueCon 2016)
Tracking huge files with Git LFS (GlueCon 2016)
Tim Pettersen
 
Modern Perl for the Unfrozen Paleolithic Perl Programmer
Modern Perl for the Unfrozen Paleolithic  Perl ProgrammerModern Perl for the Unfrozen Paleolithic  Perl Programmer
Modern Perl for the Unfrozen Paleolithic Perl Programmer
John Anderson
 
Ninja Git: Save Your Master
Ninja Git: Save Your MasterNinja Git: Save Your Master
Ninja Git: Save Your Master
Nicola Paolucci
 
PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch
PHP 5.3 and PHP 6; a look ahead - Stefan PriebschPHP 5.3 and PHP 6; a look ahead - Stefan Priebsch
PHP 5.3 and PHP 6; a look ahead - Stefan Priebschdpc
 
Installing GravCMS
Installing GravCMSInstalling GravCMS
Installing GravCMS
George Sumpster
 
Happy porting x86 application to android
Happy porting x86 application to androidHappy porting x86 application to android
Happy porting x86 application to android
Owen Hsu
 
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...
Puppet
 
Modern Perl for the Unfrozen Paleolithic Perl Programmer
Modern Perl for the Unfrozen Paleolithic Perl ProgrammerModern Perl for the Unfrozen Paleolithic Perl Programmer
Modern Perl for the Unfrozen Paleolithic Perl Programmer
John Anderson
 
PHP 5.3 And PHP 6 A Look Ahead
PHP 5.3 And PHP 6 A Look AheadPHP 5.3 And PHP 6 A Look Ahead
PHP 5.3 And PHP 6 A Look Aheadthinkphp
 
PuppetDB: One Year Faster - PuppetConf 2014
PuppetDB: One Year Faster - PuppetConf 2014PuppetDB: One Year Faster - PuppetConf 2014
PuppetDB: One Year Faster - PuppetConf 2014
Puppet
 
Learning Git with Workflows
Learning Git with WorkflowsLearning Git with Workflows
Learning Git with Workflows
Mosky Liu
 
Puppet loves RSpec, why you should, too
Puppet loves RSpec, why you should, tooPuppet loves RSpec, why you should, too
Puppet loves RSpec, why you should, too
Dennis Rowe
 
Puppet Systems Infrastructure Construction Kit
Puppet Systems Infrastructure Construction KitPuppet Systems Infrastructure Construction Kit
Puppet Systems Infrastructure Construction Kit
Alessandro Franceschi
 
Working with Git
Working with GitWorking with Git
Working with Git
Pete Nicholls
 
Git introduction
Git introductionGit introduction
Git introduction
Kornel Lugosi
 
Open Source Tools for Leveling Up Operations FOSSET 2014
Open Source Tools for Leveling Up Operations FOSSET 2014Open Source Tools for Leveling Up Operations FOSSET 2014
Open Source Tools for Leveling Up Operations FOSSET 2014Mandi Walls
 
systemd and configuration management
systemd and configuration managementsystemd and configuration management
systemd and configuration management
Julien Pivotto
 
Puppet Camp Düsseldorf 2014: Continuously Deliver Your Puppet Code with Jenki...
Puppet Camp Düsseldorf 2014: Continuously Deliver Your Puppet Code with Jenki...Puppet Camp Düsseldorf 2014: Continuously Deliver Your Puppet Code with Jenki...
Puppet Camp Düsseldorf 2014: Continuously Deliver Your Puppet Code with Jenki...
Puppet
 

What's hot (20)

Test Driven Development with Puppet - PuppetConf 2014
Test Driven Development with Puppet - PuppetConf 2014Test Driven Development with Puppet - PuppetConf 2014
Test Driven Development with Puppet - PuppetConf 2014
 
Tracking huge files with Git LFS (GlueCon 2016)
Tracking huge files with Git LFS (GlueCon 2016)Tracking huge files with Git LFS (GlueCon 2016)
Tracking huge files with Git LFS (GlueCon 2016)
 
Modern Perl for the Unfrozen Paleolithic Perl Programmer
Modern Perl for the Unfrozen Paleolithic  Perl ProgrammerModern Perl for the Unfrozen Paleolithic  Perl Programmer
Modern Perl for the Unfrozen Paleolithic Perl Programmer
 
Ninja Git: Save Your Master
Ninja Git: Save Your MasterNinja Git: Save Your Master
Ninja Git: Save Your Master
 
PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch
PHP 5.3 and PHP 6; a look ahead - Stefan PriebschPHP 5.3 and PHP 6; a look ahead - Stefan Priebsch
PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch
 
Installing GravCMS
Installing GravCMSInstalling GravCMS
Installing GravCMS
 
Happy porting x86 application to android
Happy porting x86 application to androidHappy porting x86 application to android
Happy porting x86 application to android
 
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...
 
Modern Perl for the Unfrozen Paleolithic Perl Programmer
Modern Perl for the Unfrozen Paleolithic Perl ProgrammerModern Perl for the Unfrozen Paleolithic Perl Programmer
Modern Perl for the Unfrozen Paleolithic Perl Programmer
 
PHP 5.3 And PHP 6 A Look Ahead
PHP 5.3 And PHP 6 A Look AheadPHP 5.3 And PHP 6 A Look Ahead
PHP 5.3 And PHP 6 A Look Ahead
 
PuppetDB: One Year Faster - PuppetConf 2014
PuppetDB: One Year Faster - PuppetConf 2014PuppetDB: One Year Faster - PuppetConf 2014
PuppetDB: One Year Faster - PuppetConf 2014
 
Learning Git with Workflows
Learning Git with WorkflowsLearning Git with Workflows
Learning Git with Workflows
 
Puppet loves RSpec, why you should, too
Puppet loves RSpec, why you should, tooPuppet loves RSpec, why you should, too
Puppet loves RSpec, why you should, too
 
Puppet Systems Infrastructure Construction Kit
Puppet Systems Infrastructure Construction KitPuppet Systems Infrastructure Construction Kit
Puppet Systems Infrastructure Construction Kit
 
Working with Git
Working with GitWorking with Git
Working with Git
 
Git introduction
Git introductionGit introduction
Git introduction
 
Open Source Tools for Leveling Up Operations FOSSET 2014
Open Source Tools for Leveling Up Operations FOSSET 2014Open Source Tools for Leveling Up Operations FOSSET 2014
Open Source Tools for Leveling Up Operations FOSSET 2014
 
nginx mod PSGI
nginx mod PSGInginx mod PSGI
nginx mod PSGI
 
systemd and configuration management
systemd and configuration managementsystemd and configuration management
systemd and configuration management
 
Puppet Camp Düsseldorf 2014: Continuously Deliver Your Puppet Code with Jenki...
Puppet Camp Düsseldorf 2014: Continuously Deliver Your Puppet Code with Jenki...Puppet Camp Düsseldorf 2014: Continuously Deliver Your Puppet Code with Jenki...
Puppet Camp Düsseldorf 2014: Continuously Deliver Your Puppet Code with Jenki...
 

Similar to Pipfile, pipenv, pip… what?!

Virtualenv
VirtualenvVirtualenv
Virtualenv
WEBdeBS
 
Python+gradle
Python+gradlePython+gradle
Python+gradle
Stephen Holsapple
 
Python environments
Python environmentsPython environments
Python environments
Glen Zangirolami
 
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
Codemotion
 
Django dev-env-my-way
Django dev-env-my-wayDjango dev-env-my-way
Django dev-env-my-way
Robert Lujo
 
Python packaging and dependency resolution
Python packaging and dependency resolutionPython packaging and dependency resolution
Python packaging and dependency resolution
Tatiana Al-Chueyr
 
First python project
First python projectFirst python project
First python project
Neetu Jain
 
Django district pip, virtualenv, virtualenv wrapper & more
Django district  pip, virtualenv, virtualenv wrapper & moreDjango district  pip, virtualenv, virtualenv wrapper & more
Django district pip, virtualenv, virtualenv wrapper & more
Jacqueline Kazil
 
PyCon 2013 : Scripting to PyPi to GitHub and More
PyCon 2013 : Scripting to PyPi to GitHub and MorePyCon 2013 : Scripting to PyPi to GitHub and More
PyCon 2013 : Scripting to PyPi to GitHub and MoreMatt Harrison
 
Python Projects at Neova
Python Projects at NeovaPython Projects at Neova
Python Projects at Neova
Sandip Chaudhari
 
Arbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenvArbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenv
Markus Zapke-Gründemann
 
Becoming a Git Master - Nicola Paolucci
Becoming a Git Master - Nicola PaolucciBecoming a Git Master - Nicola Paolucci
Becoming a Git Master - Nicola Paolucci
Atlassian
 
Pinto+Stratopan+Love
Pinto+Stratopan+LovePinto+Stratopan+Love
Pinto+Stratopan+Love
Jeffrey Ryan Thalhammer
 
OpenStack for Centos
OpenStack for CentosOpenStack for Centos
OpenStack for Centos
Chandan Kumar
 
Pipeline as code for your infrastructure as Code
Pipeline as code for your infrastructure as CodePipeline as code for your infrastructure as Code
Pipeline as code for your infrastructure as Code
Kris Buytaert
 
Docker to the Rescue of an Ops Team
Docker to the Rescue of an Ops TeamDocker to the Rescue of an Ops Team
Docker to the Rescue of an Ops Team
Docker, Inc.
 
Docker to the Rescue of an Ops Team
Docker to the Rescue of an Ops TeamDocker to the Rescue of an Ops Team
Docker to the Rescue of an Ops Team
Rachid Zarouali
 
Docker for data science
Docker for data scienceDocker for data science
Docker for data science
Calvin Giles
 
Arbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenvArbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenv
Markus Zapke-Gründemann
 
Python Dependency Management - PyconDE 2018
Python Dependency Management - PyconDE 2018Python Dependency Management - PyconDE 2018
Python Dependency Management - PyconDE 2018
Patrick Muehlbauer
 

Similar to Pipfile, pipenv, pip… what?! (20)

Virtualenv
VirtualenvVirtualenv
Virtualenv
 
Python+gradle
Python+gradlePython+gradle
Python+gradle
 
Python environments
Python environmentsPython environments
Python environments
 
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
 
Django dev-env-my-way
Django dev-env-my-wayDjango dev-env-my-way
Django dev-env-my-way
 
Python packaging and dependency resolution
Python packaging and dependency resolutionPython packaging and dependency resolution
Python packaging and dependency resolution
 
First python project
First python projectFirst python project
First python project
 
Django district pip, virtualenv, virtualenv wrapper & more
Django district  pip, virtualenv, virtualenv wrapper & moreDjango district  pip, virtualenv, virtualenv wrapper & more
Django district pip, virtualenv, virtualenv wrapper & more
 
PyCon 2013 : Scripting to PyPi to GitHub and More
PyCon 2013 : Scripting to PyPi to GitHub and MorePyCon 2013 : Scripting to PyPi to GitHub and More
PyCon 2013 : Scripting to PyPi to GitHub and More
 
Python Projects at Neova
Python Projects at NeovaPython Projects at Neova
Python Projects at Neova
 
Arbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenvArbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenv
 
Becoming a Git Master - Nicola Paolucci
Becoming a Git Master - Nicola PaolucciBecoming a Git Master - Nicola Paolucci
Becoming a Git Master - Nicola Paolucci
 
Pinto+Stratopan+Love
Pinto+Stratopan+LovePinto+Stratopan+Love
Pinto+Stratopan+Love
 
OpenStack for Centos
OpenStack for CentosOpenStack for Centos
OpenStack for Centos
 
Pipeline as code for your infrastructure as Code
Pipeline as code for your infrastructure as CodePipeline as code for your infrastructure as Code
Pipeline as code for your infrastructure as Code
 
Docker to the Rescue of an Ops Team
Docker to the Rescue of an Ops TeamDocker to the Rescue of an Ops Team
Docker to the Rescue of an Ops Team
 
Docker to the Rescue of an Ops Team
Docker to the Rescue of an Ops TeamDocker to the Rescue of an Ops Team
Docker to the Rescue of an Ops Team
 
Docker for data science
Docker for data scienceDocker for data science
Docker for data science
 
Arbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenvArbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenv
 
Python Dependency Management - PyconDE 2018
Python Dependency Management - PyconDE 2018Python Dependency Management - PyconDE 2018
Python Dependency Management - PyconDE 2018
 

Recently uploaded

Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
Fwdays
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 

Recently uploaded (20)

Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 

Pipfile, pipenv, pip… what?!

  • 1. Pipfile, pipenv, pip… what?! Ivan Chernov, November 2017
  • 2. About me ● Python developer @ Ostrovok.ru ● Maintain and develop: ○ Site backend ○ Email marketing platform ○ Booking service
  • 3. Agenda ● Your project workflow ● Improve it with <spoiler> ● Why we need Pipfile? ● Quick intro to pipenv ● Summary
  • 4. Setup your project $ pip install django
  • 5. Setup your project $ pip install django $ pip freeze > requirements.txt
  • 6. Setup your project $ pip install django $ pip freeze > requirements.txt $ cat requirements.txt
  • 7. Setup your project $ pip install django $ pip freeze > requirements.txt $ cat requirements.txt ... docker-compose==1.16.1 docker-pycreds==0.2.1 Django==1.11.5 ...
  • 8. >_< Virtualenv first $ python -m venv .venv
  • 9. >_< Virtualenv first $ python -m venv .venv $ . .venv/bin/activate
  • 10. >_< Virtualenv first $ python -m venv .venv $ . .venv/bin/activate (.venv) $ pip install django
  • 11. >_< Virtualenv first $ python -m venv .venv $ . .venv/bin/activate (.venv) $ pip install django (.venv) $ pip freeze > requirements.txt
  • 12. >_< Virtualenv first $ python -m venv .venv $ . .venv/bin/activate (.venv) $ pip install django (.venv) $ pip freeze > requirements.txt (.venv) $ cat requirements.txt
  • 13. >_< Virtualenv first $ python -m venv .venv $ . .venv/bin/activate (.venv) $ pip install django (.venv) $ pip freeze > requirements.txt (.venv) $ cat requirements.txt Django==1.11.5 pytz==2017.2
  • 14.
  • 15. How many deps? $ cat requirements.txt | wc -l
  • 16. Too many... $ cat requirements.txt | wc -l 125
  • 17. Deps question I $ cat requirements.txt | wc -l 125 ● Are all of deps pinned?
  • 18. Deps question II $ cat requirements.txt | wc -l 125 ● Are all of deps pinned? ● No conflicts in sub-deps?
  • 19. Deps question III $ cat requirements.txt | wc -l 125 ● Are all of deps pinned? ● No conflicts in sub-deps? ● How to view dependency tree?
  • 20. Deps question IV $ cat requirements.txt | wc -l 125 ● Are all of deps pinned? ● No conflicts in sub-deps? ● How to view dependency tree? ● How to divide prod/dev/test deps?
  • 22. Intro to pip-tools $ [sudo] pip install pip-tools
  • 23. Intro to pip-tools $ [sudo] pip install pip-tools $ echo django >> requirements.in
  • 24. Intro to pip-tools $ [sudo] pip install pip-tools $ echo django >> requirements.in $ pip-compile --output-file requirements.txt requirements.in
  • 25. Intro to pip-tools $ [sudo] pip install pip-tools $ echo django >> requirements.in $ pip-compile --output-file requirements.txt requirements.in $ cat requirements.txt
  • 26. Intro to pip-tools $ [sudo] pip install pip-tools $ echo django >> requirements.in $ pip-compile --output-file requirements.txt requirements.in $ cat requirements.txt django==1.11.5 pytz==2017.2 # via django
  • 27. Intro to pip-tools $ [sudo] pip install pip-tools $ echo django >> requirements.in $ pip-compile --output-file requirements.txt requirements.in $ cat requirements.txt django==1.11.5 pytz==2017.2 # via django
  • 28.
  • 30. Moving to libraries ● We have setuptools
  • 31. Moving to libraries ● We have setuptools ● Which is used in setup.py
  • 32. Moving to libraries ● We have setuptools ● Which is used in setup.py ● And what if setup.py contains external deps?
  • 33. Moving to libraries ● We have setuptools ● Which is used in setup.py ● And what if setup.py contains external deps? ● Pip will fail to install
  • 34. Pipfile (PEP 518) ● Rationale: give dev ability to specify build system ● Implementation: ○ toml file in root called Pipfile ○ json file for locking Pipfile.lock ○ WIP installation through pip install -p
  • 35. Rejected formats (from PEP) ● JSON - human-readable, but not human-editable
  • 36. Rejected formats (from PEP) ● JSON - human-readable, but not human-editable ● Configparser - Python stdlib, but confusing
  • 37. Rejected formats (from PEP) ● JSON - human-readable, but not human-editable ● Configparser - Python stdlib, but confusing ● Python literals (dict) - Cannot be parsed in other languages
  • 38. Rejected formats (from PEP) ● JSON - human-readable, but not human-editable ● Configparser - Python stdlib, but confusing ● Python literals (dict) - Cannot be parsed in other languages ● YAML
  • 39. Rejected formats (from PEP) ● JSON - human-readable, but not human-editable ● Configparser - Python stdlib, but confusing ● Python literals (dict) - Cannot be parsed in other languages ● YAML ○ Specification == 86 pages (== too difficult)
  • 40. Rejected formats (from PEP) ● JSON - human-readable, but not human-editable ● Configparser - Python stdlib, but confusing ● Python literals (dict) - Cannot be parsed in other languages ● YAML ○ Specification == 86 pages (== too difficult) ○ Is not safe by default (command execution vuln.)
  • 41. Rejected formats (from PEP) ● JSON - human-readable, but not human-editable ● Configparser - Python stdlib, but confusing ● Python literals (dict) - Cannot be parsed in other languages ● YAML ○ Specification == 86 pages (== too difficult) ○ Is not safe by default (command execution vuln.) ○ Pip will need to vendor PyYAML (~1k LOC Python & C code)
  • 42. Pipfile I [[source]] url = 'https://pypi.python.org/simple' verify_ssl = true name = 'pypi'
  • 43. Pipfile I [[source]] url = 'https://pypi.python.org/simple' verify_ssl = true name = 'pypi'
  • 44. Pipfile I [[source]] url = 'https://pypi.python.org/simple' verify_ssl = true name = 'pypi'
  • 45. Pipfile II [packages] requests = '>2' django = { git = 'https://github.com/django/django.git', ref = '1.11.5', editable = true } pywinusb = { version = "*", os_name = "=='nt'", index="pypi"} [dev-packages] pytest = '*'
  • 46. Pipfile II [packages] requests = '>2' django = { git = 'https://github.com/django/django.git', ref = '1.11.5', editable = true } pywinusb = { version = "*", os_name = "=='nt'", index="pypi"} [dev-packages] pytest = '*'
  • 47. Pipfile II [packages] requests = '>2' django = { git = 'https://github.com/django/django.git', ref = '1.11.5', editable = true } pywinusb = { version = "*", os_name = "=='nt'", index="pypi"} [dev-packages] pytest = '*'
  • 48. Pipfile II [packages] requests = '>2' django = { git = 'https://github.com/django/django.git', ref = '1.11.5', editable = true } pywinusb = { version = "*", os_name = "=='nt'", index="pypi"} [dev-packages] pytest = '*'
  • 49. Pipfile II [packages] requests = '>2' django = { git = 'https://github.com/django/django.git', ref = '1.11.5', editable = true } pywinusb = { version = "*", os_name = "=='nt'", index="pypi"} [dev-packages] pytest = '*'
  • 50. How to use it?
  • 52. What is Pipenv? ● Sacred Marriage of Pipfile, Pip, Pip-tools, & Virtualenv. ● From Kenneth Reitz: requests, autoenv ● Automatically manages ○ Pipfile ○ Pipfile.lock ○ virtualenv
  • 53. Project with requirements.txt $ cd your/project/dir $ pipenv install Requirements.txt found, instead of Pipfile! Converting…
  • 54. Custom pypi fail :( $ cd your/project/dir $ pipenv install Requirements.txt found, instead of Pipfile! Converting… # but for custom pypi, there will be error on lock :( $ sed -i s/pypi.python.org/pypi.example.org/g Pipfile
  • 55. $ cd your/project/dir $ pipenv run python django-admin startproject How to use? I
  • 56. $ cd your/project/dir $ pipenv shell (.venv) $ django-admin How to use? II
  • 57. How to use with Docker? $ pipenv lock # In Dockerfile WORKDIR /your/dir/ COPY Pipfile Pipfile.lock /your/dir/ RUN pipenv install --system # to install libs in system folder
  • 58. Summary Pros ● All your deps are locked Cons
  • 59. Summary Pros ● All your deps are locked ● All your venvs are in .local Cons
  • 60. Summary Pros ● All your deps are locked ● All your venvs are in .local ● Ability to separate dev/prod Cons
  • 61. Summary Pros ● All your deps are locked ● All your venvs are in .local ● Ability to separate dev/prod ● Pip will support this file Cons
  • 62. Summary Pros ● All your deps are locked ● All your venvs are in .local ● Ability to separate dev/prod ● Pip will support this file Cons ● Not mature :(
  • 63. Summary Pros ● All your deps are locked ● All your venvs are in .local ● Ability to separate dev/prod ● Pip will support this file Cons ● Not mature :( ● Dockerfile will miss cache
  • 64. Summary Pros ● All your deps are locked ● All your venvs are in .local ● Ability to separate dev/prod ● Pip will support this file Cons ● Not mature :( ● Dockerfile will miss cache ● Harder to update package
  • 65. Links ● PEP https://www.python.org/dev/peps/pep-0518/ ● Pipfile repo https://github.com/pypa/pipfile ● Pipenv repo https://github.com/pypa/pipfile ● Cheetsheet https://robots.thoughtbot.com/how-to-manage-your-python-projects-with- pipenv
  • 67. Questions? P.S. follow me → @vanadium23