Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Structuring Your Python Project
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Matt Bachmann
January 20, 2016
Programming
4k
1
Share
Structuring Your Python Project
For people who know some Python and want to structure their first project
Matt Bachmann
January 20, 2016
More Decks by Matt Bachmann
See All by Matt Bachmann
Property Based Testing: Hypothesis
bachmann1234
0
800
Diff-Cover
bachmann1234
1
270
Opening The Floodgates: Unicode Identifiers in Python
bachmann1234
0
360
Other Decks in Programming
See All in Programming
AI時代になぜ書くのか
mutsumix
0
330
実用!Hono RPC2026
yodaka
2
300
Programming with a DJ Controller — not vibe coding
m_seki
3
800
Agentic UI in the Frontend: Architectures with Open Standards @JAX 2026 in Mainz
manfredsteyer
PRO
0
110
Cache-moi si tu peux : patterns et pièges du cache en production - Devoxx France 2026 - Conférence
slecache
0
340
t *testing.T は どこからやってくるの?
otakakot
1
920
Claude CodeでETLジョブ実行テストを自動化してみた
yoshikikasama
0
1.2k
書き換えて学ぶTemporal #fukts
pirosikick
2
360
エラー処理の温故知新 / history of error handling technic
ryotanakaya
7
1.8k
ハーネスエンジニアリングにどう向き合うか 〜ルールファイルを超えて開発プロセスを設計する〜 / How to approach harness engineering
rkaga
28
19k
【26新卒研修資料】TDD実装演習
dip_tech
PRO
0
180
KMP × Kotlin 2.3 - How Android Got Slower While iOS Builds Improved by 47%
rio432
0
150
Featured
See All Featured
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
320
Code Reviewing Like a Champion
maltzj
528
40k
Evolving SEO for Evolving Search Engines
ryanjones
0
190
Exploring anti-patterns in Rails
aemeredith
3
350
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
70
39k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Making Projects Easy
brettharned
120
6.6k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
340
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
210
The Invisible Side of Design
smashingmag
302
52k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.4k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Transcript
Structuring Your Python Project Matt Bachmann
Agenda • Directory Structure • Isolating Your Environment • Installing
Dependencies • Packaging Your Project • Releasing to the World
Our Project • Display Current Weather > forcastio 42.3907 -71.1157
Currently: rain - Mixed precipitation tomorrow through Thursday, with temperatures falling to 41°F on Monday.
Project Structure
The Code
Style Checking Your Code
The Tests
Running Your Tests
License
Documentation
Documentation • All projects should have a readme ◦ Description
◦ Installation ◦ Usage • Moving Beyond Readme! ◦ Sphinx • Write docs in reStructuredText ◦ Renders in Github and PyPi. PyPi does not support Markdown
Specifying Dependencies and Isolating Your Project
Isolate Your Project • Install virtualenv > pip install virtualenv
• Create an isolated environment > virtualenv venv • Turn that environment on > source venv/bin/activate
Installing Dependencies Install a package pip install <package name> Upgrade
a package pip install -U <package name> Uninstall a package pip uninstall <package name> List Installed packages pip freeze Install packages from a file pip install -r <requirements file>
Installing Dependencies • requirements.txt requests==2.8.1 • test-requirements.txt coverage==4.0.3 flake8==2.5.0 mock==1.3.0
pyflakes==1.0.0 pytest==2.8.3
Deploying Your Project
Setup.py setup( name='displayforecastio', version='1.0', author='Matt Bachmann', url='https://github.com/Bachmann1234/displayforecastio', description='Display the current
weather in your terminal', license='Apache 2.0', packages=[‘displayforecastio'], install_requires=['requests==2.8.1'], entry_points={ 'console_scripts': ['forcastio = displayforecastio.app:run'], } )
What This Gives You • Install your project from project
root > pip install . • After installation you have a command! > forecastio 42.3907 -71.1157 • Share your project with the world
Pip Editable Installs • pip install -e <path to your
project> ◦ Installs a project by pointing to it ◦ Won’t work over pypi • Change your code, your installation reflects the changes • Super handy debugging tool • Fun way to explore other people’s projects!
Deploying Your Project To PyPI Step 1: Register for an
account
Deploying Your Project To PyPI Step 2: Create a .pypirc
in your home directory > cat .pypirc [server-login] username:Matt.Bachmann password:NotAChance
Deploying Your Project To PyPI Step 3: Register Your package
(from project root) > python setup.py register <Name>
Deploying Your Project To PyPI DONE!
Deploying Your Project To PyPI > pip install displayforecastio >
forecastio 42.3907 -71.1157 Currently: rain - Mixed precipitation tomorrow through Thursday, with temperatures falling to 42°F on Saturday.
Deploying Your Project To PyPI • Deploying Updates ◦ After
updating the version in setup.py > python setup.py sdist upload
References • Documentation ◦ https://readthedocs.org/ ◦ http://sphinx-doc.org/contents.html • Example Projects
◦ https://github.com/Bachmann1234/terminalweather ◦ https://github.com/pypa/sampleproject • Flake8 ◦ https://flake8.readthedocs.org/en/latest/ ◦ https://www.youtube.com/watch?v=wf-BqAjZb8M (Not about flake8 but an important lesson for anyone caring about style) • Folder Structure ◦ http://learnpythonthehardway.org/book/ex46.html • Licensing ◦ http://choosealicense.com/ • Pip ◦ http://pip.readthedocs.org/en/stable/user_guide/
References • PyPi ◦ https://pypi.python.org • reStructuredText ◦ http://docutils.sourceforge.net/ •
Setup.py ◦ https://docs.python.org/2/distutils/setupscript.html • Virtualenv ◦ http://virtualenv.readthedocs.org/en/latest/userguide.html