Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Structuring Your Python Project
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Matt Bachmann
January 20, 2016
Programming
4.1k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
820
Diff-Cover
bachmann1234
1
290
Opening The Floodgates: Unicode Identifiers in Python
bachmann1234
0
370
Other Decks in Programming
See All in Programming
機械に任せるテスト、人が見るテスト ⽣成AIで引き直した、運⽤保守フェーズの線引き
dske104
0
110
Intent as Code
shoppingjaws
6
1.1k
Apple Intelligence を用いた個人情報誤送信防止、及びユーザーリクエスト体験の改善について
yukiny
0
260
速習iPhone Duo対応
yuukiw00w
2
920
iOSDC2026登壇資料.pdf
riofujimon
0
200
setup-vp GitLab対応の裏側
naokihaba
0
140
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
410
技術的負債を組織課題として解く-増えすぎたマイクロサービスとの戦い-
reimaru
1
2.6k
Heart of Swift Concurrency
koher
0
1.1k
標準パッケージに uuid が追加された 背景から見る Go らしい意思決定 / go_127_uuid_decision
convto
5
9.3k
Vue Fes Japan 2026 タイムテーブル徹底解説
448jp
1
580
Starting & Sustaining Code-Based E2E Testing for Non-Coding QA Teams( #jasstniigata )
teyamagu
PRO
1
810
Featured
See All Featured
Building Flexible Design Systems
yeseniaperezcruz
330
41k
Building AI with AI
inesmontani
PRO
1
1.3k
Navigating Team Friction
lara
192
16k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
260
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
590
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
610
Building Adaptive Systems
keathley
44
3.2k
Producing Creativity
orderedlist
PRO
348
41k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Abbi's Birthday
coloredviolet
4
10k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
520
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