Python on SourceLair
Python is a first-class citizen in the supported stacks of SourceLair. This means that you can start developing your Python applications on SourceLair in seconds.
Python web applications
If you plan to work on a Python web application on SourceLair and start a project from scratch, it will work out of the box.
If you are creating a project by cloning an existing repo though, make sure to:
- Bind your server to
- Listen to the port exposed in the
PORTenvironment variable (see table below)
SourceLair provides first-class support for Django and Flask, but you can use any Python framework to build your web applications.
You can let SourceLair know what framework you will use when creating your project to get a more tailored experience.
Exposing your application to its Public URL
You should bind on the port defined in the
PORT environment variable, in order to be able to access your Python web applications via your project’s Public URL.
Below is the list of the ports that SourceLair exposes for each framework. You should use the
PORT environment variable to determinal to which port you should listen.
Customizing how your web applications runs
To customize how your web application runs (e.g. set an explicit command to run your server or configure a worker process), make sure to:
- Learn about the available environment variables in your project
- Learn how to customize your server using a
SourceLair supports the latest minor version for both Python 3 and 2. When a new Python minor version (e.g. 3.7) or bugfix (e.g. 3.6.2) release gets published, we will update all corresponding projects automatically (e.g. from 3.6 to 3.7, but not from 2.7 to 3.7).
Setting the Python version of your project
You can set the Python version of your project when creating it by:
- Clicking on the Customize tab
- Choosing Python as the language of your choice
- Choosing the Version of your choice
- Creating your project
- Python 3.6 (3.6.1)
- Python 2.7 (2.7.13)
Version support roadmap
- 📅 Monday 4 September 2017: Python 3 becomes the default Python version on SourceLair
- ⚠️ Monday 6 January 2018: SourceLair drops option for Python 2 for new projects
To install a Python library (e.g. Django) in your SourceLair project, just run the following command in your terminal:
pipenv install django
This will install Django in your SourceLair project’s workspace, add Django as a dependency in your
Pipfile.lock files to make sure you install the same libraries and library versions across your development and production systems.
You can also use
pip out of the box as well, but we recommend using
pipenv instead, as it’s superior.