Merge pull request #459 from evandroforks/fix_windows_build

Fixed development compilation with Windows 10
This commit is contained in:
Damien Elmes 2020-02-27 14:13:06 +10:00 committed by GitHub
commit aefce51dae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 101 additions and 35 deletions

View File

@ -26,6 +26,7 @@ Arthur Milchior <arthur@milchior.fr>
Yngve Hoiseth <yngve@hoiseth.net>
Ijgnd
Yoonchae Lee
Evandro Coan <github.com/evandrocoan>
Alan Du <alanhdu@gmail.com>
********************

View File

@ -1,4 +1,17 @@
SHELL := bash
SHELL := /bin/bash
ifeq ($(OS),Windows_NT)
PYTHON_BIN := python
ACTIVATE_SCRIPT := pyenv/Scripts/activate
else
PYTHON_BIN := python3
ACTIVATE_SCRIPT := pyenv/bin/activate
endif
ifndef ANKI_EXTRA_PIP
ANKI_EXTRA_PIP := echo The custom pip command variable ANKI_EXTRA_PIP was not defined...
endif
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
@ -18,10 +31,12 @@ all: run
# - modern pip required for wheel
# - add qt if missing
pyenv:
python3 -m venv pyenv && \
. pyenv/bin/activate && \
pip install --upgrade pip setuptools && \
python -c 'import PyQt5' 2>/dev/null || pip install -r qt/requirements.qt
"${PYTHON_BIN}" -m venv pyenv && \
. "${ACTIVATE_SCRIPT}" && \
python --version && \
python -m pip install --upgrade pip setuptools && \
${ANKI_EXTRA_PIP} && \
python -c 'import PyQt5' 2>/dev/null || python -m pip install -r qt/requirements.qt
# update build hash
.PHONY: buildhash
@ -35,7 +50,7 @@ buildhash:
.PHONY: develop
develop: pyenv buildhash prepare
@set -eo pipefail && \
. pyenv/bin/activate && \
. "${ACTIVATE_SCRIPT}" && \
for dir in $(DEVEL); do \
$(SUBMAKE) -C $$dir develop BUILDFLAGS="$(BUILDFLAGS)"; \
done
@ -43,9 +58,9 @@ develop: pyenv buildhash prepare
.PHONY: run
run: develop
@set -eo pipefail && \
. pyenv/bin/activate && \
. "${ACTIVATE_SCRIPT}" && \
echo "Starting Anki..."; \
qt/runanki $(RUNFLAGS)
python qt/runanki $(RUNFLAGS)
.PHONY: prepare
prepare: rslib/ftl/repo qt/ftl/repo qt/po/repo
@ -64,17 +79,17 @@ build: clean-dist build-rspy build-pylib build-qt add-buildhash
.PHONY: build-rspy
build-rspy: pyenv buildhash
@. pyenv/bin/activate && \
@. "${ACTIVATE_SCRIPT}" && \
$(SUBMAKE) -C rspy build BUILDFLAGS="$(BUILDFLAGS)"
.PHONY: build-pylib
build-pylib:
@. pyenv/bin/activate && \
@. "${ACTIVATE_SCRIPT}" && \
$(SUBMAKE) -C pylib build
.PHONY: build-qt
build-qt:
@. pyenv/bin/activate && \
@. "${ACTIVATE_SCRIPT}" && \
$(SUBMAKE) -C qt build
.PHONY: clean
@ -94,7 +109,7 @@ check: pyenv buildhash
for dir in $(CHECKABLE_RS); do \
$(SUBMAKE) -C $$dir check; \
done; \
. pyenv/bin/activate && \
. "${ACTIVATE_SCRIPT}" && \
$(SUBMAKE) -C rspy develop && \
$(SUBMAKE) -C pylib develop && \
for dir in $(CHECKABLE_PY); do \
@ -106,7 +121,7 @@ check: pyenv buildhash
.PHONY: fix
fix:
@set -eo pipefail && \
. pyenv/bin/activate && \
. "${ACTIVATE_SCRIPT}" && \
for dir in $(CHECKABLE_RS) $(CHECKABLE_PY); do \
$(SUBMAKE) -C $$dir fix; \
done; \

