-
Notifications
You must be signed in to change notification settings - Fork 21
Developing myRobogals on Windows
Here's how to install a local development copy of myRobogals on Windows.
Install Python 2.7 using the Windows installer from the Python website.
After installing, we will need to add Python to system's PATH environment variable. To do this, go to Control Panel -> System -> Advanced system settings. Under the Advanced tab, click on Environment Variables... Add ;C:\Python27;C:\Python27\Scripts to the end of the Path variable depending on whether or not you want Python installed for all the users on the computer or just yourself. Click Ok and close the windows. To test whether you've installed Python properly, open up a Command Window and type in python --version to confirm. If installed correctly, it will output the current Python version.
Fork the myRobogals repository from Github to create your own copy of it, then clone that copy to your local machine. The following pages may be helpful:
If you don't want to install MySQL, you can use the default SQLite that Django provides and skip all these steps. See "Generate the settings file" section for more information.
myRobogals is using a MySQL database. To be able to view the database in a meaningful way, download HeidiSQL and install it.
Next, you will need to install MySQL. Go to the MySQL downloads website and download the latest version of the MySQL MSI Installer. You can either choose to install it through the web (smaller MSI file, will download the MySQL products you choose to install) or just download it directly (bigger MSI file).
Open the MSI file choose the Developer Default to install. You can skip the prerequisites/dependencies because we won't be needing them. Finish the installation process to configure the product. In the Configuration Menu, select the following
Config Type: Development Machine
Connectivity: Tick - TCP/IP and Tick - Shared Memory. Leave the settings on default
Click next
MySQL Root Password: (choose an appropriate password and retype it in the next box)
Add user: myrobogals/myrobogals, role as DB admin This will be used to configure Django
Click next
Tick - Configure MySQL Server as a Windows Service
Tick/Untick - Start the MySQL Server at System Startup
This is dependent on whether or not you want to have MySQL running in the background when you start your computer. In most cases it's not necessary, so we can just untick the checkbox for now.
Click next. Skip over plugins. Click Execute.
Finally, click next then execute to connect to server and apply server configurations. Follow the prompts to complete installation. Open up MySQL Workbench to confirm that the server is running by clicking Server Status.
Use the MySQL documentation for windows as a reference which provides additional installation information or troubleshooting guide if you get stuck.
If the installation was successful, open HeidiSQL and connect to the MySQL server by selecting the following:
- Network type: MySQL (TCP/IP)
- Hostname / IP: 127.0.0.1
- User: root
- Password: (what you've chosen above)
- Port: 3306
Then click open. After it's connected, you will need to create a database. Right click on the side column and go to create new... database called myrobogals. Make sure Unnamed is selected, or top tree view otherwise it won't let you.
Virtualenv creates an environment to develop myRobogals with its own Python package versions that won't conflict with other packages or versions you have installed. Install virtualenv by typing:
pip install virtualenvwrapper-win
Create our new virtual environment in any directory you want as long as it's not in the myRobogals folders. The following will create a new folder called "venv":
mkvirtualenv venv
The virtual environment will be activated automatically and you’ll see (venv) next to the command prompt. If you start a new command prompt, you’ll need to activate the environment again in any folder by
workon venv.
Make sure your venv is activated before installing Django and myRobogals requirements. This is to ensure that the packages are installed within the myRobogals virtual environment. Now go to the cloned myRobogals directory and instal the required dependencies list under requirements.txt by typing:
cd (myRobogals folder path)
pip install -r requirements.txt
In the "myrobogals" directory inside the "myrobogals" directory (yes you read that correctly), make a copy of the file "settings.py.sample" and rename it to "settings.py"
Edit the file and fill in the path to your myRobogals directory at the top of the file. This is to ensure that everything gets the proper path references in your project.
Find where DATABASES is defined and enter in your MySQL credentials to ensure that Django has access to the database. If you would prefer to use SQLite, comment out the MySQL section and uncomment the one for SQLite.
To create a sample database with some mock users, chapters and workshops, first navigate to the directory containing the file manage.py. Create database structure by typing:
python manage.py migrate
Delete the timezone information, otherwise conflicts will occur when loading the sample data
python manage.py shell
In the python shell command line enter the following:
from myrobogals.rgmain.models import Timezone
Timezone.objects.all().delete()
quit()
Load in sample data
python manage.py loaddata sampledata
After completing the above steps, you should now be able to type:
python manage.py runserver
The development server will now be running on http://127.0.0.1:8000/ - click there and you'll see your very own local copy of myRobogals.
You can log in with the username "mark" and password "test" to get started. This account has admin privileges.
Now get coding, and contribute your changes back to us as a "Pull Request" on Github!
- Activate your myRobogals virtual environment (see above)
- Update your fork from the original repo to ensure you are working off the latest code
- Install/upgrade required Python packages using 'pip install --upgrade -r requirements.txt'
- Ensure that MySQL has started on your local machine. Otherwise Django will throw an error.
- Run 'python manage.py migrate' to ensure your local database structure is up to date
Error information will be listed here once reported. If found, please report them to Sing (firew0rks) or the wiki directly!
Make sure you have VC++ Compiler package for Python 2.7 installed. This can be found here. Sometimes depending on the version of MySQL you've installed (64-bit vs 32-bit) it could be missing some bin and lib files. The following error is seen in Command Prompt: “Cannot open include file: 'config-win.h': No such file or directory”. To fix this, make sure you download & install only the 32 bits version of MySQL Connector C 6.0.2 (apparently newer versions don't work). Link and stackoverflow solution can be found in references
https://dev.mysql.com/downloads/connector/c/6.0.html#downloads