Compare commits
No commits in common. "bdffd6641cfda8972576917e822d9aa74f3793c1" and "ff81a00ad67fe926d7d3752993f5789002b7634f" have entirely different histories.
bdffd6641c
...
ff81a00ad6
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
a Python WSGI Web Framework. Build with Bottle and Mako.
|
a Python WSGI Web Framework. Build with Bottle and Mako.
|
||||||
|
|
||||||
### [`Getting Starter`](pages/getting-starter)
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
CostaPy
|
CostaPy
|
||||||
|
|||||||
@ -35,4 +35,3 @@
|
|||||||
* Requirement
|
* Requirement
|
||||||
* [git](pages/requirement/git.md)
|
* [git](pages/requirement/git.md)
|
||||||
* [venv](pages/requirement/venv.md)
|
* [venv](pages/requirement/venv.md)
|
||||||
* [pip](pages/requirement/pip.md)
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## Requirement
|
## Requirement
|
||||||
|
|
||||||
You need a [git](pages/requirement/git.md), `python`, [pip](pages/requirement/pip.md), and [venv](pages/requirement/venv.md) before using CostaPy.
|
You need a [git](pages/requirement/git.md), `python`, `pip`, and [venv](pages/requirement/venv.md) before using CostaPy.
|
||||||
|
|
||||||
Install them using the following commands on your `Debian` or `Ubuntu` system.
|
Install them using the following commands on your `Debian` or `Ubuntu` system.
|
||||||
|
|
||||||
@ -44,6 +44,3 @@ Use this command below to start the web service and it will run on port `11000`
|
|||||||
```
|
```
|
||||||
Here, `costapy-welcome` is the label of your service. You can replace it with any name you prefer.
|
Here, `costapy-welcome` is the label of your service. You can replace it with any name you prefer.
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
[`Back to Homepage`](/) [`Learn the structure`](pages/structure)
|
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
# git
|
# git
|
||||||
|
|
||||||
**Git** is a **distributed version control system (VCS)** used to **track changes in source code**, especially in software development.
|
Work in progress
|
||||||
|
|||||||
@ -1,198 +0,0 @@
|
|||||||
# pip
|
|
||||||
|
|
||||||
`pip` is Python’s **package manager**.
|
|
||||||
It’s the tool you use to **install, upgrade, and remove Python libraries** that aren’t included in the standard library.
|
|
||||||
|
|
||||||
Think of it like:
|
|
||||||
|
|
||||||
* `apt` on Debian/Ubuntu
|
|
||||||
* `dnf` on Fedora
|
|
||||||
* `npm` for JavaScript
|
|
||||||
|
|
||||||
## What does pip do?
|
|
||||||
|
|
||||||
With `pip`, you can:
|
|
||||||
|
|
||||||
1. **Install packages**
|
|
||||||
|
|
||||||
```bash
|
|
||||||
pip install requests
|
|
||||||
```
|
|
||||||
|
|
||||||
2. **Upgrade packages**
|
|
||||||
|
|
||||||
```bash
|
|
||||||
pip install --upgrade requests
|
|
||||||
```
|
|
||||||
|
|
||||||
3. **Uninstall packages**
|
|
||||||
|
|
||||||
```bash
|
|
||||||
pip uninstall requests
|
|
||||||
```
|
|
||||||
|
|
||||||
4. **List installed packages**
|
|
||||||
|
|
||||||
```bash
|
|
||||||
pip list
|
|
||||||
```
|
|
||||||
|
|
||||||
5. **Install from a requirements file**
|
|
||||||
|
|
||||||
```bash
|
|
||||||
pip install -r requirements.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
## Where do packages come from?
|
|
||||||
|
|
||||||
By default, pip downloads packages from **PyPI** (Python Package Index):
|
|
||||||
|
|
||||||
* [https://pypi.org](https://pypi.org)
|
|
||||||
* Contains **hundreds of thousands** of Python libraries
|
|
||||||
* Example packages: `requests`, `numpy`, `flask`, `django`, `pandas`
|
|
||||||
|
|
||||||
## pip vs Python itself
|
|
||||||
|
|
||||||
* **Python** → the programming language + standard library
|
|
||||||
* **pip** → installs *extra* libraries written by the community
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
```python
|
|
||||||
import math # standard library (no pip needed)
|
|
||||||
import requests # external library (installed via pip)
|
|
||||||
```
|
|
||||||
|
|
||||||
## pip and Python versions
|
|
||||||
|
|
||||||
On many systems:
|
|
||||||
|
|
||||||
* `pip` → Python 2 or system default
|
|
||||||
* `pip3` → Python 3
|
|
||||||
|
|
||||||
Safer way (recommended):
|
|
||||||
|
|
||||||
```bash
|
|
||||||
python3 -m pip install requests
|
|
||||||
```
|
|
||||||
|
|
||||||
This ensures pip matches the Python version you’re using.
|
|
||||||
|
|
||||||
## Virtual environments
|
|
||||||
|
|
||||||
`pip` works best with **virtual environments** ([venv](pages/requirement/venv.md)) to avoid breaking system Python:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
python3 -m venv venv
|
|
||||||
source venv/bin/activate
|
|
||||||
pip install flask
|
|
||||||
```
|
|
||||||
|
|
||||||
## What is `requirements.txt`?
|
|
||||||
|
|
||||||
`requirements.txt` is a **list of Python packages** (and versions) your project depends on.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
```txt
|
|
||||||
flask==3.0.0
|
|
||||||
requests>=2.31.0
|
|
||||||
gunicorn
|
|
||||||
```
|
|
||||||
|
|
||||||
## Install dependencies from `requirements.txt`
|
|
||||||
|
|
||||||
### Basic usage
|
|
||||||
|
|
||||||
```bash
|
|
||||||
pip install -r requirements.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
### Safer (recommended)
|
|
||||||
|
|
||||||
```bash
|
|
||||||
python3 -m pip install -r requirements.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
This ensures pip matches your Python version.
|
|
||||||
|
|
||||||
## Use with a virtual environment (best practice)
|
|
||||||
|
|
||||||
```bash
|
|
||||||
python3 -m venv venv
|
|
||||||
source venv/bin/activate
|
|
||||||
|
|
||||||
pip install -r requirements.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
After activation, all packages go into `venv/`.
|
|
||||||
|
|
||||||
## Generate `requirements.txt` from current environment
|
|
||||||
|
|
||||||
If you already installed packages:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
pip freeze > requirements.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
⚠️ This captures **everything** installed in the environment.
|
|
||||||
|
|
||||||
## Common version formats
|
|
||||||
|
|
||||||
```txt
|
|
||||||
flask==3.0.0 # exact version (reproducible builds)
|
|
||||||
requests>=2.31.0 # minimum version
|
|
||||||
numpy~=1.26.0 # compatible release
|
|
||||||
django<5.0 # version upper limit
|
|
||||||
```
|
|
||||||
|
|
||||||
## Install from multiple requirement files
|
|
||||||
|
|
||||||
```bash
|
|
||||||
pip install -r base.txt -r dev.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
Useful for:
|
|
||||||
|
|
||||||
* `base.txt` → production
|
|
||||||
* `dev.txt` → development tools (pytest, black, etc.)
|
|
||||||
|
|
||||||
## Requirements from Git / local path
|
|
||||||
|
|
||||||
```txt
|
|
||||||
git+https://github.com/pallets/flask.git
|
|
||||||
-e .
|
|
||||||
```
|
|
||||||
|
|
||||||
Then install:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
pip install -r requirements.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
## Debian / system Python warning (important)
|
|
||||||
|
|
||||||
On Debian-based systems, **don’t install globally** unless you know what you’re doing:
|
|
||||||
|
|
||||||
❌ Bad:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo pip install -r requirements.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
✅ Good:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
python3 -m venv venv
|
|
||||||
pip install -r requirements.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
## Typical workflow (TL;DR)
|
|
||||||
|
|
||||||
```bash
|
|
||||||
python3 -m venv venv
|
|
||||||
source venv/bin/activate
|
|
||||||
pip install -r requirements.txt
|
|
||||||
python app.py
|
|
||||||
```
|
|
||||||
|
|
||||||
@ -14,41 +14,7 @@ When a project is no longer needed, deleting its virtual environment is straight
|
|||||||
|
|
||||||
## How it works?
|
## How it works?
|
||||||
|
|
||||||
When you run:
|
When you run `python3 -m venv your_venv_directory_name`, Python creates a directory for “A mini Python install just for this project”. When you activate it with `source .venv/bin/activate`, your shell is told "When I type `python` or `pip`, use the ones inside `.venv`", Nothing else changes. So, when you type `pip install requests`, it installs only inside `.venv`. Then, you can deactivate venv with `deactivate` command.
|
||||||
|
|
||||||
```sh
|
|
||||||
python3 -m venv your_venv_directory_name
|
|
||||||
```
|
|
||||||
|
|
||||||
Python creates a directory for *“A mini Python install just for this project”*.
|
|
||||||
|
|
||||||
When you activate it with
|
|
||||||
|
|
||||||
```sh
|
|
||||||
source your_venv_directory_name/bin/activate
|
|
||||||
```
|
|
||||||
|
|
||||||
You should see
|
|
||||||
|
|
||||||
```sh
|
|
||||||
(your_venv_directory_name)
|
|
||||||
```
|
|
||||||
|
|
||||||
your shell is told *"When I type `python` or [pip](pages/requirement/pip.md), use the ones inside `your_venv_directory_name`"*, Nothing else changes.
|
|
||||||
|
|
||||||
So, when you type:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
pip install requests
|
|
||||||
```
|
|
||||||
|
|
||||||
it installs only inside `your_venv_directory_name`.
|
|
||||||
|
|
||||||
Then, you can deactivate venv with this command:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
deactivate
|
|
||||||
```
|
|
||||||
|
|
||||||
## Why I add `venv` on my `gitignore`?
|
## Why I add `venv` on my `gitignore`?
|
||||||
|
|
||||||
|
|||||||
@ -45,6 +45,4 @@ A front-end directory for pages. Use this to organize individual front-end pages
|
|||||||
|
|
||||||
By adhering to this structure, you ensure clarity, consistency, and modularity in your framework.
|
By adhering to this structure, you ensure clarity, consistency, and modularity in your framework.
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
[`Back to Getting starter`](pages/getting-starter)
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user