View File

@ -76,3 +76,29 @@ You can use homebrew to install some dependencies:
$ brew install python mpv lame portaudio protobuf npm rustup-init gettext rename
$ brew link gettext --force
Windows users (using Visual Studio)
----------
1. Download and install Cygwin and put its `/bin/` directory on your system path.
1. Install the Cygwin Packages: `apt-cyg install rsync make`
1. Download `gettext` 0.20.1 or superior and put its `bin` directory on your system path.
1. https://mlocati.github.io/articles/gettext-iconv-windows.html
1. If the Cygwin `/usr/bin/` directory exists, move all files from `/usr/bin/` to `/bin/`.
The problem with the `/usr/bin/` is that it should not exists. Cygwin should map/mount `/bin/`
into `/usr/bin/`, i.e., they should be the same directory.
1. Download and install Python for Windows (not from Cygwin) and put `python.exe` (not `python3.exe`) on your system path.
1. Download and install pip for your Windows Python (`python -m ensurepip`).
1. Download and install rust (compiler), npm, git and put them your system path.
1. Download and install the pyaudio wheel from: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio
1. After download the file for your Python version, you need to define the following environment
variable before running anki:
`set "ANKI_EXTRA_PIP=python -m pip install full/path/to/PyAudio0.2.11cp38cp38win_amd64.whl"`
1. If there is not an wheel available for your Python version, you can built it from the source
following the installation instructions on: https://github.com/evandroforks/pyaudio
After building and installing portaudio, you need to define the following environment
variable before running anki:
`set "ANKI_EXTRA_PIP=python -m pip install git+https://github.com/evandroforks/pyaudio"`
1. Open a `cmd.exe` (command prompt) on the anki repository and run the command `sh run`
1. Do not use `bash run` because it my call for Windows Subsystem for Linux
1. Do not use any Cygwin terminal as `mintty.exe` because the `rust lang` compiler does not work with them

View File

