Of course! Let's break down what "SAE Eclipse Python" means. It's a powerful combination, and understanding each part is key to using them together effectively.

Here's a complete guide covering what each component is, how they work together, and a step-by-step tutorial.
What is SAE?
SAE stands for Sina App Engine. It is a Platform as a Service (PaaS) offered by Sina (the Chinese company behind Weibo).
Think of it as a hosting platform similar to Heroku, Google App Engine, or PythonAnywhere, but with a strong focus on the Chinese market and specific services.
Key Features of SAE:

- Easy Deployment: You can deploy your Python web applications with a simple
git pushcommand. - Managed Services: It provides managed databases (like MySQL, Redis), caching, storage, and other services out of the box.
- Scalability: It's designed to handle traffic spikes automatically.
- Chinese Infrastructure: It's hosted within China, making it ideal for applications targeting Chinese users with low latency.
- Free Tier: It offers a free tier for development and small-scale applications.
What is Eclipse?
Eclipse is a very popular, open-source Integrated Development Environment (IDE). It's a powerful code editor and development platform used by millions of developers worldwide.
Key Features of Eclipse:
- Code Editor: Syntax highlighting, auto-completion, refactoring tools.
- Debugging: Powerful graphical debugger to step through your code.
- Extensibility: Its core functionality can be extended with "plugins" to support different programming languages, frameworks, and tools.
- Version Control Integration: Built-in support for Git, SVN, etc.
For Python development, the most important plugin is PyDev.
What is PyDev?
PyDev is a plugin for Eclipse that turns it into a full-fledged Python IDE. It provides:

- Python editor with syntax highlighting and code completion.
- An integrated debugger for Python scripts.
- Support for Django, Flask, and other Python frameworks.
- Unit testing integration.
- Code analysis and linting.
So, when we talk about "Eclipse Python," we almost always mean Eclipse with the PyDev plugin.
The Synergy: SAE + Eclipse + Python
The workflow is straightforward:
- Develop in Eclipse: You write, edit, and debug your Python web application (e.g., a Flask or Django app) right inside the Eclipse IDE.
- Prepare for SAE: You make small adjustments to your code to ensure it's compatible with SAE's environment (e.g., using SAE's database services instead of local ones).
- Deploy from Eclipse: You use the Eclipse IDE's Git integration to commit your changes and push the code directly to your SAE application repository.
This setup gives you the best of both worlds: the powerful, integrated development environment of Eclipse and the easy, scalable hosting of SAE.
Step-by-Step Tutorial: Deploying a Flask App
Let's walk through creating a simple Flask application in Eclipse and deploying it to SAE.
Prerequisites
- Install Python: Make sure Python 3 is installed on your system.
- Install Eclipse: Download and install the Eclipse IDE for Enterprise Java and Web Developers. (The "Eclipse for PHP Developers" also works well and is lighter).
- Install PyDev: Inside Eclipse, go to
Help -> Install New Software.... In the "Work with" field, enterhttp://pydev.org/updatesand install the PyDev features. - Install Git: Make sure Git is installed and configured on your system.
- Get an SAE Account: Register for a free account at sae.sina.com.cn. Create a new Python 3 web application. SAE will give you a Repository URL (e.g.,
git@git.sinacloud.com:your_app_name.git).
Step 1: Create a New Python Project in Eclipse
- In Eclipse, go to
File -> New -> PyDev Project. - Give your project a name (e.g.,
sae-flask-app). - Ensure the "Interpreter" is set to your Python 3 installation.
- Click "Finish".
Step 2: Write Your Flask Application
-
In the Project Explorer, right-click your project and create a new folder named
src. -
Inside
src, create a new Python file namedwsgi.py. This is the entry point for SAE applications. -
Paste the following code into
wsgi.py. This is a simple "Hello World" Flask app.# src/wsgi.py from flask import Flask # Create the Flask application instance app = Flask(__name__) # Define a route @app.route('/') def hello(): return "Hello from SAE, deployed from Eclipse!" # This is the standard entry point for SAE if __name__ == '__main__': # The host '0.0.0.0' is required for SAE to access the app app.run(host='0.0.0.0', port=8080)
Step 3: Install Flask
You need to install Flask and add it to your project's dependencies. SAE will install these dependencies automatically when you deploy.
-
Open your system's terminal or command prompt.
-
Navigate to your Eclipse project directory.
-
Create a
requirements.txtfile in the root of your project (not insidesrc). This file tells SAE which Python packages to install.# requirements.txt Flask -
Now, install the package locally for development:
pip install -r requirements.txt
Step 4: Set up Git in Eclipse
- In Eclipse, go to
Window -> Preferences -> General -> Network Connections. - Select Git and set the "SSH2 home" to the path of your Git installation's
binfolder (e.g.,C:\Program Files\Git\binor/usr/bin). - Right-click on your project in the Project Explorer and select
Team -> Share Project.... - Select Git and click "Next".
- Create a new Git repository in your project's root directory and click "Finish".
- Stage your files: Right-click the project ->
Team -> Add to Index. - Commit your changes: Right-click the project ->
Team -> Commit.... Write a commit message like "Initial commit of Flask app" and click "Commit".
Step 5: Deploy to SAE
This is the final step. We will add the SAE remote repository and push the code.
- In Eclipse, open the Git perspective (
Window -> Open Perspective -> Git). - In the "Git Repositories" view, right-click on your project's repository.
- Select
Remote -> Create Remote.... - Name the remote
sae(or anything you like). - Paste the Repository URL you got from SAE into the "URI" field. Click "Finish".
- Now, right-click on your project's repository again and go to
Push.... - In the "Push" dialog, under "Remote", select
sae. - Under "Target", select the main branch (usually
master). - Click Add Spec... -> Remote Tracking -> RemoteRefs/HEAD ->
refs/heads/master. This ensures you are pushing to the correct branch on SAE. - Click "Push". Eclipse will ask for your SAE account credentials (username and password). Enter them.
That's it! Eclipse will push your code to SAE. SAE will detect the new code, install the dependencies from requirements.txt, and deploy your application. You can now access your app via the SAE URL provided.
Important Considerations for SAE
- Entry Point: Your application must be served from
wsgi.py. SAE looks for this file. - Port: Your app must listen on port
8080. - Database: Don't use a local database like SQLite. Use the MySQL or Redis services provided by SAE. You'll need to configure your app to read the database connection credentials from environment variables that SAE provides.
- Static Files: SAE has a specific way to serve static files. You may need to configure your Flask app to use SAE's storage service for CSS, JavaScript, and images.
