Browse Source

Optimising Windows Install (#330)

* Include windows installation instructions

* Installation instructions reorganised; Windows DB path workaround.
mattsterr 7 years ago
parent
commit
fa63c6176e
2 changed files with 39 additions and 47 deletions
  1. 33 45
      docs/installation.rst
  2. 6 2
      flaskbb/cli/main.py

+ 33 - 45
docs/installation.rst

@@ -19,11 +19,12 @@ use the package manager `pip`_ to install the dependencies for FlaskBB.
 
 Virtualenv Setup
 ~~~~~~~~~~~~~~~~
-
-The easiest way to install `virtualenv`_ and
+**Linux:** The easiest way to install `virtualenv`_ and
 `virtualenvwrapper`_ is, to use the package manager on your system (if you
 are running Linux) to install them.
 
+**Windows:** Take a look at the `flask`_ documentation (then skip ahead to dependencies).
+
 For example, on archlinux you can install them with::
 
     $ sudo pacman -S python2-virtualenvwrapper
@@ -33,7 +34,7 @@ or, on macOS, you can install them with::
     $ sudo pip install virtualenvwrapper
 
 It's sufficient to just install the virtualenvwrapper because it depends on
-virtualenv and the package manager will resolve all the dependncies for you.
+virtualenv and the package manager will resolve all the dependencies for you.
 
 After that, you can create your virtualenv with::
 
@@ -117,37 +118,37 @@ this is `pacman` and for Debian/Ubuntu based systems this is `apt-get`.
 Configuration
 -------------
 
-FlaskBB comes with the ability to generate the configuration file for you.
-Just run::
+Production / I Just Want to Try It
+~~~~~~~~~~
+
+FlaskBB already sets some sane defaults, so you shouldn't have to change much.
+To make this whole process a little bit easier for you, we have created
+a little wizard which will ask you some questions and with the answers
+you provide it will generate a configuration for you. You can of course
+further adjust the generated configuration.
+
+The setup wizard can be started with::
 
     flaskbb makeconfig
 
-and answer its questions. By default it will try to save the configuration
-file with the name ``flaskbb.cfg`` in FlaskBB's root folder.
 
-You can also omit the questions, which will generate a **developemnt**
-configuration by passing the ``-d/--development`` option to it::
+These are the only settings you have to make sure to setup accordingly if
+you want to run FlaskBB in production:
 
-    flaskbb makeconfig -d
+- ``SERVER_NAME = "example.org"``
+- ``PREFERRED_URL_SCHEME = "https"``
+- ``SQLALCHEMY_DATABASE_URI = 'sqlite:///path/to/flaskbb.sqlite'``
+- ``SECRET_KEY = "secret key"``
+- ``WTF_CSRF_SECRET_KEY = "secret key"``
 
-In previous versions, FlaskBB tried to assume which configuration file to use,
-which it will no longer do. Now, by default, it will load a config with
-some sane defaults (i.e. debug off) but thats it. You can either pass an
-import string to a config object or the path to the (python) config file.
+By default it will try to save the configuration file with the name flaskbb.cfg in FlaskBB’s root folder.
 
-For example, if you are using a generated config file it looks something
-like this::
+Finally to get going – fire up FlaskBB!
 
     flaskbb --config flaskbb.cfg run
     [+] Using config from: /path/to/flaskbb/flaskbb.cfg
      * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
 
-and this is how you do it by using an import string. Be sure that it is
-importable from within FlaskBB::
-
-    flaskbb --config flaskbb.configs.default.DefaultConfig run
-
-
 Development
 ~~~~~~~~~~~
 
@@ -155,6 +156,10 @@ To get started with development you have to generate a development
 configuration first. You can use the CLI for this,
 as explained in `Configuration <#configuration>`_::
 
+    flaskbb makeconfig -d
+
+or
+
     flaskbb makeconfig --development
 
 Now you can either use ``make`` to run the development server::
@@ -165,30 +170,10 @@ or if you like to type a little bit more, the CLI::
 
     flaskbb --config flaskbb.cfg run
 
+You can either pass an import string to the path to the (python) config file you’ve just created, or a default config object. (Most users will follow the example above, which uses the generated file).
+This is how you do it by using an import string. Be sure that it is importable from within FlaskBB:
 
-Production
-~~~~~~~~~~
-
-FlaskBB already sets some sane defaults, so you shouldn't have to change much.
-To make this whole process a little bit easier for you, we have created
-a little wizard which will ask you some questions and with the answers
-you provide it will generate a configuration for you. You can of course
-further adjust the generated configuration.
-
-The setup wizard can be started with::
-
-    flaskbb makeconfig
-
-
-These are the only settings you have to make sure to setup accordingly if
-you want to run FlaskBB in production:
-
-- ``SERVER_NAME = "example.org"``
-- ``PREFERRED_URL_SCHEME = "https"``
-- ``SQLALCHEMY_DATABASE_URI = 'sqlite:///path/to/flaskbb.sqlite'``
-- ``SECRET_KEY = "secret key"``
-- ``WTF_CSRF_SECRET_KEY = "secret key"``
-
+    flaskbb --config flaskbb.configs.default.DefaultConfig run
 
 Redis
 ~~~~~
@@ -256,6 +241,8 @@ Both methods are included in the example configs.
 Installation
 ------------
 
+**Sqlite users:** create a DB file in your project source.
+
 For a guided install, run::
 
     $ make install
@@ -526,3 +513,4 @@ to say
 .. _virtualenv: https://virtualenv.pypa.io/en/latest/installation.html
 .. _virtualenvwrapper: http://virtualenvwrapper.readthedocs.org/en/latest/install.html#basic-installation
 .. _pip: http://www.pip-installer.org/en/latest/installing.html
+.. _flask: http://flask.pocoo.org/docs/0.12/installation/ 

+ 6 - 2
flaskbb/cli/main.py

@@ -453,12 +453,16 @@ def generate_config(development, output, force):
     if os.path.exists(config_path) and not os.path.isfile(config_path):
         config_path = os.path.join(config_path, "flaskbb.cfg")
 
+    # An override to handle database location paths on Windows environments
+    database_path = "sqlite:///" + os.path.join(os.path.dirname(current_app.instance_path), "flaskbb.sqlite")
+    if os.name == 'nt':
+        database_path = database_path.replace("\\", r"\\")
+
     default_conf = {
         "is_debug": True,
         "server_name": "localhost:5000",
         "url_scheme": "http",
-        "database_uri": "sqlite:///" + os.path.join(
-            os.path.dirname(current_app.root_path), "flaskbb.sqlite"),
+        "database_uri": database_path,
         "redis_enabled": False,
         "redis_uri": "redis://localhost:6379",
         "mail_server": "localhost",