Python: Development platform
Prepare your development platform for a pleasant and efficient experience
👋 Welcome to the Stackhero documentation!
Stackhero offers a ready-to-use Python cloud solution that provides a host of benefits, including:
- Deploy your application in seconds with a simple
git push.- Use your own domain name and benefit from the automatic configuration of HTTPS certificates for enhanced security.
- Enjoy peace of mind with automatic backups, one-click updates, and straightforward, transparent, and predictable pricing.
- Get optimal performance and robust security thanks to a private and dedicated VM.
Save time and simplify your life: it only takes 5 minutes to try Stackhero's Python cloud hosting solution!
Having an excellent development platform is crucial for a smooth and efficient workflow.
In this guide, we will explore how to develop remotely using a ready-to-code service or locally on your computer. We will also cover Python installation with asdf and conclude with creating a new Python project.
How to develop: locally or remotely
There are two popular approaches to Python development: setting up a local environment on your computer or utilising a cloud-based solution like Code-Hero. Each approach has its own pros and cons, so it is important to choose what best fits your needs.
Developing locally allows you to work offline without an internet connection. However, it may require more time to set up, especially if you are new to programming. You will need to manage backups, handle the limitations of your computer's processing power, and ensure data security. Local development also restricts you to a specific device, which may limit your flexibility.
On the other hand, a cloud-based solution like Code-Hero offers a preconfigured environment ready to use, saving you the hassle of setting up your own workspace. This platform provides a user-friendly interface and a suite of built-in tools, making it easy to work on multiple projects. Remote servers often offer better performance and resource availability. Plus, it is accessible from any device with an internet connection.
With pre-configured tools like Docker and Traefik, you can easily set up TLS encryption and use a real domain for your development website, similar to a production environment. This resolves common issues with external webhooks, CORS, and other web-based services, offering a smoother development experience.
Ultimately, the choice between developing locally or using a cloud-based solution depends on your preferences, skills, and project requirements.
To summarise:
-
Local development (on your computer):
- ✅ Works offline: No internet connection needed
- ❌ Limited resources: May have less processing power
- ❌ Setup required: Manual installation and tool configuration
- ❌ Maintenance: Regular updates and backups must be managed
-
Remote development (on Code-Hero):
- ✅ Ready-to-use: Tools are pre-installed for immediate development
- ✅ Enhanced performance: Access to powerful resources
- ✅ Device flexibility: Access from any computer, tablet, or phone
- ✅ External integration: HTTPS domain available for webhook interactions
- ❌ Internet dependency: Requires an internet connection
Developing in Python: the remote approach
Opting for a remote approach to Python development offers a hassle-free experience with pre-configured environments ready to use. This means you can dive into projects quickly without spending time on manual configuration.
Code-Hero runs on powerful servers, ensuring smooth performance even for resource-intensive tasks. This allows you to focus on building Python projects and improving your skills with speed, convenience, and reliability.
Once your Code-Hero service is started, you can create your first Python project in seconds. You can skip the "Developing in Python: the local approach" section and jump directly to "Creating a Python project."
Developing in Python: the local approach
Setting up a local development environment involves installing Python, necessary dependencies, and tools on your computer.
Keep in mind that local development may come with limitations, such as hardware constraints or the need for manual updates and backups.
Setting up your local Python environment
To start developing with Python, you will need to install Python and its dependencies on your computer.
We will use asdf, a versatile tool that allows you to manage multiple environments and switch between different versions effortlessly.
While asdf may seem unfamiliar, it can significantly simplify your Python development experience, saving you time and preventing common issues associated with managing multiple environments and versions.
Python has its own virtual environment handlers (python venv, mkvirtualenv, or virtualenv), commonly used to isolate project dependencies. However, with asdf, you will not need to rely on these, as it offers a more robust solution for managing various runtime environments and versions.
asdf is useful not only for Python but also for many other languages like Node.js, Ruby, PHP, and more.
Installing asdf
To install asdf, simply follow the steps outlined in the official documentation.
Once you have completed the installation, you can verify that asdf is working correctly by running asdf version in your terminal. This command should display the installed version of asdf, confirming it is ready for use.
Installing Python using asdf
To install the latest version of Python using asdf, you can execute the following commands:
asdf plugin add python https://github.com/danhper/asdf-python.git
asdf install python latest
asdf global python latest
After completing the installation, verify that everything is functioning correctly by running the command below to display the installed Python version:
python --version
This should return the version number of the newly installed Python, confirming it is properly set up and ready for use.
Creating a Python project
Creating a Python project is straightforward. Begin by creating a new directory for your project:
mkdir my_project
cd my_project
Next, set the Python version for your project (using the latest version) and initialise the Git repository:
asdf install python latest \
&& asdf local python latest
echo "__pycache__/" >> .gitignore
git init
git add -A .
git commit -m "First commit"
These steps will create a new Python project directory, configure the Python version, and initialise a Git repository with an initial commit, setting the foundation for your project's development.
We have initialised a local Git repository for your Python project, but we have not yet connected it to a remote repository hosting service.
To ensure the safety and version control of your project, it is highly recommended to create a project on your preferred repository hosting platform, such as GitLab, GitHub, or Bitbucket.
If you are looking for a Git repository hosting service, Stackhero offers GitLab cloud service that can be set up in just 2 minutes, running on a private and dedicated VM for maximum confidentiality and security, available in Europe or the USA depending on your choice.