Monthly Archives: October 2016

Running ReadTheDocs on Windows

Hey everyone,

This is a quick guide on how to setup your own readthedocs server on Windows.

Install Python 2.7: https://www.python.org/downloads/

Install virtual env using pip via command prompt (run as administrator):
c:\Python27>python.exe scripts\pip.exe install virtualenv

Create a virtual environment:
c:\Python27>scripts\virtualenv.exe c:\readthedocs
c:\readthedocs\Scripts>activate.bat
(readthedocs) c:\readthedocs\Scripts>

Create a folder and clone the repository:
(readthedocs) c:\readthedocs\Scripts>md checkouts
(readthedocs) c:\readthedocs\Scripts>cd checkouts
(readthedocs) c:\readthedocs\Scripts\checkouts>git clone http://github.com/rtfd/readthedocs.org.git
Cloning into 'readthedocs.org'...
remote: Counting objects: 47896, done.
remote: Compressing objects: 100% (53/53), done.
remote: Total 47896 (delta 19), reused 0 (delta 0), pack-reused 47843
Receiving objects: 100% (47896/47896), 37.91 MiB | 8.76 MiB/s, done.
Resolving deltas: 100% (31783/31783), done.
Checking connectivity... done.

Get and install dependencies using pip:
(readthedocs) c:\readthedocs\Scripts\checkouts>cd readthedocs.org
(readthedocs) c:\readthedocs\Scripts\checkouts\readthedocs.org>git clone http://github.com/rtfd/readthedocs.org.git

Ran into the following error: no module named django.core.management (probably caused by having two version of python installed)
(readthedocs) c:\readthedocs\Scripts\checkouts\readthedocs.org>c:\Python27\python.exe c:\readthedocs\Scripts\pip.exe install django --upgrade
Collecting django
Using cached Django-1.10.2-py2.py3-none-any.whl
Installing collected packages: django
Successfully installed django-1.10.2
You are using pip version 8.1.1, however version 8.1.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' comm
and.

Build the database:
(readthedocs) c:\readthedocs\Scripts\checkouts\readthedocs.org>c:\Python27\pytho
n.exe C:\readthedocs\Scripts\checkouts\readthedocs.org\manage.py syncdb
Operations to perform:
Synchronize unmigrated apps: allauth, messages, django_extensions, django_grav
atar, rest_framework, annoying, textclassifier, corsheaders, copyright, privacy,
django_countries, humanize, rtd_tests, haystack, doc_builder, staticfiles, rest
api, bitbucket_oauth2, bitbucket, notifications, djangosecure, pagination, githu
b, djcelery, payments
Apply all migrations: core, account, builds, gold, sessions, admin, guardian,
tastypie, messages_extends, comments, sites, contenttypes, redirects, auth, tagg
it, oauth, bookmarks, donate, projects, socialaccount
Synchronizing apps without migrations:
Creating tables...
Creating table corsheaders_corsmodel
Creating table celery_taskmeta
Creating table celery_tasksetmeta
Creating table djcelery_intervalschedule
Creating table djcelery_crontabschedule
Creating table djcelery_periodictasks
Creating table djcelery_periodictask
Creating table djcelery_workerstate
Creating table djcelery_taskstate
Running deferred SQL...
Installing custom SQL...
Running migrations:
Rendering model states... DONE
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying account.0001_initial... OK
Applying account.0002_email_max_length... OK
Applying admin.0001_initial... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying taggit.0001_initial... OK
Applying projects.0001_initial... OK
Applying builds.0001_initial... OK
Applying projects.0002_add_importedfile_model... OK
Applying bookmarks.0001_initial... OK
Applying builds.0002_build_command_initial... OK
Applying comments.0001_initial... OK
Applying core.0001_initial... OK
Applying core.0002_make_userprofile_user_a_onetoonefield... OK
Applying core.0003_add_banned_status... OK
Applying donate.0001_initial... OK
Applying donate.0002_dollar-drop-choices... OK
Applying donate.0003_add-impressions... OK
Applying donate.0004_rebase-impressions-on-base... OK
Applying donate.0005_add-geo-filters... OK
Applying donate.0006_add-geo-data... OK
Applying donate.0007_add-impression-totals... OK
Applying gold.0001_initial... OK
Applying guardian.0001_initial... OK
Applying messages_extends.0001_initial... OK
Applying sites.0001_initial... OK
Applying socialaccount.0001_initial... OK
Applying socialaccount.0002_token_max_lengths... OK
Applying oauth.0001_initial... OK
Applying oauth.0002_combine_services... OK
Applying oauth.0003_move_github... OK
Applying oauth.0004_drop_github_and_bitbucket_models... OK
Applying oauth.0005_add_account_relation... OK
Applying oauth.0006_move_oauth_source... OK
Applying oauth.0007_org_slug_nonunique... OK
Applying projects.0003_project_cdn_enabled... OK
Applying projects.0004_add_project_container_image... OK
Applying projects.0005_sync_project_model... OK
Applying projects.0006_add_domain_models... OK
Applying projects.0007_migrate_canonical_data... OK
Applying projects.0008_add_subproject_alias_prefix... OK
Applying projects.0009_add_domain_field... OK
Applying projects.0010_migrate_domain_data... OK
Applying projects.0011_delete-url... OK
Applying projects.0012_proper-name-for-install-project... OK
Applying projects.0013_add-container-limits... OK
Applying projects.0014_add-state-tracking... OK
Applying projects.0015_add_project_allow_promos... OK
Applying projects.0016_build-queue-name... OK
Applying projects.0017_add_domain_https... OK
Applying redirects.0001_initial... OK
Applying sessions.0001_initial... OK
Applying taggit.0002_auto_20150616_2121... OK
Applying tastypie.0001_initial... OK