@ -1,4 +1,6 @@
SHELL := bash
SHELL := /bin/bash
FIND := $(if $(wildcard /bin/find),/bin/find,/usr/bin/find)
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
@ -14,11 +16,11 @@ PHONY: all
all: check
.build/run-deps: setup.py
pip install -e .
python -m pip install -e .
@touch $@
.build/dev-deps: requirements.dev
pip install -r requirements.dev
python -m pip install -r requirements.dev
@touch $@
PROTODEPS := $(wildcard ../proto/*.proto)
@ -54,7 +56,7 @@ clean:
# Checking python
######################
CHECKDEPS := $(shell find anki tests -name '*.py' | grep -v buildinfo.py)
CHECKDEPS := $(shell ${FIND} anki tests -name '*.py' | grep -v buildinfo.py)
.build/mypy: $(CHECKDEPS)
mypy anki

View File

@ -1,4 +1,6 @@
SHELL := bash
SHELL := /bin/bash
FIND := $(if $(wildcard /bin/find),/bin/find,/usr/bin/find)
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
@ -14,14 +16,14 @@ PHONY: all
all: check
.build/run-deps: setup.py
pip install -e .
python -m pip install -e .
@touch $@
.build/dev-deps: requirements.dev
pip install -r requirements.dev
python -m pip install -r requirements.dev
@touch $@
.build/ui: $(shell find designer -type f)
.build/ui: $(shell ${FIND} designer -type f)
./tools/build_ui.sh
@touch $@
@ -75,7 +77,7 @@ JSDEPS := $(patsubst ts/src/%.ts, web/%.js, $(TSDEPS))
PYLIB := ../pylib
CHECKDEPS := $(shell find aqt tests -name '*.py' | grep -v buildinfo.py)
CHECKDEPS := $(shell ${FIND} aqt tests -name '*.py' | grep -v buildinfo.py)
.build/mypy: $(CHECKDEPS) .build/qt-stubs
mypy aqt

View File

@ -3,7 +3,15 @@
set -eo pipefail
out=../aqt_data/locale/qt
mkdir -p $out
mkdir -p "$out"
qtTranslations=$(python -c "from PyQt5.QtCore import *; print(QLibraryInfo.location(QLibraryInfo.TranslationsPath))")
rsync -a $qtTranslations/qt* $out
qtTranslations="$(python -c "from PyQt5.QtCore import *; import sys; sys.stdout.write(QLibraryInfo.location(QLibraryInfo.TranslationsPath))")"
unameOut="$(uname -s)"
case "${unameOut}" in
CYGWIN*)
qtTranslations="$(cygpath -u "${qtTranslations}")"
;;
esac
rsync -a "$qtTranslations"/qt* "$out"

View File

@ -1,3 +1,5 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
import os
import json
import re

View File

@ -1,3 +1,5 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
import re
import json

View File

@ -3,7 +3,7 @@
"version": "1.0.0",
"description": "Anki desktop js support files",
"scripts": {
"build": "tsc --build; sass --no-source-map scss:../aqt_data/web",
"build": "tsc --build && sass --no-source-map scss:../aqt_data/web",
"pretty": "prettier --write src/*.ts",
"check-pretty": "prettier --check src/*.ts"
},

View File

@ -1,4 +1,5 @@
SHELL := bash
SHELL := /bin/bash
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables

View File

@ -1,4 +1,6 @@
SHELL := bash
SHELL := /bin/bash
FIND := $(if $(wildcard /bin/find),/bin/find,/usr/bin/find)
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
@ -23,7 +25,7 @@ develop: .build/vernum ftl/repo
ftl/repo:
(cd ftl && ./scripts/fetch-latest-translations)
ALL_SOURCE := $(shell find src -type f) $(wildcard ftl/*.ftl)
ALL_SOURCE := $(shell ${FIND} src -type f) $(wildcard ftl/*.ftl)
# nightly currently required for ignoring files in rustfmt.toml
RUST_TOOLCHAIN := $(shell cat rust-toolchain)

View File

@ -1,4 +1,6 @@
SHELL := bash
SHELL := /bin/bash
FIND := $(if $(wildcard /bin/find),/bin/find,/usr/bin/find)
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
@ -19,8 +21,8 @@ all: develop
develop: .build/develop
DEPS := .build/tools .build/vernum ../meta/buildhash $(wildcard $(QT_FTLS)/*.ftl) \
$(shell find ../rslib/src -name '*.rs') $(wildcard ../proto/*) \
$(shell find ../rslib/ftl -type f)
$(shell ${FIND} ../rslib/src -name '*.rs') $(wildcard ../proto/*) \
$(shell ${FIND} ../rslib/ftl -type f)
.build/develop: $(DEPS)
touch ../proto/backend.proto
@ -44,7 +46,7 @@ clean:
RUST_TOOLCHAIN := $(shell cat rust-toolchain)
.build/tools: requirements.txt rust-toolchain
pip install -r requirements.txt
python -m pip install -r requirements.txt
rustup toolchain install $(RUST_TOOLCHAIN)
rustup component add rustfmt-preview --toolchain $(RUST_TOOLCHAIN)
rustup component add clippy-preview --toolchain $(RUST_TOOLCHAIN)

1
run
View File

@ -1,3 +1,4 @@
#!/bin/bash
python --version
make -C $(dirname $0) run RUNFLAGS="$*"

View File

@ -1,4 +1,5 @@
SHELL := bash
SHELL := /bin/bash
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables

View File

@ -1,4 +1,5 @@
SHELL := bash
SHELL := /bin/bash
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables