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, 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
Python projects in SourceLair ship with
pip preinstalled to let you install and manage Python libraries.
While you can run a command like
pip install example-library in your terminal to install a library, we recommend putting them in a file named
requirements.txt and install them by running
pip install -r requirements.txt in your terminal.
This way you can be sure that you keep track of the different Python libraries your project depeneds on and keep consistency between your production system and SourceLair.