Starting the readthedocs server:
D:\Users\ChrisO>C:\readthedocs\Scripts\activate.bat

(readthedocs) D:\Users\ChrisO>c:\Python27\python.exe C:\readthedocs\Scripts\chec
kouts\readthedocs.org\manage.py runserver
Performing system checks…

System check identified no issues (1 silenced).
October 21, 2016 – 11:16:17
Django version 1.8.3, using settings ‘readthedocs.settings.dev’
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.

Create a new readthedocsproject:
I followed this guide: http://read-the-docs.readthedocs.io/en/latest/getting_started.html#in-rst

Creating the new project:
C:\readthedocs>md whatibroke
C:\readthedocs>cd whatibroke
C:\readthedocs\whatibroke>C:\readthedocs\Scripts\sphinx-quickstart.exe
Welcome to the Sphinx 1.3.5 quickstart utility.

Please enter values for the following settings (just press Enter to
accept a default value, if one is given in brackets).

Installing a theme – sphinx_rtd_theme (optional step):
c:\readthedocs\Scripts>activate.bat
(readthedocs) c:\readthedocs\Scripts>cd c:\readthedocs\whatibroke
(readthedocs) c:\readthedocs\whatibroke>pip install sphinx_rtd_theme

In your conf.py file (C:\readthedocs\whatibroke\conf.py):
import sphinx_rtd_theme
html_theme = "sphinx_rtd_theme"
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]

Building your output:
c:\readthedocs\Scripts>activate.bat
(readthedocs) c:\readthedocs\Scripts>cd c:\readthedocs\whatibroke
(readthedocs) c:\readthedocs\whatibroke>make html
Running Sphinx v1.3.5
loading pickled environment... done
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 0 source files that are out of date
updating environment: 0 added, 0 changed, 0 removed
looking for now-outdated files... none found
no targets are out of date.
build succeeded.

Build finished. The HTML pages are in _build/html.

Thanks to the following stackoverflow post for a lot of the information here: http://stackoverflow.com/a/19892345/522859