Django2.2 with Watchman

runserver can now use Watchman to improve the performance of watching a large number of files for changes.

Python3.7

Python3.7 安装时遇到_ssl 模块没法编译成功,需要安装 openssl-1.0.2 版本以上
下载 openssl 版本包后解压指定路径安装

1
2
3
4
5
6
7
8
9
10
$ cd openssl-xxxx-dir
$ ./config --prefix=/usr/local/openssl
$ make && make install
# 如果你需要覆盖原来的openssl版本,请参考其他openssl安装教程

# 安装Python3.7 指定openssl路径
$ cd Python-3.7-dir
$ ./configure --prefix=/usr/local/python37 --enable-shared --with-openssl=/usr/local/openssl
$ make && make install
$ ln -s /usr/local/python37/bin/python3 /usr/sbin/

安装完 Django 后调试时发现输出如下

1
2
3
4
$ python3 manage.py runserver
Watchman unavailable: pywatchman not installed.
Watching for file changes with StatReloader
Performing system checks…

需要安装watchmanpip install pywatchman

Watchman

django2.2 增加了对 watchman 的支持,更好进行调试

1
2
3
4
5
6
7
8
$ git clone https://github.com/facebook/watchman.git
$ cd watchman
$ git checkout v4.9.0 # the latest stable release
# 使用 Centos6 的需要修改`Makefile.am` 参考https://github.com/facebook/watchman/issues/534
$ ./autogen.sh
$ ./configure
$ make
$ sudo make install

遇到的问题

Watchman 安装遇到的问题:

configure: error: *** A compiler with support for C++11 language features is required.

解决办法:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 1. 安装yum centos-release-scl仓库:
$ sudo yum install centos-release-scl

# 启用 RHSCL 仓库:
$ sudo yum-config-manager --enable rhel-server-rhscl-7-rpms

# 2. 安装devtoolset-7开发工具:
$ sudo yum install devtoolset-7

# 3. 使用devtoolset-7环境:
$ scl enable devtoolset-7 bash

# 4. 这里会进入新的开发环境,可以使用gcc --version查看,重新编译安装watchman,
# Ctrl + d 可以退出当前环境