SlideShare ist ein Scribd-Unternehmen logo
1 von 57
Downloaden Sie, um offline zu lesen
Python+Gradle
Stephen	
  Holsapple	
  
Python	
  
What	
  is	
  setuptools?	
  
#!/usr/bin/env python
from setuptools import setup
setup(
description=README,
author='Stephen Holsapple',
author_email='sholsapp@linkedin.com',
packages=['foo'],
install_requires=[],
)
What	
  is	
  setuptools?	
  Everything.	
  
•  To	
  Python,	
  setuptools	
  is	
  everything.	
  
– Is	
  the	
  core	
  API	
  that	
  most	
  tools	
  nowadays	
  use.	
  
– Is	
  the	
  brains	
  behind:	
  
•  Build	
  
•  Packaging	
  
•  Metadata	
  discovery	
  
•  Dependency	
  management	
  
Building	
  w/	
  setuptools
•  Tools	
  like	
  virtualenv	
  and	
  pip	
  make	
  life	
  
preHy	
  good.	
  
More	
  about	
  virtualenv	
  
$ virtualenv my-env
$ source my-env/bin/activate
(my-env)$ python
Python 2.7.5
>>> import sys
>>> sys.path
['./my-env/lib/python2.7/site-
packages']
(my-env) $ deactivate
$
More	
  about	
  virtualenv
•  A	
  command	
  line	
  tool	
  useful	
  for:	
  
– CreaJng	
  isolated	
  Python	
  environments.	
  
•  Really,	
  a	
  plaLorm	
  to	
  solve	
  dependency	
  and	
  
version	
  problems.	
  
More	
  about	
  pip
•  A	
  command	
  line	
  tool	
  useful	
  for:	
  
– Finding	
  dependencies	
  
– Installing	
  dependencies	
  
– ArJfact	
  management	
  
– Caching	
  
•  Really,	
  an	
  implementaJon	
  of	
  the	
  
setuptools	
  programming	
  interface.	
  
More	
  about	
  pip
(my-env)$ pip install requests
Downloading/unpacking requests
Downloading requests-2.7.0-py2.py3-none-
any.whl (470kB): 470kB downloaded
Installing collected packages: requests
Successfully installed requests
Cleaning up...
Building	
  w/	
  setuptools	
  
(my-env)$ pip install requests
(my-env)$ python
>>> import requests
>>> ...
Packaging	
  w/	
  setuptools
•  Tools	
  like	
  setuptools,	
  pip, pex	
  make	
  life	
  
preHy	
  good.	
  
– Source	
  distribuJons	
  
– Binary	
  distribuJons	
  
– Deployable	
  distribuJon	
  
Metadata	
  w/	
  setuptools
•  Doesn't	
  provide	
  great	
  ways	
  to:	
  
– Reason	
  about	
  builds	
  before/aOer	
  
– Reason	
  about	
  arJfacts	
  programaJcally	
  
•  Does	
  expose	
  programming	
  interfaces	
  to	
  
integrate	
  with	
  exisJng	
  metadata	
  systems.	
  
•  Requires	
  us	
  to	
  evaluate	
  Python	
  to	
  query	
  about	
  
metadata.	
  
Metadata	
  w/	
  setuptools
(my-env)$ pip show requests
---
Name: requests
Version: 2.7.0
Location: my-env/lib/python2.7/site-packages
Requires:
(my-env)$ pip freeze
requests==2.7.0
wsgiref==0.1.2
Dependencies	
  w/	
  setuptools
#!/usr/bin/env python
import setuptools
setuptools.setup(,
# ...
install_requires=[
"requests>=2.6",
"pyOpenSSL==0.15",
"urllib3",
],
# ...
)
Dependencies	
  w/	
  pip
$ cat requirements.txt
requests>=2.6
pyOpenSSL==0.15
urllib3
[pip/issues/988]
“Requirements	
  files	
  are	
  
used	
  to	
  force	
  pip	
  to	
  
properly	
  resolve	
  
dependencies.	
  As	
  it	
  is	
  now,	
  
pip	
  doesn't	
  have	
  true	
  
dependency	
  resolu=on,	
  
but	
  instead	
  simply	
  uses	
  
the	
  first	
  specifica=on	
  it	
  
finds	
  for	
  a	
  project.”	
  
pkg_resources	
  is	
  greedy	
  
•  Simply	
  use	
  the	
  first	
  specificaJon	
  found	
  for	
  a	
  
dependency.	
  
•  Ask	
  developers	
  to	
  pin	
  all	
  of	
  their	
  
dependencies.	
  
– pip freeze > requirements.txt
[VersionConflict]
pkg_resources.VersionConflict:
(requests 2.6.2,
Requirement.parse('requests<=2.6.0')
[DistributionNotFound]
pip.exceptions.DistributionNotFound:
No distributions at all found for
requests
Future	
  Work	
  
•  Sincere	
  thanks	
  to	
  
Donald	
  StuS	
  et	
  al.	
  on	
  
PyPA	
  working	
  to	
  
improve	
  state	
  of	
  
Python	
  packaging.	
  
•  Python	
  is	
  rapidly	
  
changing	
  for	
  the	
  
beHer.	
  
Python	
  
•  Report	
  card	
  
– Ecosystem	
  (great)	
  
– Build	
  System	
  (good)	
  
– Packaging	
  (good)	
  
– Metadata	
  (okay)	
  
– Dependency	
  Management	
  (bad)	
  
Scaling	
  Products	
  
•  Builds	
  
•  ArJfacts	
  
– Downloading	
  
– Caching	
  
– Metadata	
  
•  Dependencies	
  
– Dependency	
  ResoluJon	
  
– Conflict	
  ResoluJon	
  
•  TesJng	
  
Building	
  BeHer	
  Building	
  Systems	
  
•  We	
  have	
  a	
  core	
  set	
  of	
  great	
  tools	
  to	
  work	
  
with:	
  
– virtualenv
– setuptools
– pip
– pex
A	
  polite	
  tool	
  
•  The	
  pip	
  tool	
  is	
  polite	
  because:	
  
– Allows	
  for	
  customizaJon	
  or	
  disabling	
  of	
  
setuptools	
  and	
  pip	
  features:	
  
•  --index-url
•  --extra-index-url
•  --no-deps
– Allows	
  us	
  to	
  use	
  local	
  repositories.	
  
– Allows	
  us	
  to	
  solve	
  our	
  problems	
  our	
  way.	
  
#!/bin/build.sh	
  
vinit && source activate
python setup.py install
py.test
python setup.py sdist
#!/bin/build.sh	
  
vinit && source activate
python setup.py install
py.test
python setup.py sdist
pip wheel .
#!/bin/build.sh
vinit && source activate
for dep in $( cache/ ); do
pip install --no-deps dep
done
python setup.py install
py.test
python setup.py sdist
#!/bin/build.sh
vinit && source activate
for dep in $( ???/ ); do
pip install --no-deps dep
done
python setup.py install
py.test
python setup.py sdist
Gradle	
  
#!/bin/build.sh
vinit && source activate
for dep in $( gradle/ ); do
pip install --no-deps dep
done
python setup.py install
py.test
python setup.py sdist
Philosophy	
  
Let’s	
  let	
  Python	
  do	
  what	
  Python	
  is	
  
good	
  at	
  and	
  let	
  Gradle	
  do	
  what	
  Gradle	
  
is	
  good	
  at.	
  
Gradle	
  as	
  a	
  Build	
  Orchestrator	
  
•  First,	
  resolve	
  my	
  dependencies
•  Second,	
  run	
  my	
  build
– pip install --no-deps dep
•  Third,	
  run	
  my	
  package
– python setup.py sdist
•  Last,	
  run	
  my	
  publish
build.gradle
apply plugin: 'python-venv'
apply plugin: 'python-sdist'
sdist {
sourceDirectory 'src'
}
build.gradle
apply plugin: 'python-venv'
apply plugin: 'python-pex'
sdist {
sourceDirectory 'src'
}
Enhancing	
  Python	
  
•  Represent	
  arJfacts	
  and	
  dependencies	
  in	
  a	
  way	
  
Gradle	
  can	
  understand.	
  
•  Integrate	
  exisJng	
  metadata	
  with	
  setuptools	
  
using	
  custom	
  distribuJon	
  class.	
  
RepresenJng	
  Dependencies	
  
<ivy-module version="1.0">
<info module="cryptography" revision="0.8.2" />
<publications>
<artifact name="cryptography" conf="default"/>
</publications>
<dependencies>
<dependency name="pyasn1" rev="0.1.7" />
<dependency name="six" rev="1.9.0" />
<dependency name="setuptools" rev="3.4.4" />
<dependency name="enum34" rev="1.0.4" />
<dependency name="cffi" rev="0.9.2" />
</dependencies>
</ivy-module>
The	
  Cheese	
  Shop	
  
•  Python	
  Package	
  Index	
  (PyPI)	
  
– Community	
  hosts	
  packages	
  here	
  
– Cannot	
  modify	
  packages	
  here	
  
•  Internal	
  Python	
  Package	
  Index	
  
– ArJfactory	
  
– Add	
  Ivy	
  metadata	
  for	
  packages	
  
IntegraJng	
  Metadata	
  
•  How	
  to	
  marry	
  setuptools	
  with	
  custom	
  
metadata	
  systems.	
  
– Product	
  names	
  
– Product	
  versions	
  
– SpecificaJon	
  files	
  
– Dependencies	
  
IntegraJng	
  Metadata	
  
#!/usr/bin/env python2.6
import setuptools
from distgradle import GradleDistribution
setuptools.setup(
distclass=GradleDistribution,
package_dir={'': 'src'},
packages=setuptools.find_packages('src'),
include_package_data=True,
namespace_packages=['linkedin'],
)
Gradle	
  Infrastructure	
  
•  python-product
– Your	
  enterprise	
  build	
  logic,	
  covering	
  everything	
  
from	
  your	
  resoluJon	
  strategies,	
  your	
  repositories,	
  
your	
  metadata,	
  and	
  more.	
  
– You	
  could	
  write	
  a	
  simple	
  plugin	
  that	
  simply	
  defers	
  
to	
  setuptools,	
  if	
  you	
  want.	
  
Gradle	
  Plugins	
  
•  python-venv
– Builds	
  a	
  local	
  environment	
  
•  python-sdist
– Build	
  a	
  source	
  distribuJon	
  using	
  setuptools.	
  
•  python-wheel	
  
– Build	
  a	
  wheel	
  distribuJon	
  using	
  setuptools.	
  
•  python-pex
– Build	
  a	
  pex	
  distribuJon	
  using	
  pex.	
  
python-venv	
  
•  Under	
  the	
  hood:	
  
– CreaJng	
  a	
  virtual	
  environment.	
  
– Installing	
  build	
  requirements.	
  
– Installing	
  your	
  resolved	
  dependencies.	
  
– Installing	
  your	
  project.	
  
– Running	
  tests	
  
– Packaging	
  arJfacts	
  
python-sdist	
  
•  Under	
  the	
  hood:	
  
– Applying	
  python-venv
– Invoking	
  ./setup.py sdist
python-wheel	
  
•  Under	
  the	
  hood:	
  
– Applying	
  python-venv
– Invoking	
  pip wheel
•  Making	
  Python's	
  wheel	
  file	
  compaJble	
  with	
  
Ivy	
  is	
  hard.	
  
python-pex	
  
•  Under	
  the	
  hood:	
  
– Applying	
  python-venv
– Invoking	
  pex
•  Prepare	
  to	
  baHle	
  with	
  pex's	
  dependency	
  
resolver.	
  
python-???	
  
•  ExisJng	
  plugins	
  easy	
  to	
  add	
  now.	
  
•  AddiJonal	
  plugins	
  easy	
  to	
  add	
  later.	
  
•  Mix	
  and	
  match	
  any	
  way	
  we	
  like.	
  
– We	
  might	
  want	
  a	
  source	
  and	
  a	
  wheel	
  distribuJon.	
  
Python+Gradle	
  
•  Report	
  card	
  
– Ecosystem	
  (great)	
  
– Build	
  System	
  (good)	
  
– Packaging	
  (good)	
  
– Metadata	
  (good)	
  
– Dependency	
  Management	
  (great)	
  
What	
  is	
  Gradle	
  doing?	
  
•  Reading	
  specificaJon	
  files	
  
•  Dependency	
  and	
  conflict	
  resoluJon	
  
•  Downloading	
  and	
  caching	
  
•  OrchestraJng	
  creaJon	
  of	
  Python	
  arJfacts	
  
•  CreaJng	
  build	
  metadata	
  
•  Uploading	
  arJfacts	
  
•  PyPI	
  
What	
  is	
  Gradle	
  not	
  doing?	
  
•  Changing	
  how	
  you	
  develop	
  with	
  Python	
  
•  Changing	
  how	
  Python	
  packages	
  arJfacts	
  
•  Changing	
  Python	
  arJfacts	
  themselves	
  
•  Pushing	
  Gradle-­‐isms	
  into	
  Python	
  
Major	
  Wins	
  
•  Dependency	
  Management	
  
•  Plugin	
  Architecture	
  
•  Reusable	
  Logic	
  
•  MulJ-­‐language	
  Builds	
  
MulJ-­‐language	
  Builds	
  
•  One	
  build	
  system	
  to	
  rule	
  them	
  all.	
  
– Java	
  
– Scala	
  
– C/C++	
  
– Javascript	
  
– Python	
  
•  Products	
  can	
  contain	
  different	
  languages	
  
Why	
  Python?	
  
•  Why	
  was	
  Python	
  so	
  easy	
  to	
  build	
  with	
  Gradle?	
  
– Can	
  decouple	
  dep.	
  mgmt.	
  from	
  setuptools
– Can	
  decouple	
  dep.	
  mgmt.	
  from	
  PyPI	
  
– Can	
  represent	
  dependencies	
  with	
  Ivy	
  
•  Other	
  languages	
  like	
  Python	
  can	
  also	
  easily	
  
use	
  Gradle	
  
QuesJons?	
  

Weitere ähnliche Inhalte

Was ist angesagt?

ビッグデータ処理データベースの全体像と使い分け
ビッグデータ処理データベースの全体像と使い分けビッグデータ処理データベースの全体像と使い分け
ビッグデータ処理データベースの全体像と使い分けRecruit Technologies
 
スレッドダンプの読み方
スレッドダンプの読み方スレッドダンプの読み方
スレッドダンプの読み方Funato Takashi
 
データ履歴管理のためのテンポラルデータモデルとReladomoの紹介 #jjug_ccc #ccc_g3
データ履歴管理のためのテンポラルデータモデルとReladomoの紹介 #jjug_ccc #ccc_g3 データ履歴管理のためのテンポラルデータモデルとReladomoの紹介 #jjug_ccc #ccc_g3
データ履歴管理のためのテンポラルデータモデルとReladomoの紹介 #jjug_ccc #ccc_g3 Hiroshi Ito
 
Nginx勉強会
Nginx勉強会Nginx勉強会
Nginx勉強会Yuji Otani
 
ドメイン駆動設計のための Spring の上手な使い方
ドメイン駆動設計のための Spring の上手な使い方ドメイン駆動設計のための Spring の上手な使い方
ドメイン駆動設計のための Spring の上手な使い方増田 亨
 
Spring Bootの本当の理解ポイント #jjug
Spring Bootの本当の理解ポイント #jjugSpring Bootの本当の理解ポイント #jjug
Spring Bootの本当の理解ポイント #jjugMasatoshi Tada
 
日本語テストメソッドについて
日本語テストメソッドについて日本語テストメソッドについて
日本語テストメソッドについてkumake
 
GitHub ActionsでiOSのCIを実現しよう
GitHub ActionsでiOSのCIを実現しようGitHub ActionsでiOSのCIを実現しよう
GitHub ActionsでiOSのCIを実現しようShinya Nakajima
 
[Cloud OnAir] Google Cloud とつなぐ色々な方法 〜 つなぐ方法をゼロからご紹介します〜 2019年1月31日 放送
[Cloud OnAir] Google Cloud とつなぐ色々な方法 〜 つなぐ方法をゼロからご紹介します〜 2019年1月31日 放送[Cloud OnAir] Google Cloud とつなぐ色々な方法 〜 つなぐ方法をゼロからご紹介します〜 2019年1月31日 放送
[Cloud OnAir] Google Cloud とつなぐ色々な方法 〜 つなぐ方法をゼロからご紹介します〜 2019年1月31日 放送Google Cloud Platform - Japan
 
Hadoop概要説明
Hadoop概要説明Hadoop概要説明
Hadoop概要説明Satoshi Noto
 
1000台規模のHadoopクラスタをHive/Tezアプリケーションにあわせてパフォーマンスチューニングした話
1000台規模のHadoopクラスタをHive/Tezアプリケーションにあわせてパフォーマンスチューニングした話1000台規模のHadoopクラスタをHive/Tezアプリケーションにあわせてパフォーマンスチューニングした話
1000台規模のHadoopクラスタをHive/Tezアプリケーションにあわせてパフォーマンスチューニングした話Yahoo!デベロッパーネットワーク
 
トランザクションスクリプトのすすめ
トランザクションスクリプトのすすめトランザクションスクリプトのすすめ
トランザクションスクリプトのすすめpospome
 
アルゴリズムのイメージを擬人化する
アルゴリズムのイメージを擬人化するアルゴリズムのイメージを擬人化する
アルゴリズムのイメージを擬人化するAtCoder Inc.
 
ビッグデータ処理データベースの全体像と使い分け
2018年version
ビッグデータ処理データベースの全体像と使い分け
2018年versionビッグデータ処理データベースの全体像と使い分け
2018年version
ビッグデータ処理データベースの全体像と使い分け
2018年versionTetsutaro Watanabe
 
Supabase Edge Functions と Netlify Edge Functions を使ってみる – 機能とその比較 –
Supabase Edge Functions と Netlify Edge Functions を使ってみる – 機能とその比較 –Supabase Edge Functions と Netlify Edge Functions を使ってみる – 機能とその比較 –
Supabase Edge Functions と Netlify Edge Functions を使ってみる – 機能とその比較 –虎の穴 開発室
 
CloudFront経由でのCORS利用
CloudFront経由でのCORS利用CloudFront経由でのCORS利用
CloudFront経由でのCORS利用Yuta Imai
 
怖くないSpring Bootのオートコンフィグレーション
怖くないSpring Bootのオートコンフィグレーション怖くないSpring Bootのオートコンフィグレーション
怖くないSpring Bootのオートコンフィグレーション土岐 孝平
 

Was ist angesagt? (20)

ビッグデータ処理データベースの全体像と使い分け
ビッグデータ処理データベースの全体像と使い分けビッグデータ処理データベースの全体像と使い分け
ビッグデータ処理データベースの全体像と使い分け
 
スレッドダンプの読み方
スレッドダンプの読み方スレッドダンプの読み方
スレッドダンプの読み方
 
データ履歴管理のためのテンポラルデータモデルとReladomoの紹介 #jjug_ccc #ccc_g3
データ履歴管理のためのテンポラルデータモデルとReladomoの紹介 #jjug_ccc #ccc_g3 データ履歴管理のためのテンポラルデータモデルとReladomoの紹介 #jjug_ccc #ccc_g3
データ履歴管理のためのテンポラルデータモデルとReladomoの紹介 #jjug_ccc #ccc_g3
 
Nginx勉強会
Nginx勉強会Nginx勉強会
Nginx勉強会
 
HashMapとは?
HashMapとは?HashMapとは?
HashMapとは?
 
Javaメモリ勉強会
Javaメモリ勉強会Javaメモリ勉強会
Javaメモリ勉強会
 
ドメイン駆動設計のための Spring の上手な使い方
ドメイン駆動設計のための Spring の上手な使い方ドメイン駆動設計のための Spring の上手な使い方
ドメイン駆動設計のための Spring の上手な使い方
 
Spring Bootの本当の理解ポイント #jjug
Spring Bootの本当の理解ポイント #jjugSpring Bootの本当の理解ポイント #jjug
Spring Bootの本当の理解ポイント #jjug
 
日本語テストメソッドについて
日本語テストメソッドについて日本語テストメソッドについて
日本語テストメソッドについて
 
GitHub ActionsでiOSのCIを実現しよう
GitHub ActionsでiOSのCIを実現しようGitHub ActionsでiOSのCIを実現しよう
GitHub ActionsでiOSのCIを実現しよう
 
[Cloud OnAir] Google Cloud とつなぐ色々な方法 〜 つなぐ方法をゼロからご紹介します〜 2019年1月31日 放送
[Cloud OnAir] Google Cloud とつなぐ色々な方法 〜 つなぐ方法をゼロからご紹介します〜 2019年1月31日 放送[Cloud OnAir] Google Cloud とつなぐ色々な方法 〜 つなぐ方法をゼロからご紹介します〜 2019年1月31日 放送
[Cloud OnAir] Google Cloud とつなぐ色々な方法 〜 つなぐ方法をゼロからご紹介します〜 2019年1月31日 放送
 
Hadoop概要説明
Hadoop概要説明Hadoop概要説明
Hadoop概要説明
 
1000台規模のHadoopクラスタをHive/Tezアプリケーションにあわせてパフォーマンスチューニングした話
1000台規模のHadoopクラスタをHive/Tezアプリケーションにあわせてパフォーマンスチューニングした話1000台規模のHadoopクラスタをHive/Tezアプリケーションにあわせてパフォーマンスチューニングした話
1000台規模のHadoopクラスタをHive/Tezアプリケーションにあわせてパフォーマンスチューニングした話
 
ヤフー発のメッセージキュー「Pulsar」のご紹介
ヤフー発のメッセージキュー「Pulsar」のご紹介ヤフー発のメッセージキュー「Pulsar」のご紹介
ヤフー発のメッセージキュー「Pulsar」のご紹介
 
トランザクションスクリプトのすすめ
トランザクションスクリプトのすすめトランザクションスクリプトのすすめ
トランザクションスクリプトのすすめ
 
アルゴリズムのイメージを擬人化する
アルゴリズムのイメージを擬人化するアルゴリズムのイメージを擬人化する
アルゴリズムのイメージを擬人化する
 
ビッグデータ処理データベースの全体像と使い分け
2018年version
ビッグデータ処理データベースの全体像と使い分け
2018年versionビッグデータ処理データベースの全体像と使い分け
2018年version
ビッグデータ処理データベースの全体像と使い分け
2018年version
 
Supabase Edge Functions と Netlify Edge Functions を使ってみる – 機能とその比較 –
Supabase Edge Functions と Netlify Edge Functions を使ってみる – 機能とその比較 –Supabase Edge Functions と Netlify Edge Functions を使ってみる – 機能とその比較 –
Supabase Edge Functions と Netlify Edge Functions を使ってみる – 機能とその比較 –
 
CloudFront経由でのCORS利用
CloudFront経由でのCORS利用CloudFront経由でのCORS利用
CloudFront経由でのCORS利用
 
怖くないSpring Bootのオートコンフィグレーション
怖くないSpring Bootのオートコンフィグレーション怖くないSpring Bootのオートコンフィグレーション
怖くないSpring Bootのオートコンフィグレーション
 

Andere mochten auch

Testing: Python, Java, Groovy, etc.
Testing: Python, Java, Groovy, etc.Testing: Python, Java, Groovy, etc.
Testing: Python, Java, Groovy, etc.Russel Winder
 
Learning R via Python…or the other way around
Learning R via Python…or the other way aroundLearning R via Python…or the other way around
Learning R via Python…or the other way aroundSid Xing
 
Androidで動かすはじめてのDeepLearning
Androidで動かすはじめてのDeepLearningAndroidで動かすはじめてのDeepLearning
Androidで動かすはじめてのDeepLearningMiyoshi Kosuke
 
DI(依存性注入)について
DI(依存性注入)についてDI(依存性注入)について
DI(依存性注入)についてYui Ito
 
Deploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGH
Deploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGHDeploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGH
Deploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGHErica Windisch
 

Andere mochten auch (7)

{py}gradle
{py}gradle{py}gradle
{py}gradle
 
{py}gradle
{py}gradle{py}gradle
{py}gradle
 
Testing: Python, Java, Groovy, etc.
Testing: Python, Java, Groovy, etc.Testing: Python, Java, Groovy, etc.
Testing: Python, Java, Groovy, etc.
 
Learning R via Python…or the other way around
Learning R via Python…or the other way aroundLearning R via Python…or the other way around
Learning R via Python…or the other way around
 
Androidで動かすはじめてのDeepLearning
Androidで動かすはじめてのDeepLearningAndroidで動かすはじめてのDeepLearning
Androidで動かすはじめてのDeepLearning
 
DI(依存性注入)について
DI(依存性注入)についてDI(依存性注入)について
DI(依存性注入)について
 
Deploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGH
Deploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGHDeploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGH
Deploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGH
 

Ähnlich wie Python+Gradle Setup

Pipfile, pipenv, pip… what?!
Pipfile, pipenv, pip… what?!Pipfile, pipenv, pip… what?!
Pipfile, pipenv, pip… what?!Ivan Chernoff
 
Python Dependency Management - PyconDE 2018
Python Dependency Management - PyconDE 2018Python Dependency Management - PyconDE 2018
Python Dependency Management - PyconDE 2018Patrick Muehlbauer
 
Arbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenvArbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenvMarkus Zapke-Gründemann
 
ASP.NET 5 auf Raspberry PI & docker
ASP.NET 5 auf Raspberry PI & dockerASP.NET 5 auf Raspberry PI & docker
ASP.NET 5 auf Raspberry PI & dockerJürgen Gutsch
 
Arbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenvArbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenvMarkus Zapke-Gründemann
 
Virtualenv
VirtualenvVirtualenv
VirtualenvWEBdeBS
 
Packaging perl (LPW2010)
Packaging perl (LPW2010)Packaging perl (LPW2010)
Packaging perl (LPW2010)p3castro
 
Practical introduction to dev ops with chef
Practical introduction to dev ops with chefPractical introduction to dev ops with chef
Practical introduction to dev ops with chefLeanDog
 
Using the pip package manager for Odoo
Using the pip package manager for OdooUsing the pip package manager for Odoo
Using the pip package manager for OdooOdoo
 
Using the "pip" package manager for Odoo/OpenERP - Opendays 2014
Using the "pip" package manager for Odoo/OpenERP - Opendays 2014Using the "pip" package manager for Odoo/OpenERP - Opendays 2014
Using the "pip" package manager for Odoo/OpenERP - Opendays 2014Daniel Reis
 
First python project
First python projectFirst python project
First python projectNeetu Jain
 
Python packaging and dependency resolution
Python packaging and dependency resolutionPython packaging and dependency resolution
Python packaging and dependency resolutionTatiana Al-Chueyr
 
The Secrets of The FullStack Ninja - Part A - Session I
The Secrets of The FullStack Ninja - Part A - Session IThe Secrets of The FullStack Ninja - Part A - Session I
The Secrets of The FullStack Ninja - Part A - Session IOded Sagir
 
ASP.NET 5 on the Raspberry PI 2
ASP.NET 5 on the Raspberry PI 2ASP.NET 5 on the Raspberry PI 2
ASP.NET 5 on the Raspberry PI 2Jürgen Gutsch
 
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 TeamDocker, 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 TeamRachid Zarouali
 
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 2017Codemotion
 
Continuous Integration Testing in Django
Continuous Integration Testing in DjangoContinuous Integration Testing in Django
Continuous Integration Testing in DjangoKevin Harvey
 
Welcome to the Cheese Shop: setuptools, virtualenv and PyPUG
Welcome to the Cheese Shop: setuptools, virtualenv and PyPUGWelcome to the Cheese Shop: setuptools, virtualenv and PyPUG
Welcome to the Cheese Shop: setuptools, virtualenv and PyPUGdwvisser
 

Ähnlich wie Python+Gradle Setup (20)

Pipfile, pipenv, pip… what?!
Pipfile, pipenv, pip… what?!Pipfile, pipenv, pip… what?!
Pipfile, pipenv, pip… what?!
 
Python Dependency Management - PyconDE 2018
Python Dependency Management - PyconDE 2018Python Dependency Management - PyconDE 2018
Python Dependency Management - PyconDE 2018
 
Arbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenvArbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenv
 
ASP.NET 5 auf Raspberry PI & docker
ASP.NET 5 auf Raspberry PI & dockerASP.NET 5 auf Raspberry PI & docker
ASP.NET 5 auf Raspberry PI & docker
 
Arbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenvArbeiten mit distribute, pip und virtualenv
Arbeiten mit distribute, pip und virtualenv
 
Virtualenv
VirtualenvVirtualenv
Virtualenv
 
Packaging perl (LPW2010)
Packaging perl (LPW2010)Packaging perl (LPW2010)
Packaging perl (LPW2010)
 
Practical introduction to dev ops with chef
Practical introduction to dev ops with chefPractical introduction to dev ops with chef
Practical introduction to dev ops with chef
 
Using the pip package manager for Odoo
Using the pip package manager for OdooUsing the pip package manager for Odoo
Using the pip package manager for Odoo
 
Using the "pip" package manager for Odoo/OpenERP - Opendays 2014
Using the "pip" package manager for Odoo/OpenERP - Opendays 2014Using the "pip" package manager for Odoo/OpenERP - Opendays 2014
Using the "pip" package manager for Odoo/OpenERP - Opendays 2014
 
First python project
First python projectFirst python project
First python project
 
Python packaging and dependency resolution
Python packaging and dependency resolutionPython packaging and dependency resolution
Python packaging and dependency resolution
 
The Secrets of The FullStack Ninja - Part A - Session I
The Secrets of The FullStack Ninja - Part A - Session IThe Secrets of The FullStack Ninja - Part A - Session I
The Secrets of The FullStack Ninja - Part A - Session I
 
ASP.NET 5 on the Raspberry PI 2
ASP.NET 5 on the Raspberry PI 2ASP.NET 5 on the Raspberry PI 2
ASP.NET 5 on the Raspberry PI 2
 
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
 
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
 
Continuous Integration Testing in Django
Continuous Integration Testing in DjangoContinuous Integration Testing in Django
Continuous Integration Testing in Django
 
Welcome to the Cheese Shop: setuptools, virtualenv and PyPUG
Welcome to the Cheese Shop: setuptools, virtualenv and PyPUGWelcome to the Cheese Shop: setuptools, virtualenv and PyPUG
Welcome to the Cheese Shop: setuptools, virtualenv and PyPUG
 
Virtualenv
VirtualenvVirtualenv
Virtualenv
 

Kürzlich hochgeladen

Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
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 GoalsJhone kinadey
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 

Kürzlich hochgeladen (20)

Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
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
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 

Python+Gradle Setup

  • 3. What  is  setuptools?   #!/usr/bin/env python from setuptools import setup setup( description=README, author='Stephen Holsapple', author_email='sholsapp@linkedin.com', packages=['foo'], install_requires=[], )
  • 4. What  is  setuptools?  Everything.   •  To  Python,  setuptools  is  everything.   – Is  the  core  API  that  most  tools  nowadays  use.   – Is  the  brains  behind:   •  Build   •  Packaging   •  Metadata  discovery   •  Dependency  management  
  • 5. Building  w/  setuptools •  Tools  like  virtualenv  and  pip  make  life   preHy  good.  
  • 6. More  about  virtualenv   $ virtualenv my-env $ source my-env/bin/activate (my-env)$ python Python 2.7.5 >>> import sys >>> sys.path ['./my-env/lib/python2.7/site- packages'] (my-env) $ deactivate $
  • 7. More  about  virtualenv •  A  command  line  tool  useful  for:   – CreaJng  isolated  Python  environments.   •  Really,  a  plaLorm  to  solve  dependency  and   version  problems.  
  • 8. More  about  pip •  A  command  line  tool  useful  for:   – Finding  dependencies   – Installing  dependencies   – ArJfact  management   – Caching   •  Really,  an  implementaJon  of  the   setuptools  programming  interface.  
  • 9. More  about  pip (my-env)$ pip install requests Downloading/unpacking requests Downloading requests-2.7.0-py2.py3-none- any.whl (470kB): 470kB downloaded Installing collected packages: requests Successfully installed requests Cleaning up...
  • 10. Building  w/  setuptools   (my-env)$ pip install requests (my-env)$ python >>> import requests >>> ...
  • 11. Packaging  w/  setuptools •  Tools  like  setuptools,  pip, pex  make  life   preHy  good.   – Source  distribuJons   – Binary  distribuJons   – Deployable  distribuJon  
  • 12. Metadata  w/  setuptools •  Doesn't  provide  great  ways  to:   – Reason  about  builds  before/aOer   – Reason  about  arJfacts  programaJcally   •  Does  expose  programming  interfaces  to   integrate  with  exisJng  metadata  systems.   •  Requires  us  to  evaluate  Python  to  query  about   metadata.  
  • 13. Metadata  w/  setuptools (my-env)$ pip show requests --- Name: requests Version: 2.7.0 Location: my-env/lib/python2.7/site-packages Requires: (my-env)$ pip freeze requests==2.7.0 wsgiref==0.1.2
  • 14. Dependencies  w/  setuptools #!/usr/bin/env python import setuptools setuptools.setup(, # ... install_requires=[ "requests>=2.6", "pyOpenSSL==0.15", "urllib3", ], # ... )
  • 15. Dependencies  w/  pip $ cat requirements.txt requests>=2.6 pyOpenSSL==0.15 urllib3
  • 16. [pip/issues/988] “Requirements  files  are   used  to  force  pip  to   properly  resolve   dependencies.  As  it  is  now,   pip  doesn't  have  true   dependency  resolu=on,   but  instead  simply  uses   the  first  specifica=on  it   finds  for  a  project.”  
  • 17. pkg_resources  is  greedy   •  Simply  use  the  first  specificaJon  found  for  a   dependency.   •  Ask  developers  to  pin  all  of  their   dependencies.   – pip freeze > requirements.txt
  • 20.
  • 21.
  • 22.
  • 23. Future  Work   •  Sincere  thanks  to   Donald  StuS  et  al.  on   PyPA  working  to   improve  state  of   Python  packaging.   •  Python  is  rapidly   changing  for  the   beHer.  
  • 24. Python   •  Report  card   – Ecosystem  (great)   – Build  System  (good)   – Packaging  (good)   – Metadata  (okay)   – Dependency  Management  (bad)  
  • 25. Scaling  Products   •  Builds   •  ArJfacts   – Downloading   – Caching   – Metadata   •  Dependencies   – Dependency  ResoluJon   – Conflict  ResoluJon   •  TesJng  
  • 26. Building  BeHer  Building  Systems   •  We  have  a  core  set  of  great  tools  to  work   with:   – virtualenv – setuptools – pip – pex
  • 27. A  polite  tool   •  The  pip  tool  is  polite  because:   – Allows  for  customizaJon  or  disabling  of   setuptools  and  pip  features:   •  --index-url •  --extra-index-url •  --no-deps – Allows  us  to  use  local  repositories.   – Allows  us  to  solve  our  problems  our  way.  
  • 28. #!/bin/build.sh   vinit && source activate python setup.py install py.test python setup.py sdist
  • 29. #!/bin/build.sh   vinit && source activate python setup.py install py.test python setup.py sdist pip wheel .
  • 30. #!/bin/build.sh vinit && source activate for dep in $( cache/ ); do pip install --no-deps dep done python setup.py install py.test python setup.py sdist
  • 31. #!/bin/build.sh vinit && source activate for dep in $( ???/ ); do pip install --no-deps dep done python setup.py install py.test python setup.py sdist
  • 33. #!/bin/build.sh vinit && source activate for dep in $( gradle/ ); do pip install --no-deps dep done python setup.py install py.test python setup.py sdist
  • 34. Philosophy   Let’s  let  Python  do  what  Python  is   good  at  and  let  Gradle  do  what  Gradle   is  good  at.  
  • 35.
  • 36. Gradle  as  a  Build  Orchestrator   •  First,  resolve  my  dependencies •  Second,  run  my  build – pip install --no-deps dep •  Third,  run  my  package – python setup.py sdist •  Last,  run  my  publish
  • 37. build.gradle apply plugin: 'python-venv' apply plugin: 'python-sdist' sdist { sourceDirectory 'src' }
  • 38. build.gradle apply plugin: 'python-venv' apply plugin: 'python-pex' sdist { sourceDirectory 'src' }
  • 39. Enhancing  Python   •  Represent  arJfacts  and  dependencies  in  a  way   Gradle  can  understand.   •  Integrate  exisJng  metadata  with  setuptools   using  custom  distribuJon  class.  
  • 40. RepresenJng  Dependencies   <ivy-module version="1.0"> <info module="cryptography" revision="0.8.2" /> <publications> <artifact name="cryptography" conf="default"/> </publications> <dependencies> <dependency name="pyasn1" rev="0.1.7" /> <dependency name="six" rev="1.9.0" /> <dependency name="setuptools" rev="3.4.4" /> <dependency name="enum34" rev="1.0.4" /> <dependency name="cffi" rev="0.9.2" /> </dependencies> </ivy-module>
  • 41. The  Cheese  Shop   •  Python  Package  Index  (PyPI)   – Community  hosts  packages  here   – Cannot  modify  packages  here   •  Internal  Python  Package  Index   – ArJfactory   – Add  Ivy  metadata  for  packages  
  • 42. IntegraJng  Metadata   •  How  to  marry  setuptools  with  custom   metadata  systems.   – Product  names   – Product  versions   – SpecificaJon  files   – Dependencies  
  • 43. IntegraJng  Metadata   #!/usr/bin/env python2.6 import setuptools from distgradle import GradleDistribution setuptools.setup( distclass=GradleDistribution, package_dir={'': 'src'}, packages=setuptools.find_packages('src'), include_package_data=True, namespace_packages=['linkedin'], )
  • 44. Gradle  Infrastructure   •  python-product – Your  enterprise  build  logic,  covering  everything   from  your  resoluJon  strategies,  your  repositories,   your  metadata,  and  more.   – You  could  write  a  simple  plugin  that  simply  defers   to  setuptools,  if  you  want.  
  • 45. Gradle  Plugins   •  python-venv – Builds  a  local  environment   •  python-sdist – Build  a  source  distribuJon  using  setuptools.   •  python-wheel   – Build  a  wheel  distribuJon  using  setuptools.   •  python-pex – Build  a  pex  distribuJon  using  pex.  
  • 46. python-venv   •  Under  the  hood:   – CreaJng  a  virtual  environment.   – Installing  build  requirements.   – Installing  your  resolved  dependencies.   – Installing  your  project.   – Running  tests   – Packaging  arJfacts  
  • 47. python-sdist   •  Under  the  hood:   – Applying  python-venv – Invoking  ./setup.py sdist
  • 48. python-wheel   •  Under  the  hood:   – Applying  python-venv – Invoking  pip wheel •  Making  Python's  wheel  file  compaJble  with   Ivy  is  hard.  
  • 49. python-pex   •  Under  the  hood:   – Applying  python-venv – Invoking  pex •  Prepare  to  baHle  with  pex's  dependency   resolver.  
  • 50. python-???   •  ExisJng  plugins  easy  to  add  now.   •  AddiJonal  plugins  easy  to  add  later.   •  Mix  and  match  any  way  we  like.   – We  might  want  a  source  and  a  wheel  distribuJon.  
  • 51. Python+Gradle   •  Report  card   – Ecosystem  (great)   – Build  System  (good)   – Packaging  (good)   – Metadata  (good)   – Dependency  Management  (great)  
  • 52. What  is  Gradle  doing?   •  Reading  specificaJon  files   •  Dependency  and  conflict  resoluJon   •  Downloading  and  caching   •  OrchestraJng  creaJon  of  Python  arJfacts   •  CreaJng  build  metadata   •  Uploading  arJfacts   •  PyPI  
  • 53. What  is  Gradle  not  doing?   •  Changing  how  you  develop  with  Python   •  Changing  how  Python  packages  arJfacts   •  Changing  Python  arJfacts  themselves   •  Pushing  Gradle-­‐isms  into  Python  
  • 54. Major  Wins   •  Dependency  Management   •  Plugin  Architecture   •  Reusable  Logic   •  MulJ-­‐language  Builds  
  • 55. MulJ-­‐language  Builds   •  One  build  system  to  rule  them  all.   – Java   – Scala   – C/C++   – Javascript   – Python   •  Products  can  contain  different  languages  
  • 56. Why  Python?   •  Why  was  Python  so  easy  to  build  with  Gradle?   – Can  decouple  dep.  mgmt.  from  setuptools – Can  decouple  dep.  mgmt.  from  PyPI   – Can  represent  dependencies  with  Ivy   •  Other  languages  like  Python  can  also  easily   use  Gradle