Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating python README #124

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 60 additions & 45 deletions python/README.md
Original file line number Diff line number Diff line change
@@ -1,74 +1,89 @@
# Python platform

The Python platform uses python 2.7.14 by default and get your dependencies with pip,
either by ``Pipfile.lock``, ``requirements.txt`` or ``setup.py``.
The Python platform uses python `3.11.3` by default and get your dependencies
with pip, either by `Pipfile.lock`, `requirements.txt` or `setup.py`.

You can define which python version you want using ``.python-version``, always use full versions.
You can define which python version you want using `.python-version`, always
use full versions.

ex:
```
3.6.1
3.11.3
```

available python versions:
Available python versions:
- 2.7.14
- 3.5.5
- 3.6.5
- 3.7.4
- pypy2.7-5.10.0
- pypy3.5-5.10.1

when adding new releases, we will retain previous version on the series to allow time for users update their apps.
e,g: when 3.6.3 is released, we will remove 3.6.1.
- 3.5.10
- 3.6.15
- 3.7.16
- 3.8.16
- 3.9.16
- 3.10.11
- 3.11.3
- pypy2.7-7.3.2
- pypy3.6-7.3.2

when adding new releases, we will retain previous version on the series to
allow time for users update their apps. e,g: when 3.6.3 is released, we will
remove 3.6.1.

## Setting pip version

By default, the latest pip version will be installed. If you want to use a specific version, set
a ``PYTHON_PIP_VERSION`` environment variable. It accepts a specific version (``PYTHON_PIP_VERSION=7.1.2``) or a
By default, the latest pip version will be installed. If you want to use a
specific version, set a `PYTHON_PIP_VERSION` environment variable. It accepts
a specific version (`PYTHON_PIP_VERSION=7.1.2`) or a
[requirement specifier](https://pip.pypa.io/en/stable/reference/pip_install/#requirement-specifiers)
(``PYTHON_PIP_VERSION="<10"``).
(`PYTHON_PIP_VERSION="<10"`).

## Code deployment

If you just run a ``tsuru app deploy`` of your code, tsuru will try
to download all of your depencies using ``requirements.txt`` or ``setup script``.
You can customize this behavior, see the next section for more details.
If you just run a `tsuru app deploy` of your code, tsuru will try to download
all of your depencies using `requirements.txt` or `setup script`. You can
customize this behavior, see the next section for more details.

## Code deployment with dependencies

There are two ways to list the applications dependencies: ``requirements.txt`` or ``setup.py``.
The priority order is: requirements -> setup. The file should be in the root of deploy files.
There are two ways to list the applications dependencies: `requirements.txt`
or ``setup.py``. The priority order is: requirements -> setup. The file should
be in the root of deploy files.

### Using Pipfile.lock

If you have a ``Pipfile.lock`` file, tsuru will use pipenv to install the dependencies of your application.
If you have a `Pipfile.lock` file, tsuru will use pipenv to install the
dependencies of your application.

### Using requirements.txt

You can define a file called ``requirements.txt`` that list all pip dependencies of your application,
each line represents one dependency, here's an example:
You can define a file called `requirements.txt` that list all pip
dependencies of your application, each line represents one dependency, here's
an example:

$ cat requirements.txt
Flask==0.10.1
gunicorn==19.3.0
$ cat requirements.txt
```
Flask==0.10.1
gunicorn==19.3.0
```

### Using setup script

You can also define the setup script to list your dependencies, here's an example:

$ cat setup.py
from setuptools import setup, find_packages
setup(
name="app-name",
packages=find_packages(),
description="example",
include_package_data=True,
install_requires=[
"Flask==0.10.1",
"gunicorn==19.3.0",
],
)

After invoking ``tsuru app-deploy``, tsuru will receive your code and tell the platform
to install all the dependencies using ``pipenv install --system --deploy``, ``pip install -r requirements.txt``
or ``pip instal -e ./``.
You can also define the setup script to list your dependencies, here's an
example:

$ cat setup.py
```python
from setuptools import setup, find_packages
setup(
name="app-name",
packages=find_packages(),
description="example",
include_package_data=True,
install_requires=[
"Flask==0.10.1",
"gunicorn==19.3.0",
],
)
```

After invoking `tsuru app-deploy`, tsuru will receive your code and tell the
platform to install all the dependencies using `pipenv install --system
--deploy`, `pip install -r requirements.txt` or `pip instal -e ./`.