|
| https://realpython.com/ |
| Start Here | https://realpython.com/start-here/ |
|
Learn Python
| https://realpython.com/courses/structuring-python-application/discussion/ |
| Python Tutorials →In-depth articles and video courses | https://realpython.com/search?kind=article&kind=course&order=newest |
| Learning Paths →Guided study plans for accelerated learning | https://realpython.com/learning-paths/ |
| Quizzes & Exercises →Check your learning progress | https://realpython.com/quizzes/ |
| Browse Topics →Focus on a specific area or skill level | https://realpython.com/tutorials/all/ |
| Community Chat →Learn with other Pythonistas | https://realpython.com/community/ |
| Office Hours →Live Q&A calls with Python experts | https://realpython.com/office-hours/ |
| Podcast →Hear what’s new in the world of Python | https://realpython.com/podcasts/rpp/ |
| Books →Round out your knowledge and learn offline | https://realpython.com/products/books/ |
| Reference →Concise definitions for common Python terms | https://realpython.com/ref/ |
| Code Mentor →BetaPersonalized code assistance & learning tools | https://realpython.com/mentor/ |
| Unlock All Content → | https://realpython.com/account/join/ |
|
More
| https://realpython.com/courses/structuring-python-application/discussion/ |
| Learner Stories | https://realpython.com/learner-stories/ |
| Python Newsletter | https://realpython.com/newsletter/ |
| Python Job Board | https://www.pythonjobshq.com |
| Meet the Team | https://realpython.com/team/ |
| Become a Tutorial Writer | https://realpython.com/write-for-us/ |
| Become a Video Instructor | https://realpython.com/become-an-instructor/ |
| Search | https://realpython.com/search |
| https://realpython.com/search |
| Join | https://realpython.com/account/join/ |
| Sign‑In | https://realpython.com/account/login/?next=%2Fvideos%2Fstructuring-python-application%2F |
| https://realpython.com/courses/structuring-python-application/#team |
| Structuring a Python Application | https://realpython.com/courses/structuring-python-application/ |
| Christopher Trudeau | https://realpython.com/courses/structuring-python-application/#team |
| Recommended Tutorial | https://realpython.com/python-application-layouts/ |
| Course Slides (.pdf) | https://realpython.com/courses/structuring-python-application/downloads/layout-slides/ |
| Sample Code (.zip) | https://realpython.com/courses/structuring-python-application/downloads/layout-code/ |
| Ask a Question | https://realpython.com/courses/structuring-python-application/discussion/#discussion |
| https://realpython.com/feedback/survey/course/structuring-python-application/liked/?from=lesson-title |
| https://realpython.com/feedback/survey/course/structuring-python-application/disliked/?from=lesson-title |
| Contents | https://realpython.com/courses/structuring-python-application/discussion/#description |
| Transcript | https://realpython.com/courses/structuring-python-application/discussion/#transcript |
| Discussion (5) | https://realpython.com/courses/structuring-python-application/discussion/#discussion |
| Flask | https://realpython.com/tutorials/flask/ |
| Django | https://realpython.com/tutorials/django/ |
| Sample Code (.zip) | https://realpython.com/courses/structuring-python-application/downloads/layout-code/ |
| Course Slides (.pdf) | https://realpython.com/courses/structuring-python-application/downloads/layout-slides/ |
| 00:00 | https://realpython.com/courses/structuring-python-application/discussion/#t=0.48 |
| Welcome to Python Application Layouts. | https://realpython.com/courses/structuring-python-application/discussion/#t=0.48 |
| My name is Chris and I will be your guide. | https://realpython.com/courses/structuring-python-application/discussion/#t=2.37 |
| This series of videos will show you how to organize your Python code and the | https://realpython.com/courses/structuring-python-application/discussion/#t=4.74 |
| files associated therein. Each lesson in the video | https://realpython.com/courses/structuring-python-application/discussion/#t=7.83 |
| will cover different kinds of configurations: simple one-off scripts, installable | https://realpython.com/courses/structuring-python-application/discussion/#t=10.77 |
| single packages, larger applications, a Django web application, | https://realpython.com/courses/structuring-python-application/discussion/#t=15.43 |
| and finally, a Flask application. First off, | https://realpython.com/courses/structuring-python-application/discussion/#t=20.07 |
| I’m going to assume that you have some familiarity with Python modules and | https://realpython.com/courses/structuring-python-application/discussion/#t=23.7 |
| packages. If you need a refresher, | https://realpython.com/courses/structuring-python-application/discussion/#t=26.64 |
| there’s a course on Real Python that can help you with the details. | https://realpython.com/courses/structuring-python-application/discussion/#t=28.89 |
| 00:32 | https://realpython.com/courses/structuring-python-application/discussion/#t=32.369 |
| So, let’s get started. | https://realpython.com/courses/structuring-python-application/discussion/#t=32.369 |
| Python is very flexible when it comes to how you structure your applications. | https://realpython.com/courses/structuring-python-application/discussion/#t=33.93 |
| You can more or less get away with almost anything you want. | https://realpython.com/courses/structuring-python-application/discussion/#t=36.99 |
| 00:39 | https://realpython.com/courses/structuring-python-application/discussion/#t=39.66 |
| That’s very powerful, | https://realpython.com/courses/structuring-python-application/discussion/#t=39.66 |
| but it can also be very daunting if you’re just getting going. Unfortunately, | https://realpython.com/courses/structuring-python-application/discussion/#t=40.65 |
| the internet is no help. If you start googling for how to do this, | https://realpython.com/courses/structuring-python-application/discussion/#t=44.1 |
| there’s lots and lots of opinions on how it should be done. That being said, | https://realpython.com/courses/structuring-python-application/discussion/#t=47.52 |
| the content in this video is based on a Real Python article from Kyle. | https://realpython.com/courses/structuring-python-application/discussion/#t=52.5 |
| 00:56 | https://realpython.com/courses/structuring-python-application/discussion/#t=56.1 |
| You can see the original article here. | https://realpython.com/courses/structuring-python-application/discussion/#t=56.1 |
| This means that it in itself is also opinionated. | https://realpython.com/courses/structuring-python-application/discussion/#t=58.77 |
| Now, I happen to agree with Kyle’s opinions and he’s outlining things that are | https://realpython.com/courses/structuring-python-application/discussion/#t=62.13 |
| best practices, | https://realpython.com/courses/structuring-python-application/discussion/#t=65.34 |
| but you will be able to find contradictory information out there. | https://realpython.com/courses/structuring-python-application/discussion/#t=66.51 |
| 01:10 | https://realpython.com/courses/structuring-python-application/discussion/#t=70.14 |
| The intent of this course is to give you good places to start. | https://realpython.com/courses/structuring-python-application/discussion/#t=70.14 |
| Once you’re comfortable, you can adjust things to your own style. | https://realpython.com/courses/structuring-python-application/discussion/#t=73.47 |
| Accompanying this video is a selection of sample code. | https://realpython.com/courses/structuring-python-application/discussion/#t=76.92 |
| 01:19 | https://realpython.com/courses/structuring-python-application/discussion/#t=79.38 |
| It’s actually executable. It doesn’t just show the file layout; | https://realpython.com/courses/structuring-python-application/discussion/#t=79.38 |
| it actually works. This means you can package it, | https://realpython.com/courses/structuring-python-application/discussion/#t=82.53 |
| run the tests, and see how things change from a small application to a large | https://realpython.com/courses/structuring-python-application/discussion/#t=86.04 |
| application. Hopefully, this is helpful as you’re following along. | https://realpython.com/courses/structuring-python-application/discussion/#t=90.63 |
| 01:35 | https://realpython.com/courses/structuring-python-application/discussion/#t=95.34 |
| I’ll start with the simplest situation: | https://realpython.com/courses/structuring-python-application/discussion/#t=95.34 |
| a program consisting of a single Python file. This kind of situation works | https://realpython.com/courses/structuring-python-application/discussion/#t=97.44 |
| if you don’t have any dependencies and everything’s just pure Python or if | https://realpython.com/courses/structuring-python-application/discussion/#t=101.97 |
| you’re using a virtual env with tools like pip or Pipenv to manage external | https://realpython.com/courses/structuring-python-application/discussion/#t=105.45 |
| dependencies. Of course, single-file programs | https://realpython.com/courses/structuring-python-application/discussion/#t=109.47 |
| often aren’t just single files. You’re writing automated tests, right? | https://realpython.com/courses/structuring-python-application/discussion/#t=113.94 |
| 01:57 | https://realpython.com/courses/structuring-python-application/discussion/#t=117.45 |
| You should be. Even if you’re not, there’s also things that go along with it— | https://realpython.com/courses/structuring-python-application/discussion/#t=117.45 |
| for example, configuration for your git setup, | https://realpython.com/courses/structuring-python-application/discussion/#t=121.62 |
| setup.py for organizing how your system is packaged | https://realpython.com/courses/structuring-python-application/discussion/#t=124.44 |
| if you are trying to do packaging, requirements.txt that specifies your | https://realpython.com/courses/structuring-python-application/discussion/#t=128.1 |
| dependencies, and licensing and README information is always useful | https://realpython.com/courses/structuring-python-application/discussion/#t=132.75 |
| if you’re trying to hand this script off to somebody else. | https://realpython.com/courses/structuring-python-application/discussion/#t=136.23 |
| 02:19 | https://realpython.com/courses/structuring-python-application/discussion/#t=139.29 |
| This course comes with sample code that actually executes. | https://realpython.com/courses/structuring-python-application/discussion/#t=139.29 |
| I’m going to give you a quick tour of what it does. | https://realpython.com/courses/structuring-python-application/discussion/#t=142.56 |
| It’s a little Hello World so that you can see as I build on it in the different | https://realpython.com/courses/structuring-python-application/discussion/#t=144.39 |
| lessons | https://realpython.com/courses/structuring-python-application/discussion/#t=148.26 |
| how the pieces fit together, and what changes as things become more complicated. | https://realpython.com/courses/structuring-python-application/discussion/#t=148.89 |
| 02:33 | https://realpython.com/courses/structuring-python-application/discussion/#t=153.51 |
| So, here it is: helloworld.py. | https://realpython.com/courses/structuring-python-application/discussion/#t=153.51 |
| Normally, a Hello World example is nothing but print("Hello, World!"). | https://realpython.com/courses/structuring-python-application/discussion/#t=155.82 |
| In order to show you how to interact with external libraries and how these | https://realpython.com/courses/structuring-python-application/discussion/#t=159.66 |
| pieces fit together, my Hello World is a little bit more complicated, | https://realpython.com/courses/structuring-python-application/discussion/#t=163.05 |
| but not by much. | https://realpython.com/courses/structuring-python-application/discussion/#t=166.8 |
| 02:48 | https://realpython.com/courses/structuring-python-application/discussion/#t=168.63 |
| All it’s doing in line 12 is using the very popular requests library. | https://realpython.com/courses/structuring-python-application/discussion/#t=168.63 |
| If you haven’t seen it before, requests wraps HTTP code. | https://realpython.com/courses/structuring-python-application/discussion/#t=173.43 |
| 02:57 | https://realpython.com/courses/structuring-python-application/discussion/#t=177.18 |
| It’s the easiest way of grabbing the contents of | https://realpython.com/courses/structuring-python-application/discussion/#t=177.18 |
| a web page. Line 8 shows the URL that I’m grabbing. The URL I’m grabbing is a | https://realpython.com/courses/structuring-python-application/discussion/#t=179.29 |
| Wikipedia article on Hello World programs— | https://realpython.com/courses/structuring-python-application/discussion/#t=184.99 |
| how very meta. And then on line 13, I’m printing it— | https://realpython.com/courses/structuring-python-application/discussion/#t=187.48 |
| finding the tag inside of it and printing out just the result of that. | https://realpython.com/courses/structuring-python-application/discussion/#t=191.47 |
| 03:17 | https://realpython.com/courses/structuring-python-application/discussion/#t=197.17 |
| So, as I said, pretty simple—essentially, it just prints "Hello, World!" | https://realpython.com/courses/structuring-python-application/discussion/#t=197.17 |
| but uses the requests library to do it. | https://realpython.com/courses/structuring-python-application/discussion/#t=202.0 |
| 03:25 | https://realpython.com/courses/structuring-python-application/discussion/#t=205.6 |
| The other thing to notice here is I’ve embedded a version number. | https://realpython.com/courses/structuring-python-application/discussion/#t=205.6 |
| 03:29 | https://realpython.com/courses/structuring-python-application/discussion/#t=209.14 |
| There are multiple ways of specifying version numbers; | https://realpython.com/courses/structuring-python-application/discussion/#t=209.14 |
| this is my preferred mechanism because you can actually get at it | https://realpython.com/courses/structuring-python-application/discussion/#t=211.45 |
| programmatically. Later on, when this goes from a single file to multiple files, | https://realpython.com/courses/structuring-python-application/discussion/#t=214.09 |
| I’ll move this out of the script and into the __init__. | https://realpython.com/courses/structuring-python-application/discussion/#t=218.71 |
| 03:43 | https://realpython.com/courses/structuring-python-application/discussion/#t=223.63 |
| And here it is in action. | https://realpython.com/courses/structuring-python-application/discussion/#t=223.63 |
| 03:46 | https://realpython.com/courses/structuring-python-application/discussion/#t=226.33 |
| That’s the tag from the Wikipedia page on Hello | https://realpython.com/courses/structuring-python-application/discussion/#t=226.33 |
| World programs, as expected. | https://realpython.com/courses/structuring-python-application/discussion/#t=229.3 |
| 03:54 | https://realpython.com/courses/structuring-python-application/discussion/#t=234.22 |
| So, this is some test code to go with my Hello World program. | https://realpython.com/courses/structuring-python-application/discussion/#t=234.22 |
| Interestingly enough, | https://realpython.com/courses/structuring-python-application/discussion/#t=237.49 |
| there’s actually more code in the tests than there is in the program itself. | https://realpython.com/courses/structuring-python-application/discussion/#t=238.3 |
| 04:01 | https://realpython.com/courses/structuring-python-application/discussion/#t=241.72 |
| That’s because I’m avoiding the call to the internet inside of requests. | https://realpython.com/courses/structuring-python-application/discussion/#t=241.72 |
| The meat of the test is lines 15 through 19. Line 18 calls | https://realpython.com/courses/structuring-python-application/discussion/#t=246.67 |
| the actual code. requests is mocked out so that the internet call isn’t actually | https://realpython.com/courses/structuring-python-application/discussion/#t=251.29 |
| made. I generally try to make a difference between my unit tests, | https://realpython.com/courses/structuring-python-application/discussion/#t=256.959 |
| which are self-contained and don’t require the dependencies, versus my | https://realpython.com/courses/structuring-python-application/discussion/#t=261.25 |
| integration tests, which would include going off to the world. | https://realpython.com/courses/structuring-python-application/discussion/#t=264.58 |
| 04:28 | https://realpython.com/courses/structuring-python-application/discussion/#t=268.09 |
| This allows me to write much faster unit tests, and I’m not dependent on the | https://realpython.com/courses/structuring-python-application/discussion/#t=268.09 |
| environment I’m running them in. | https://realpython.com/courses/structuring-python-application/discussion/#t=271.21 |
| If you haven’t seen unit tests or mocks before, | https://realpython.com/courses/structuring-python-application/discussion/#t=273.34 |
| there’s plenty of good content on Real Python to help you out with that. For now, | https://realpython.com/courses/structuring-python-application/discussion/#t=275.38 |
| just understand that this is the code that tests it, and I’ll show you quickly | https://realpython.com/courses/structuring-python-application/discussion/#t=280.39 |
| how that works. | https://realpython.com/courses/structuring-python-application/discussion/#t=283.99 |
| 04:46 | https://realpython.com/courses/structuring-python-application/discussion/#t=286.75 |
| The Python unittest module is executable. On the command line, | https://realpython.com/courses/structuring-python-application/discussion/#t=286.75 |
| I can specify -m to execute unittest, passing in my tests file. Python’s | https://realpython.com/courses/structuring-python-application/discussion/#t=290.53 |
| unittest library will then execute the tests in my tests.py file. | https://realpython.com/courses/structuring-python-application/discussion/#t=296.77 |
| 05:01 | https://realpython.com/courses/structuring-python-application/discussion/#t=301.36 |
| Here it goes. You see the results of the program: | https://realpython.com/courses/structuring-python-application/discussion/#t=301.36 |
| "Hello, World!" program - Wikipedia, because do_hello() prints something to the screen, | https://realpython.com/courses/structuring-python-application/discussion/#t=304.02 |
| and then you see the output from the unittest module specifying that it ran one | https://realpython.com/courses/structuring-python-application/discussion/#t=309.7 |
| test successfully and everything’s okay. | https://realpython.com/courses/structuring-python-application/discussion/#t=313.45 |
| 05:17 | https://realpython.com/courses/structuring-python-application/discussion/#t=317.17 |
| So, you’ve seen the code and the tests that go with it. Now, | https://realpython.com/courses/structuring-python-application/discussion/#t=317.17 |
| I want to show you the accompanying files | https://realpython.com/courses/structuring-python-application/discussion/#t=319.99 |
| that would probably also be in the directory, | https://realpython.com/courses/structuring-python-application/discussion/#t=321.19 |
| particularly if you’re going to package this up for other people. For starters, | https://realpython.com/courses/structuring-python-application/discussion/#t=322.81 |
| .gitignore. This is a configuration file | https://realpython.com/courses/structuring-python-application/discussion/#t=327.31 |
| for git to tell it to ignore certain file types. | https://realpython.com/courses/structuring-python-application/discussion/#t=329.65 |
| 05:32 | https://realpython.com/courses/structuring-python-application/discussion/#t=332.38 |
| It stops it from trying to check in things like backup files and swap files that | https://realpython.com/courses/structuring-python-application/discussion/#t=332.38 |
| you’re not interested in. Here’s a really, really simple example. | https://realpython.com/courses/structuring-python-application/discussion/#t=336.13 |
| If you’re writing code on a Mac, the .DS_Store directory shows up everywhere. | https://realpython.com/courses/structuring-python-application/discussion/#t=340.33 |
| 05:44 | https://realpython.com/courses/structuring-python-application/discussion/#t=344.68 |
| It’s where meta information is stored. You probably don’t want that checked in. | https://realpython.com/courses/structuring-python-application/discussion/#t=344.68 |
| If you’re writing Python 3, __pycache__/ | https://realpython.com/courses/structuring-python-application/discussion/#t=349.21 |
| will have the contents of the compiled Python files. Any Python c, Python o, or | https://realpython.com/courses/structuring-python-application/discussion/#t=352.45 |
| Python d files—so that’s .pyc, .pyo, | https://realpython.com/courses/structuring-python-application/discussion/#t=358.04 |
| or .pyd—are all object files and don’t need to be in your repository. | https://realpython.com/courses/structuring-python-application/discussion/#t=360.71 |
| 06:05 | https://realpython.com/courses/structuring-python-application/discussion/#t=365.39 |
| These are examples of things you probably don’t want to store inside of git. A | https://realpython.com/courses/structuring-python-application/discussion/#t=365.39 |
| complete version of this file is much longer than this. You can see sample | https://realpython.com/courses/structuring-python-application/discussion/#t=369.23 |
| .gitignore files off at GitHub itself. | https://realpython.com/courses/structuring-python-application/discussion/#t=372.68 |
| 06:15 | https://realpython.com/courses/structuring-python-application/discussion/#t=375.26 |
| It has good .gitignore files for almost every programming language you can think | https://realpython.com/courses/structuring-python-application/discussion/#t=375.26 |
| of. My Hello World program uses the requests library. | https://realpython.com/courses/structuring-python-application/discussion/#t=379.58 |
| 06:23 | https://realpython.com/courses/structuring-python-application/discussion/#t=383.21 |
| That means I need to be able to pip install it to a virtual env. | https://realpython.com/courses/structuring-python-application/discussion/#t=383.21 |
| The requirements.txt file shows this dependency as well as anything else | https://realpython.com/courses/structuring-python-application/discussion/#t=386.81 |
| that I might use when I’m developing. A sample file includes requests 2.22, | https://realpython.com/courses/structuring-python-application/discussion/#t=391.7 |
| which is the library I was using, as well as coverage and pudb—coverage | https://realpython.com/courses/structuring-python-application/discussion/#t=398.78 |
| being a program to help me see what my tests are covering and aren’t covering, | https://realpython.com/courses/structuring-python-application/discussion/#t=403.34 |
| and pudb is my favorite command-line | https://realpython.com/courses/structuring-python-application/discussion/#t=407.69 |
| debugger. requirements.txt generally stores | https://realpython.com/courses/structuring-python-application/discussion/#t=409.7 |
| everything you need to run your tests and develop. | https://realpython.com/courses/structuring-python-application/discussion/#t=413.84 |
| 06:57 | https://realpython.com/courses/structuring-python-application/discussion/#t=417.29 |
| This is often more than what you would include in a shipped application. | https://realpython.com/courses/structuring-python-application/discussion/#t=417.29 |
| So, setup.py won’t have the coverage and pudb items in it— | https://realpython.com/courses/structuring-python-application/discussion/#t=422.54 |
| it’ll only have requests. Just the strict dependencies. Speaking of setup.py— | https://realpython.com/courses/structuring-python-application/discussion/#t=426.53 |
| what is it? It’s a way of specifying what is packaged in your application. | https://realpython.com/courses/structuring-python-application/discussion/#t=431.72 |
| 07:16 | https://realpython.com/courses/structuring-python-application/discussion/#t=436.34 |
| Unfortunately, Python | https://realpython.com/courses/structuring-python-application/discussion/#t=436.34 |
| isn’t really strong when it comes to packaging. Or an alternative way of looking | https://realpython.com/courses/structuring-python-application/discussion/#t=437.39 |
| at that is there’s lots and lots of choice; | https://realpython.com/courses/structuring-python-application/discussion/#t=441.02 |
| it isn’t really baked into the language and there’s tons of third-party ways of | https://realpython.com/courses/structuring-python-application/discussion/#t=443.33 |
| doing it. The Python community is trying to tackle this, | https://realpython.com/courses/structuring-python-application/discussion/#t=446.81 |
| but it’s changed a lot over the years | https://realpython.com/courses/structuring-python-application/discussion/#t=450.98 |
| and so you’re going to bump into all sorts of ways of doing things. | https://realpython.com/courses/structuring-python-application/discussion/#t=453.5 |
| 07:37 | https://realpython.com/courses/structuring-python-application/discussion/#t=457.07 |
| setup.py isn’t the only way, but it is one of the more common | https://realpython.com/courses/structuring-python-application/discussion/#t=457.07 |
| popular ways, and a lot of tools interact with it. For example, | https://realpython.com/courses/structuring-python-application/discussion/#t=460.43 |
| if you’ve heard of tox, | https://realpython.com/courses/structuring-python-application/discussion/#t=464.27 |
| it’s a test harness for testing your program under multiple versions of Python. | https://realpython.com/courses/structuring-python-application/discussion/#t=465.8 |
| 07:49 | https://realpython.com/courses/structuring-python-application/discussion/#t=469.85 |
| twine is a tool for uploading a package to PyPI | https://realpython.com/courses/structuring-python-application/discussion/#t=469.85 |
| so you can share it with other people. | https://realpython.com/courses/structuring-python-application/discussion/#t=472.52 |
| The packages that twine uploads are the result of setup.py | https://realpython.com/courses/structuring-python-application/discussion/#t=474.68 |
| being executed and creating bundles. For more information on setup.py and how | https://realpython.com/courses/structuring-python-application/discussion/#t=477.77 |
| to use it with Pipenv, go to the Real Python article on this topic. | https://realpython.com/courses/structuring-python-application/discussion/#t=483.17 |
| 08:07 | https://realpython.com/courses/structuring-python-application/discussion/#t=487.55 |
| Now, I’ll show you an example. This is the bottom chunk of a setup.py file. | https://realpython.com/courses/structuring-python-application/discussion/#t=487.55 |
| It’s kind of funny; not only were the tests twice as long as the code, now | https://realpython.com/courses/structuring-python-application/discussion/#t=492.41 |
| the configuration file is four times as long. | https://realpython.com/courses/structuring-python-application/discussion/#t=497.12 |
| 08:20 | https://realpython.com/courses/structuring-python-application/discussion/#t=500.21 |
| The heart of setup.py is down at the bottom here in these final four lines— | https://realpython.com/courses/structuring-python-application/discussion/#t=500.21 |
| calling the setup() library and passing in a dictionary that describes your | https://realpython.com/courses/structuring-python-application/discussion/#t=504.17 |
| package. I’ll move up a little bit | https://realpython.com/courses/structuring-python-application/discussion/#t=507.74 |
| now. Lines 16 through 38— | https://realpython.com/courses/structuring-python-application/discussion/#t=510.02 |
| this is the dictionary specifying information. Really, | https://realpython.com/courses/structuring-python-application/discussion/#t=513.559 |
| this is just attributes about the program helloworld. | https://realpython.com/courses/structuring-python-application/discussion/#t=516.59 |
| 08:40 | https://realpython.com/courses/structuring-python-application/discussion/#t=520.94 |
| It includes things like name, the version, description, a longer description, | https://realpython.com/courses/structuring-python-application/discussion/#t=520.94 |
| where to find it, who the author is, the license you’ve picked, | https://realpython.com/courses/structuring-python-application/discussion/#t=525.41 |
| what kind of program it is, what modules it uses, and what it requires. | https://realpython.com/courses/structuring-python-application/discussion/#t=529.82 |
| 08:54 | https://realpython.com/courses/structuring-python-application/discussion/#t=534.29 |
| 35 through 37 is important— | https://realpython.com/courses/structuring-python-application/discussion/#t=534.29 |
| this is what makes sure dependencies get installed when your package is | https://realpython.com/courses/structuring-python-application/discussion/#t=536.58 |
| installed by someone else. | https://realpython.com/courses/structuring-python-application/discussion/#t=540.69 |
| Remember how this is different from requirements.txt: requirements.txt | https://realpython.com/courses/structuring-python-application/discussion/#t=542.94 |
| includes everything that you would put in your development virtual environment— | https://realpython.com/courses/structuring-python-application/discussion/#t=547.53 |
| and that includes things like your debugging tools— | https://realpython.com/courses/structuring-python-application/discussion/#t=550.92 |
| whereas install_requires is only what someone using your program would need. | https://realpython.com/courses/structuring-python-application/discussion/#t=553.8 |
| 09:18 | https://realpython.com/courses/structuring-python-application/discussion/#t=558.84 |
| So. install_requires—the requests | https://realpython.com/courses/structuring-python-application/discussion/#t=558.84 |
| library; requirements.txt only has requests as well as things like coverage | https://realpython.com/courses/structuring-python-application/discussion/#t=561.09 |
| and pudb inside of it. I’m going to scroll up to the top now. | https://realpython.com/courses/structuring-python-application/discussion/#t=566.55 |
| 09:30 | https://realpython.com/courses/structuring-python-application/discussion/#t=570.96 |
| Lines 1 through 13 aren’t required for setup.py to work; | https://realpython.com/courses/structuring-python-application/discussion/#t=570.96 |
| as long as you fill in your dictionary args, you’re good to go. | https://realpython.com/courses/structuring-python-application/discussion/#t=574.65 |
| These 13 lines are things that I often do inside of my setup.py | https://realpython.com/courses/structuring-python-application/discussion/#t=577.77 |
| so that I’m reusing information from the outside world. For example, | https://realpython.com/courses/structuring-python-application/discussion/#t=581.34 |
| I have a regular expression looking for "__version__" inside of the | https://realpython.com/courses/structuring-python-application/discussion/#t=584.97 |
| program file. It reads it and puts it inside of the dictionary. | https://realpython.com/courses/structuring-python-application/discussion/#t=589.38 |
| 09:53 | https://realpython.com/courses/structuring-python-application/discussion/#t=593.61 |
| This means I don’t have to remember to update the version number in two places: | https://realpython.com/courses/structuring-python-application/discussion/#t=593.61 |
| the code and the setup.py file. Similarly, | https://realpython.com/courses/structuring-python-application/discussion/#t=597.42 |
| because I have a README file, | https://realpython.com/courses/structuring-python-application/discussion/#t=601.2 |
| I’m reading that in and putting it inside of the long_description. You can | https://realpython.com/courses/structuring-python-application/discussion/#t=602.64 |
| of course | https://realpython.com/courses/structuring-python-application/discussion/#t=606.66 |
| just set these things up inside of the dictionary—or in some cases, not even | https://realpython.com/courses/structuring-python-application/discussion/#t=607.08 |
| include them— | https://realpython.com/courses/structuring-python-application/discussion/#t=610.41 |
| but I wanted to show you what I often include inside of my own application | https://realpython.com/courses/structuring-python-application/discussion/#t=611.04 |
| configuration. Now, you’ve seen requirements.txt and setup.py. | https://realpython.com/courses/structuring-python-application/discussion/#t=614.52 |
| 10:18 | https://realpython.com/courses/structuring-python-application/discussion/#t=618.75 |
| Just a couple of housekeeping files left. First off, the LICENSE. | https://realpython.com/courses/structuring-python-application/discussion/#t=618.75 |
| There’s a lot of misinformation out there about copyrights, | https://realpython.com/courses/structuring-python-application/discussion/#t=623.28 |
| particularly when it comes to software. | https://realpython.com/courses/structuring-python-application/discussion/#t=625.89 |
| 10:28 | https://realpython.com/courses/structuring-python-application/discussion/#t=628.26 |
| The thing you have to know is if you do not include a license file, | https://realpython.com/courses/structuring-python-application/discussion/#t=628.26 |
| the code is fully copyrighted by default, in most jurisdictions. | https://realpython.com/courses/structuring-python-application/discussion/#t=632.01 |
| What that means is no one has any right to use it or copy it in any fashion. | https://realpython.com/courses/structuring-python-application/discussion/#t=636.6 |
| 10:42 | https://realpython.com/courses/structuring-python-application/discussion/#t=642.39 |
| The open-source world would not exist if everyone did this. Licenses are what | https://realpython.com/courses/structuring-python-application/discussion/#t=642.39 |
| grant other people the ability to use your software, | https://realpython.com/courses/structuring-python-application/discussion/#t=647.94 |
| and you’re probably using an awful lot of opensource products right now, | https://realpython.com/courses/structuring-python-application/discussion/#t=651.27 |
| so in my view, it’s only fair to share some of what you’re using yourself. | https://realpython.com/courses/structuring-python-application/discussion/#t=655.44 |
| 10:59 | https://realpython.com/courses/structuring-python-application/discussion/#t=659.58 |
| There’s plenty of variations on licenses. You can pick which one you like. | https://realpython.com/courses/structuring-python-application/discussion/#t=659.58 |
| If you’re using GitHub, when you create a new repository | https://realpython.com/courses/structuring-python-application/discussion/#t=664.17 |
| it will even give you a dropdown to choose which license to include in your | https://realpython.com/courses/structuring-python-application/discussion/#t=666.93 |
| repository. That massive text there is the MIT License. | https://realpython.com/courses/structuring-python-application/discussion/#t=670.53 |
| 11:14 | https://realpython.com/courses/structuring-python-application/discussion/#t=674.49 |
| It’s one of the simpler licenses and it’s very, very popular in the Python world. | https://realpython.com/courses/structuring-python-application/discussion/#t=674.49 |
| This is the one I tend to go to myself unless I’m doing something that’s | https://realpython.com/courses/structuring-python-application/discussion/#t=679.08 |
| interacting with other projects that don’t allow it. | https://realpython.com/courses/structuring-python-application/discussion/#t=682.86 |
| 11:26 | https://realpython.com/courses/structuring-python-application/discussion/#t=686.22 |
| There’s lots of good information off at ChooseALicense.com | https://realpython.com/courses/structuring-python-application/discussion/#t=686.22 |
| if you want to see what the differences are and help you pick a license. | https://realpython.com/courses/structuring-python-application/discussion/#t=689.64 |
| Just remember: if you don’t include a license | https://realpython.com/courses/structuring-python-application/discussion/#t=693.78 |
| you’re not actually sharing your code, regardless of whatever your intent was. | https://realpython.com/courses/structuring-python-application/discussion/#t=696.29 |
| 11:40 | https://realpython.com/courses/structuring-python-application/discussion/#t=700.11 |
| Finally, a README file is also important. If you’re sharing your code, | https://realpython.com/courses/structuring-python-application/discussion/#t=700.11 |
| you need to be able to tell people what it is. | https://realpython.com/courses/structuring-python-application/discussion/#t=703.41 |
| This should be a short description of your project. | https://realpython.com/courses/structuring-python-application/discussion/#t=706.47 |
| 11:48 | https://realpython.com/courses/structuring-python-application/discussion/#t=708.84 |
| Two very common formats for this are Markdown and reStructuredText. | https://realpython.com/courses/structuring-python-application/discussion/#t=708.84 |
| If you’re using GitHub, | https://realpython.com/courses/structuring-python-application/discussion/#t=713.35 |
| README.md or README.rst will automatically show as the project’s homepage. | https://realpython.com/courses/structuring-python-application/discussion/#t=714.82 |
| 12:00 | https://realpython.com/courses/structuring-python-application/discussion/#t=720.52 |
| Writing these things sometimes can be a bit of a challenge. Us programmers— | https://realpython.com/courses/structuring-python-application/discussion/#t=720.52 |
| not so goodly in English. | https://realpython.com/courses/structuring-python-application/discussion/#t=723.85 |
| If you’re having a little trouble and you want to figure out how to do it, | https://realpython.com/courses/structuring-python-application/discussion/#t=725.68 |
| Dan’s written a great article on how to describe your project and how to tell | https://realpython.com/courses/structuring-python-application/discussion/#t=728.59 |
| others about it. So, that’s a simple single-file program. | https://realpython.com/courses/structuring-python-application/discussion/#t=732.34 |
| 12:16 | https://realpython.com/courses/structuring-python-application/discussion/#t=736.93 |
| Next up, | https://realpython.com/courses/structuring-python-application/discussion/#t=736.93 |
| I’ll make things a little more complicated and show you how to use a single | https://realpython.com/courses/structuring-python-application/discussion/#t=737.62 |
| package which has multiple files in it. | https://realpython.com/courses/structuring-python-application/discussion/#t=740.8 |
| April 29, 2020 | https://realpython.com/courses/structuring-python-application/discussion/#comment-2c00b202-6c00-4b52-a922-03bee3ba0e66 |
| ive only been maintaining in my setup.py | https://github.com/drewmullen/vault-kv-migrate/blob/0169fe421bf8d25aa83b081a17a7f00a40ca42db/setup.py#L28 |
| April 30, 2020 | https://realpython.com/courses/structuring-python-application/discussion/#comment-e13a42ce-d755-4cb1-ac1b-2449677a6b38 |
| realpython.com/python-modules-packages | https://realpython.com/python-modules-packages |
| realpython.com/python-application-layouts | https://realpython.com/python-application-layouts |
| github.com/github/gitignore | https://github.com/github/gitignore |
| realpython.com/pipenv-guide | https://realpython.com/pipenv-guide |
| choosealicense.com | https://choosealicense.com |
| dbader.org/blog/write-a-great-readme-for-your-github-project | https://dbader.org/blog/write-a-great-readme-for-your-github-project |
| May 2, 2020 | https://realpython.com/courses/structuring-python-application/discussion/#comment-71b5523e-46e2-4f68-8f8e-9136bccb4ecf |
| May 3, 2020 | https://realpython.com/courses/structuring-python-application/discussion/#comment-01e09859-6825-4698-bef1-97daf866d5ed |
| May 4, 2020 | https://realpython.com/courses/structuring-python-application/discussion/#comment-33d9c49d-881a-4b79-a7ae-f49e7b42c3ac |
| Become a Member | https://realpython.com/account/join/ |
| Overview | https://realpython.com/courses/structuring-python-application/ |
| https://realpython.com/lessons/installable-single-package/ |
|
Structuring a Python Application (Overview) 12:25
| https://realpython.com/videos/structuring-python-application/ |
|
Installable Single Package 06:11
| https://realpython.com/lessons/installable-single-package/ |
|
Application With Internal Packages 06:23
| https://realpython.com/lessons/application-internal-packages/ |
|
Django Web Application 04:19
| https://realpython.com/lessons/django-web-application/ |
|
Flask Web Application 01:58
| https://realpython.com/lessons/flask-web-application/ |
|
Structuring a Python Application (Summary) 04:39
| https://realpython.com/lessons/structuring-python-application-summary/ |
| Privacy Policy | https://realpython.com/privacy-policy/ |
Viewport: width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover