A dependency is software or a service that a component relies on but does not implement itself. A simple to-do app might need only Python and Streamlit. Add a feature that fetches information online, and the app may also depend on a third-party library and an API. Those dependencies help the app do more, but they also affect deployment and testing. section 5.3 section 11.3.1
Two common kinds of external dependency are:
- A Python library, such as requests: app code calls it, but its implementation lives outside the app. section 5.4.1 section 11.3.1
- A remote service, such as an API that supplies dictionary entries, exchange rates, or news headlines: the app connects to it to obtain information. section 5.3
A dependency that works on your laptop must also be available in production. For Python libraries, list compatible versions in requirements.txt and install them with pip install -r requirements.txt. Streamlit Community Cloud reads that file from the GitHub repository and installs the listed libraries. An unqualified name leaves the version unspecified; == selects an exact version, while >= sets a minimum. Matching versions matters when code uses a feature absent from an older release, and even a newer release could remove a feature the app needs. section 5.4.1
Listing 5.5 A strict requirements.txt file
requests==2.31.0 streamlit==1.34.0
The strict requirements.txt example pins requests and streamlit to exact versions, making the intended production installations explicit. section 5.4.1
A virtual environment keeps a project's Python and libraries isolated, so changing one project's dependencies need not disrupt another. Remote services need different preparation: an app using an external API may require an account and a secret key, which must be kept safe. section 2.2.3 section 9.2.2
Keep a unit test independent of an API
Suppose a movie-search component calls requests.get, then uses the TMDB API's response. Both the requests implementation and the API are outside that component. Replace their behavior with controlled fakes during a unit test: the test can check the component's own code without making a real network call or failing because the API is busy. Use integration or end-to-end tests to examine behavior beyond that isolated component. section 11.3.1 section 11.8


























