From 19f1c98025e84364e6fd75ba2b5f0777b707ed18 Mon Sep 17 00:00:00 2001 From: evandrocoan Date: Mon, 24 Feb 2020 14:58:07 -0300 Subject: [PATCH 01/13] Fixed development compilation with Windows 10 1. Documented on README.development how to setup the environment for Windows. 2. Fixed qt/ts/package.json not working due usage of ; instead of && 3. Fixed copy-qt-files rsync using Windows paths instead of Unix ones 4. Fixed Makefile's using Windows Linux Subsystem bash instead of the Cygwin one. 5. Ensured running the correct pip module by using python -m pip instead of just pip. 6. Fixed Makefiles using Windows `find` command, instead of the Cygwin's one (POSIX find). 7. Fixed pyenv sourcing/activate using /pyevn/bin/ instead of /python/Scripts/ on Windows. 8. Fixed pyaudio not installing/linking with portaudio on Windows by installing for a patched fork at evandroforks/pyaudio 9. Forked and fixed portaudio not building with Visual Studio 2017 or superior and added the reference for the patched fork on README.development at evandroforks/portaudio. --- Makefile | 55 +++++++++++++++++++-------------- README.development | 22 +++++++++++++ pylib/Makefile | 11 ++++--- qt/Makefile | 20 +++++++++--- qt/i18n/copy-qt-files | 14 +++++++-- qt/tools/extract-po-string.py | 2 ++ qt/tools/extract_scss_colors.py | 2 ++ qt/ts/package.json | 2 +- react/Makefile | 4 ++- rslib/Makefile | 4 ++- rspy/Makefile | 6 ++-- run | 1 + svelte/Makefile | 4 ++- tslib/Makefile | 4 ++- 14 files changed, 109 insertions(+), 42 deletions(-) diff --git a/Makefile b/Makefile index a2d8a7d44..e2273071f 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,12 @@ -SHELL := bash +SHELL := /bin/bash +ECHOCMD := /bin/echo -e + +ifeq ($(OS),Windows_NT) + IS_WINDOWS := true +else + IS_WINDOWS := +endif + .SHELLFLAGS := -eu -o pipefail -c .DELETE_ON_ERROR: MAKEFLAGS += --warn-undefined-variables @@ -18,10 +26,11 @@ 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$(if ${IS_WINDOWS},,3) -m venv pyenv && \ + . pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \ + python --version && \ + python -m pip install --upgrade pip setuptools && \ + python -c 'import PyQt5' 2>/dev/null || python -m pip install -r qt/requirements.qt # update build hash .PHONY: buildhash @@ -34,42 +43,42 @@ buildhash: .PHONY: develop develop: pyenv buildhash - @set -e && \ - . pyenv/bin/activate && \ + set -e && \ + . pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \ for dir in $(DEVEL); do \ $(SUBMAKE) -C $$dir develop BUILDFLAGS="$(BUILDFLAGS)"; \ done .PHONY: run run: develop - @set -e && \ - . pyenv/bin/activate && \ + set -e && \ + . pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \ echo "Starting Anki..."; \ - qt/runanki $(RUNFLAGS) + python qt/runanki $(RUNFLAGS) .PHONY: build build: clean-dist build-rspy build-pylib build-qt add-buildhash - @echo - @echo "Build complete." + echo + echo "Build complete." .PHONY: build-rspy build-rspy: pyenv buildhash - @. pyenv/bin/activate && \ + . pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \ $(SUBMAKE) -C rspy build BUILDFLAGS="$(BUILDFLAGS)" .PHONY: build-pylib build-pylib: - @. pyenv/bin/activate && \ + . pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \ $(SUBMAKE) -C pylib build .PHONY: build-qt build-qt: - @. pyenv/bin/activate && \ + . pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \ $(SUBMAKE) -C qt build .PHONY: clean clean: clean-dist - @set -e && \ + set -e && \ for dir in $(DEVEL); do \ $(SUBMAKE) -C $$dir clean; \ done @@ -80,29 +89,29 @@ clean-dist: .PHONY: check check: pyenv buildhash - @set -e && \ + set -e && \ for dir in $(CHECKABLE_RS); do \ $(SUBMAKE) -C $$dir check; \ done; \ - . pyenv/bin/activate && \ + . pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \ $(SUBMAKE) -C rspy develop && \ $(SUBMAKE) -C pylib develop && \ for dir in $(CHECKABLE_PY); do \ $(SUBMAKE) -C $$dir check; \ done; - @echo - @echo "All checks passed!" + echo + echo "All checks passed!" .PHONY: fix fix: - @set -e && \ - . pyenv/bin/activate && \ + set -e && \ + . pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \ for dir in $(CHECKABLE_RS) $(CHECKABLE_PY); do \ $(SUBMAKE) -C $$dir fix; \ done; \ .PHONY: add-buildhash add-buildhash: - @ver=$$(cat meta/version); \ + ver=$$(cat meta/version); \ hash=$$(cat meta/buildhash); \ rename "s/-$${ver}-/-$${ver}+$${hash}-/" dist/*-$$ver-* diff --git a/README.development b/README.development index d420fe815..6d69a9c24 100644 --- a/README.development +++ b/README.development @@ -76,3 +76,25 @@ 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 +---------- + +1. Download and install Cygwin and put its `/bin/` directory on your system path. +1. Install the Cygwin Packages: `apt-cyg install gettext rsync make` + 1. Move these files to `/bin/` + 1. /usr/bin/msgfmt.exe + 1. /usr/bin/cyggettextsrc-0-19-8-1.dll + 1. /usr/bin/cyggettextlib-0-19-8-1.dll +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. +1. Download and install rust (compiler), npm, git and put them your system path. +1. Download and install Visual Studio 2017 or superior and: + 1. `git clone https://github.com/evandroforks/portaudio` + 1. Open the file `portaudio\build\msvc\portaudio.sln` with Visual Studio + 1. Select the Solution Configuration as `Release` and the Solution Platforms as `x64` on the top toolbar + 1. Go to the menu `Build -> Build Solution` + 1. Copy the file `portaudio\build\msvc\x64\Release\portaudio.lib` to `C:\Python\libs\` (Or whatever your Windows Python is installed) +1. Open a `cmd.exe` (command prompt) on the anki repository and run the command `sh run` + 1. Do not `bash run` because it my call for Windows Subsystem fo Linux + 1. Do not use any Cygwin terminal as `mintty.exe` because the `rust lang` compiler does not work with them diff --git a/pylib/Makefile b/pylib/Makefile index 34766523f..532b8d62c 100644 --- a/pylib/Makefile +++ b/pylib/Makefile @@ -1,4 +1,7 @@ -SHELL := bash +SHELL := /bin/bash +ECHOCMD := /bin/echo -e +FIND_EXEC := $(if $(wildcard /bin/find),,/usr)/bin/find + .SHELLFLAGS := -eu -o pipefail -c .DELETE_ON_ERROR: MAKEFLAGS += --warn-undefined-variables @@ -14,11 +17,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 +57,7 @@ clean: # Checking python ###################### -CHECKDEPS := $(shell find anki tests -name '*.py' | grep -v buildinfo.py) +CHECKDEPS := $(shell ${FIND_EXEC} anki tests -name '*.py' | grep -v buildinfo.py) .build/mypy: $(CHECKDEPS) mypy anki diff --git a/qt/Makefile b/qt/Makefile index 457d0012c..2cadfc1ca 100644 --- a/qt/Makefile +++ b/qt/Makefile @@ -1,4 +1,13 @@ -SHELL := bash +SHELL := /bin/bash +ECHOCMD := /bin/echo -e +FIND_EXEC := $(if $(wildcard /bin/find),,/usr)/bin/find + +ifeq ($(OS),Windows_NT) + IS_WINDOWS := true +else + IS_WINDOWS := +endif + .SHELLFLAGS := -eu -o pipefail -c .DELETE_ON_ERROR: MAKEFLAGS += --warn-undefined-variables @@ -14,14 +23,15 @@ PHONY: all all: check .build/run-deps: setup.py - pip install -e . + $(if ${IS_WINDOWS},python -m pip install git+https://github.com/evandroforks/pyaudio,) + 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_EXEC} designer -type f) ./tools/build_ui.sh @touch $@ @@ -73,7 +83,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_EXEC} aqt tests -name '*.py' | grep -v buildinfo.py) .build/mypy: $(CHECKDEPS) .build/qt-stubs mypy aqt diff --git a/qt/i18n/copy-qt-files b/qt/i18n/copy-qt-files index fe6210b18..7905cc848 100755 --- a/qt/i18n/copy-qt-files +++ b/qt/i18n/copy-qt-files @@ -3,7 +3,15 @@ set -e 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" diff --git a/qt/tools/extract-po-string.py b/qt/tools/extract-po-string.py index 472537567..d467ba014 100644 --- a/qt/tools/extract-po-string.py +++ b/qt/tools/extract-po-string.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 +# -*- coding: UTF-8 -*- import os import json import re diff --git a/qt/tools/extract_scss_colors.py b/qt/tools/extract_scss_colors.py index 6202689f3..7928b7027 100644 --- a/qt/tools/extract_scss_colors.py +++ b/qt/tools/extract_scss_colors.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 +# -*- coding: UTF-8 -*- import re import json diff --git a/qt/ts/package.json b/qt/ts/package.json index 985d48d41..f0c29ab8d 100644 --- a/qt/ts/package.json +++ b/qt/ts/package.json @@ -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" }, diff --git a/react/Makefile b/react/Makefile index 60dac2cf0..f955c3cb5 100644 --- a/react/Makefile +++ b/react/Makefile @@ -1,4 +1,6 @@ -SHELL := bash +SHELL := /bin/bash +ECHOCMD := /bin/echo -e + .SHELLFLAGS := -eu -o pipefail -c .DELETE_ON_ERROR: MAKEFLAGS += --warn-undefined-variables diff --git a/rslib/Makefile b/rslib/Makefile index af629a269..4e322e392 100644 --- a/rslib/Makefile +++ b/rslib/Makefile @@ -1,4 +1,6 @@ -SHELL := bash +SHELL := /bin/bash +ECHOCMD := /bin/echo -e + .SHELLFLAGS := -eu -o pipefail -c .DELETE_ON_ERROR: MAKEFLAGS += --warn-undefined-variables diff --git a/rspy/Makefile b/rspy/Makefile index fee123722..7c9ed30ea 100644 --- a/rspy/Makefile +++ b/rspy/Makefile @@ -1,4 +1,6 @@ -SHELL := bash +SHELL := /bin/bash +ECHOCMD := /bin/echo -e + .SHELLFLAGS := -eu -o pipefail -c .DELETE_ON_ERROR: MAKEFLAGS += --warn-undefined-variables @@ -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) diff --git a/run b/run index 9bbd8e2d1..7e984857d 100755 --- a/run +++ b/run @@ -1,3 +1,4 @@ #!/bin/bash +python --version make -C $(dirname $0) run RUNFLAGS="$*" diff --git a/svelte/Makefile b/svelte/Makefile index 52b217b26..7b058bc50 100644 --- a/svelte/Makefile +++ b/svelte/Makefile @@ -1,4 +1,6 @@ -SHELL := bash +SHELL := /bin/bash +ECHOCMD := /bin/echo -e + .SHELLFLAGS := -eu -o pipefail -c .DELETE_ON_ERROR: MAKEFLAGS += --warn-undefined-variables diff --git a/tslib/Makefile b/tslib/Makefile index a8668acf8..c11b6e0e5 100644 --- a/tslib/Makefile +++ b/tslib/Makefile @@ -1,4 +1,6 @@ -SHELL := bash +SHELL := /bin/bash +ECHOCMD := /bin/echo -e + .SHELLFLAGS := -eu -o pipefail -c .DELETE_ON_ERROR: MAKEFLAGS += --warn-undefined-variables From ebe35c0a15e2494f16378ca8386a91e970f3b9be Mon Sep 17 00:00:00 2001 From: evandrocoan Date: Mon, 24 Feb 2020 15:05:13 -0300 Subject: [PATCH 02/13] Added myself into CONTRIBUTORS --- CONTRIBUTORS | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index e1a5518c4..5bc4a5047 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -26,6 +26,7 @@ Arthur Milchior Yngve Hoiseth Ijgnd Yoonchae Lee +Evandro Coan ******************** From bca96de75c83037092c5bfcd73708cb6c66af565 Mon Sep 17 00:00:00 2001 From: evandrocoan Date: Mon, 24 Feb 2020 15:32:31 -0300 Subject: [PATCH 03/13] Fixed misspelling on README.development and added missing FIND_EXEC to rspy/Makefile --- README.development | 2 +- rspy/Makefile | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.development b/README.development index 6d69a9c24..1c5b06b67 100644 --- a/README.development +++ b/README.development @@ -96,5 +96,5 @@ Windows users 1. Go to the menu `Build -> Build Solution` 1. Copy the file `portaudio\build\msvc\x64\Release\portaudio.lib` to `C:\Python\libs\` (Or whatever your Windows Python is installed) 1. Open a `cmd.exe` (command prompt) on the anki repository and run the command `sh run` - 1. Do not `bash run` because it my call for Windows Subsystem fo Linux + 1. Do not use `bash run` because it my call for Windows Subsystem fo Linux 1. Do not use any Cygwin terminal as `mintty.exe` because the `rust lang` compiler does not work with them diff --git a/rspy/Makefile b/rspy/Makefile index 7c9ed30ea..7af93253f 100644 --- a/rspy/Makefile +++ b/rspy/Makefile @@ -1,5 +1,6 @@ SHELL := /bin/bash ECHOCMD := /bin/echo -e +FIND_EXEC := $(if $(wildcard /bin/find),,/usr)/bin/find .SHELLFLAGS := -eu -o pipefail -c .DELETE_ON_ERROR: @@ -21,8 +22,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_EXEC} ../rslib/src -name '*.rs') $(wildcard ../proto/*) \ + $(shell ${FIND_EXEC} ../rslib/ftl -type f) .build/develop: $(DEPS) touch ../proto/backend.proto From 7638c99a820fd9c157ebdfc0d9a01b4801dbfa66 Mon Sep 17 00:00:00 2001 From: evandrocoan Date: Mon, 24 Feb 2020 17:54:39 -0300 Subject: [PATCH 04/13] Updated README.development to use gettext version 0.20.1 --- README.development | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/README.development b/README.development index 1c5b06b67..89d1d8495 100644 --- a/README.development +++ b/README.development @@ -81,11 +81,10 @@ Windows users ---------- 1. Download and install Cygwin and put its `/bin/` directory on your system path. -1. Install the Cygwin Packages: `apt-cyg install gettext rsync make` - 1. Move these files to `/bin/` - 1. /usr/bin/msgfmt.exe - 1. /usr/bin/cyggettextsrc-0-19-8-1.dll - 1. /usr/bin/cyggettextlib-0-19-8-1.dll +1. Install the Cygwin Packages: `apt-cyg install rsync make` + 1. If the Cygwin `/usr/bin/` directory exists, move all files from `/usr/bin/` to `/bin/`. + 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. 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. 1. Download and install rust (compiler), npm, git and put them your system path. From afeab0e55934149a771cb140525dd24246b4c803 Mon Sep 17 00:00:00 2001 From: evandrocoan Date: Mon, 24 Feb 2020 20:38:38 -0300 Subject: [PATCH 05/13] Fixed misspelled word on README.development --- README.development | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.development b/README.development index 89d1d8495..bbfacdd7e 100644 --- a/README.development +++ b/README.development @@ -77,7 +77,7 @@ $ brew install python mpv lame portaudio protobuf npm rustup-init gettext rename $ brew link gettext --force -Windows users +Windows users (using Visual Studio) ---------- 1. Download and install Cygwin and put its `/bin/` directory on your system path. @@ -95,5 +95,5 @@ Windows users 1. Go to the menu `Build -> Build Solution` 1. Copy the file `portaudio\build\msvc\x64\Release\portaudio.lib` to `C:\Python\libs\` (Or whatever your Windows Python is installed) 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 fo Linux + 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 From 0f87955a2968ad6737ea12920bae29b3e1b85483 Mon Sep 17 00:00:00 2001 From: evandrocoan Date: Mon, 24 Feb 2020 21:36:14 -0300 Subject: [PATCH 06/13] Fixed rslib/Makefile using find from Windows, instead from POSIX --- rslib/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rslib/Makefile b/rslib/Makefile index 4e322e392..4c09cada8 100644 --- a/rslib/Makefile +++ b/rslib/Makefile @@ -1,5 +1,6 @@ SHELL := /bin/bash ECHOCMD := /bin/echo -e +FIND_EXEC := $(if $(wildcard /bin/find),,/usr)/bin/find .SHELLFLAGS := -eu -o pipefail -c .DELETE_ON_ERROR: @@ -25,7 +26,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_EXEC} src -type f) $(wildcard ftl/*.ftl) # nightly currently required for ignoring files in rustfmt.toml RUST_TOOLCHAIN := $(shell cat rust-toolchain) From 26cdff29ec1979ced29dd17d0b80326de90eab22 Mon Sep 17 00:00:00 2001 From: evandrocoan Date: Tue, 25 Feb 2020 02:32:17 -0300 Subject: [PATCH 07/13] Renamed FIND_EXEC to FIND, replaced IS_WINDOWS by specific commands as PYTHON_BIN, ACTIVE_SCRIPT and INSTALL_PYAUDIO. Fixed echo statements not using @ to suppress double message output. Deprecated the usage of ECHOCMD := /bin/echo -e because it has no effect: https://stackoverflow.com/questions/60387684/how-to-make-the-makefile-echos-to-use-bin-echo-e # Conflicts: # Makefile --- Makefile | 39 ++++++++++++++++++++------------------- README.development | 4 +++- pylib/Makefile | 5 ++--- qt/Makefile | 13 ++++++------- react/Makefile | 1 - rslib/Makefile | 5 ++--- rspy/Makefile | 7 +++---- 7 files changed, 36 insertions(+), 38 deletions(-) diff --git a/Makefile b/Makefile index e2273071f..2dd4d4bf9 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,11 @@ SHELL := /bin/bash -ECHOCMD := /bin/echo -e ifeq ($(OS),Windows_NT) - IS_WINDOWS := true + PYTHON_BIN := python + ACTIVATE_SCRIPT := pyenv/Scripts/activate else - IS_WINDOWS := + PYTHON_BIN := python3 + ACTIVATE_SCRIPT := pyenv/bin/activate endif .SHELLFLAGS := -eu -o pipefail -c @@ -26,8 +27,8 @@ all: run # - modern pip required for wheel # - add qt if missing pyenv: - python$(if ${IS_WINDOWS},,3) -m venv pyenv && \ - . pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \ + "${PYTHON_BIN}" -m venv pyenv && \ + . "${ACTIVATE_SCRIPT}" && \ python --version && \ python -m pip install --upgrade pip setuptools && \ python -c 'import PyQt5' 2>/dev/null || python -m pip install -r qt/requirements.qt @@ -43,37 +44,37 @@ buildhash: .PHONY: develop develop: pyenv buildhash - set -e && \ - . pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \ + set -eo pipefail && \ + . "${ACTIVATE_SCRIPT}" && \ for dir in $(DEVEL); do \ $(SUBMAKE) -C $$dir develop BUILDFLAGS="$(BUILDFLAGS)"; \ done .PHONY: run run: develop - set -e && \ - . pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \ + set -eo pipefail && \ + . "${ACTIVATE_SCRIPT}" && \ echo "Starting Anki..."; \ python qt/runanki $(RUNFLAGS) .PHONY: build build: clean-dist build-rspy build-pylib build-qt add-buildhash - echo - echo "Build complete." + @echo + @echo "Build complete." .PHONY: build-rspy build-rspy: pyenv buildhash - . pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \ + . "${ACTIVATE_SCRIPT}" && \ $(SUBMAKE) -C rspy build BUILDFLAGS="$(BUILDFLAGS)" .PHONY: build-pylib build-pylib: - . pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \ + . "${ACTIVATE_SCRIPT}" && \ $(SUBMAKE) -C pylib build .PHONY: build-qt build-qt: - . pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \ + . "${ACTIVATE_SCRIPT}" && \ $(SUBMAKE) -C qt build .PHONY: clean @@ -93,19 +94,19 @@ check: pyenv buildhash for dir in $(CHECKABLE_RS); do \ $(SUBMAKE) -C $$dir check; \ done; \ - . pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \ + . "${ACTIVATE_SCRIPT}" && \ $(SUBMAKE) -C rspy develop && \ $(SUBMAKE) -C pylib develop && \ for dir in $(CHECKABLE_PY); do \ $(SUBMAKE) -C $$dir check; \ done; - echo - echo "All checks passed!" + @echo + @echo "All checks passed!" .PHONY: fix fix: - set -e && \ - . pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \ + set -eo pipefail && \ + . "${ACTIVATE_SCRIPT}" && \ for dir in $(CHECKABLE_RS) $(CHECKABLE_PY); do \ $(SUBMAKE) -C $$dir fix; \ done; \ diff --git a/README.development b/README.development index bbfacdd7e..fc45458e6 100644 --- a/README.development +++ b/README.development @@ -82,9 +82,11 @@ 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. If the Cygwin `/usr/bin/` directory exists, move all files from `/usr/bin/` to `/bin/`. 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. 1. Download and install rust (compiler), npm, git and put them your system path. diff --git a/pylib/Makefile b/pylib/Makefile index 532b8d62c..c78af5bf4 100644 --- a/pylib/Makefile +++ b/pylib/Makefile @@ -1,6 +1,5 @@ SHELL := /bin/bash -ECHOCMD := /bin/echo -e -FIND_EXEC := $(if $(wildcard /bin/find),,/usr)/bin/find +FIND := $(if $(wildcard /bin/find),/bin/find,/usr/bin/find) .SHELLFLAGS := -eu -o pipefail -c .DELETE_ON_ERROR: @@ -57,7 +56,7 @@ clean: # Checking python ###################### -CHECKDEPS := $(shell ${FIND_EXEC} anki tests -name '*.py' | grep -v buildinfo.py) +CHECKDEPS := $(shell ${FIND} anki tests -name '*.py' | grep -v buildinfo.py) .build/mypy: $(CHECKDEPS) mypy anki diff --git a/qt/Makefile b/qt/Makefile index 2cadfc1ca..bca95a466 100644 --- a/qt/Makefile +++ b/qt/Makefile @@ -1,11 +1,10 @@ SHELL := /bin/bash -ECHOCMD := /bin/echo -e -FIND_EXEC := $(if $(wildcard /bin/find),,/usr)/bin/find +FIND := $(if $(wildcard /bin/find),/bin/find,/usr/bin/find) ifeq ($(OS),Windows_NT) - IS_WINDOWS := true + INSTALL_PYAUDIO := python -m pip install git+https://github.com/evandroforks/pyaudio else - IS_WINDOWS := + INSTALL_PYAUDIO := @echo Skipping pyaudio for Windows... endif .SHELLFLAGS := -eu -o pipefail -c @@ -23,7 +22,7 @@ PHONY: all all: check .build/run-deps: setup.py - $(if ${IS_WINDOWS},python -m pip install git+https://github.com/evandroforks/pyaudio,) + ${INSTALL_PYAUDIO} python -m pip install -e . @touch $@ @@ -31,7 +30,7 @@ all: check python -m pip install -r requirements.dev @touch $@ -.build/ui: $(shell ${FIND_EXEC} designer -type f) +.build/ui: $(shell ${FIND} designer -type f) ./tools/build_ui.sh @touch $@ @@ -83,7 +82,7 @@ JSDEPS := $(patsubst ts/src/%.ts, web/%.js, $(TSDEPS)) PYLIB := ../pylib -CHECKDEPS := $(shell ${FIND_EXEC} 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 diff --git a/react/Makefile b/react/Makefile index f955c3cb5..d39a2cf90 100644 --- a/react/Makefile +++ b/react/Makefile @@ -1,5 +1,4 @@ SHELL := /bin/bash -ECHOCMD := /bin/echo -e .SHELLFLAGS := -eu -o pipefail -c .DELETE_ON_ERROR: diff --git a/rslib/Makefile b/rslib/Makefile index 4c09cada8..58cbadfbe 100644 --- a/rslib/Makefile +++ b/rslib/Makefile @@ -1,6 +1,5 @@ SHELL := /bin/bash -ECHOCMD := /bin/echo -e -FIND_EXEC := $(if $(wildcard /bin/find),,/usr)/bin/find +FIND := $(if $(wildcard /bin/find),/bin/find,/usr/bin/find) .SHELLFLAGS := -eu -o pipefail -c .DELETE_ON_ERROR: @@ -26,7 +25,7 @@ develop: .build/vernum ftl/repo ftl/repo: (cd ftl && ./scripts/fetch-latest-translations) -ALL_SOURCE := $(shell ${FIND_EXEC} 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) diff --git a/rspy/Makefile b/rspy/Makefile index 7af93253f..787857e90 100644 --- a/rspy/Makefile +++ b/rspy/Makefile @@ -1,6 +1,5 @@ SHELL := /bin/bash -ECHOCMD := /bin/echo -e -FIND_EXEC := $(if $(wildcard /bin/find),,/usr)/bin/find +FIND := $(if $(wildcard /bin/find),/bin/find,/usr/bin/find) .SHELLFLAGS := -eu -o pipefail -c .DELETE_ON_ERROR: @@ -22,8 +21,8 @@ all: develop develop: .build/develop DEPS := .build/tools .build/vernum ../meta/buildhash $(wildcard $(QT_FTLS)/*.ftl) \ - $(shell ${FIND_EXEC} ../rslib/src -name '*.rs') $(wildcard ../proto/*) \ - $(shell ${FIND_EXEC} ../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 From 4b5463becf5281df3c0f3fac97dd603d2aceb164 Mon Sep 17 00:00:00 2001 From: evandrocoan Date: Tue, 25 Feb 2020 03:26:40 -0300 Subject: [PATCH 08/13] Added instructions to first try to download prebuilt pyaudio wheels on README.development --- README.development | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.development b/README.development index fc45458e6..7b8de83b3 100644 --- a/README.development +++ b/README.development @@ -90,7 +90,9 @@ Windows users (using Visual Studio) 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. 1. Download and install rust (compiler), npm, git and put them your system path. -1. Download and install Visual Studio 2017 or superior and: +1. Download and install the pyaudio wheel from: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio + If that wheel do not work for you, you can download and build them from their source with the following steps: + 1. Download and install Visual Studio 2017 or superior and: 1. `git clone https://github.com/evandroforks/portaudio` 1. Open the file `portaudio\build\msvc\portaudio.sln` with Visual Studio 1. Select the Solution Configuration as `Release` and the Solution Platforms as `x64` on the top toolbar From 14a86273c40e798adf05fd635145a42668ca31e7 Mon Sep 17 00:00:00 2001 From: evandrocoan Date: Tue, 25 Feb 2020 17:11:46 -0300 Subject: [PATCH 09/13] Deprecated SHELLCMD, moved the pyaudio installation instructions to its repository updating the instruction on README.development --- README.development | 11 +++-------- svelte/Makefile | 1 - tslib/Makefile | 1 - 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/README.development b/README.development index 7b8de83b3..58291e9b3 100644 --- a/README.development +++ b/README.development @@ -90,14 +90,9 @@ Windows users (using Visual Studio) 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. 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 - If that wheel do not work for you, you can download and build them from their source with the following steps: - 1. Download and install Visual Studio 2017 or superior and: - 1. `git clone https://github.com/evandroforks/portaudio` - 1. Open the file `portaudio\build\msvc\portaudio.sln` with Visual Studio - 1. Select the Solution Configuration as `Release` and the Solution Platforms as `x64` on the top toolbar - 1. Go to the menu `Build -> Build Solution` - 1. Copy the file `portaudio\build\msvc\x64\Release\portaudio.lib` to `C:\Python\libs\` (Or whatever your Windows Python is installed) 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 + 1. If got an error from pip trying to build the `pyaudio` library, + follow the installation instructions from: https://github.com/evandroforks/pyaudio + and install the `portaudio.lib` on your system. diff --git a/svelte/Makefile b/svelte/Makefile index 7b058bc50..db41f4270 100644 --- a/svelte/Makefile +++ b/svelte/Makefile @@ -1,5 +1,4 @@ SHELL := /bin/bash -ECHOCMD := /bin/echo -e .SHELLFLAGS := -eu -o pipefail -c .DELETE_ON_ERROR: diff --git a/tslib/Makefile b/tslib/Makefile index c11b6e0e5..030d5ffe5 100644 --- a/tslib/Makefile +++ b/tslib/Makefile @@ -1,5 +1,4 @@ SHELL := /bin/bash -ECHOCMD := /bin/echo -e .SHELLFLAGS := -eu -o pipefail -c .DELETE_ON_ERROR: From d88e5eb30800d125516ffac82f00ac286b7da66b Mon Sep 17 00:00:00 2001 From: evandrocoan Date: Tue, 25 Feb 2020 20:46:54 -0300 Subject: [PATCH 10/13] Removed the qt/Makefile INSTALL_PYAUDIO variable and created the Makefile SYSTEM_PACKAGES updating README.development --- Makefile | 3 +++ README.development | 11 +++++++---- qt/Makefile | 7 ------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 43b9615ce..55a697300 100644 --- a/Makefile +++ b/Makefile @@ -3,9 +3,11 @@ SHELL := /bin/bash ifeq ($(OS),Windows_NT) PYTHON_BIN := python ACTIVATE_SCRIPT := pyenv/Scripts/activate + SYSTEM_PACKAGES := sed -iv -- "s/include-system-site-packages\s*=\s*false/include-system-site-packages = true/g" pyenv/pyvenv.cfg else PYTHON_BIN := python3 ACTIVATE_SCRIPT := pyenv/bin/activate + SYSTEM_PACKAGES := echo Skipping Windows Pythons system packages inheritance activation... endif .SHELLFLAGS := -eu -o pipefail -c @@ -28,6 +30,7 @@ all: run # - add qt if missing pyenv: "${PYTHON_BIN}" -m venv pyenv && \ + ${SYSTEM_PACKAGES} && \ . "${ACTIVATE_SCRIPT}" && \ python --version && \ python -m pip install --upgrade pip setuptools && \ diff --git a/README.development b/README.development index 58291e9b3..6db22b641 100644 --- a/README.development +++ b/README.development @@ -88,11 +88,14 @@ Windows users (using Visual Studio) 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. +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 can install it using a command like + `python -m pip install PyAudio‑0.2.11‑cp38‑cp38‑win_amd64.whl` + 1. If got an error from pip trying to build the `pyaudio` library, + or there is not a wheel available for your Python version, you can built it from the source + following the installation instructions on: 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 - 1. If got an error from pip trying to build the `pyaudio` library, - follow the installation instructions from: https://github.com/evandroforks/pyaudio - and install the `portaudio.lib` on your system. diff --git a/qt/Makefile b/qt/Makefile index bca95a466..4fb91701d 100644 --- a/qt/Makefile +++ b/qt/Makefile @@ -1,12 +1,6 @@ SHELL := /bin/bash FIND := $(if $(wildcard /bin/find),/bin/find,/usr/bin/find) -ifeq ($(OS),Windows_NT) - INSTALL_PYAUDIO := python -m pip install git+https://github.com/evandroforks/pyaudio -else - INSTALL_PYAUDIO := @echo Skipping pyaudio for Windows... -endif - .SHELLFLAGS := -eu -o pipefail -c .DELETE_ON_ERROR: MAKEFLAGS += --warn-undefined-variables @@ -22,7 +16,6 @@ PHONY: all all: check .build/run-deps: setup.py - ${INSTALL_PYAUDIO} python -m pip install -e . @touch $@ From ddb1788c22023c83948c9e907a184fea47fde4b4 Mon Sep 17 00:00:00 2001 From: evandrocoan Date: Tue, 25 Feb 2020 23:34:09 -0300 Subject: [PATCH 11/13] Reverted back to use pyenv (without using system wide packages) --- Makefile | 4 +--- README.development | 11 +++++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 55a697300..2815e9ad7 100644 --- a/Makefile +++ b/Makefile @@ -3,11 +3,9 @@ SHELL := /bin/bash ifeq ($(OS),Windows_NT) PYTHON_BIN := python ACTIVATE_SCRIPT := pyenv/Scripts/activate - SYSTEM_PACKAGES := sed -iv -- "s/include-system-site-packages\s*=\s*false/include-system-site-packages = true/g" pyenv/pyvenv.cfg else PYTHON_BIN := python3 ACTIVATE_SCRIPT := pyenv/bin/activate - SYSTEM_PACKAGES := echo Skipping Windows Pythons system packages inheritance activation... endif .SHELLFLAGS := -eu -o pipefail -c @@ -30,10 +28,10 @@ all: run # - add qt if missing pyenv: "${PYTHON_BIN}" -m venv pyenv && \ - ${SYSTEM_PACKAGES} && \ . "${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 diff --git a/README.development b/README.development index 6db22b641..bcc00b127 100644 --- a/README.development +++ b/README.development @@ -91,11 +91,14 @@ Windows users (using Visual Studio) 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 can install it using a command like - `python -m pip install PyAudio‑0.2.11‑cp38‑cp38‑win_amd64.whl` - 1. If got an error from pip trying to build the `pyaudio` library, - or there is not a wheel available for your Python version, you can built it from the source + 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/PyAudio‑0.2.11‑cp38‑cp38‑win_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 From f206940d5c01f273e374e2e1ffac3c0888032863 Mon Sep 17 00:00:00 2001 From: evandrocoan Date: Thu, 27 Feb 2020 00:22:08 -0300 Subject: [PATCH 12/13] Added back missing Makefile @ silencers --- Makefile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index be2132fea..50e51c844 100644 --- a/Makefile +++ b/Makefile @@ -45,7 +45,7 @@ buildhash: .PHONY: develop develop: pyenv buildhash prepare - set -eo pipefail && \ + @set -eo pipefail && \ . "${ACTIVATE_SCRIPT}" && \ for dir in $(DEVEL); do \ $(SUBMAKE) -C $$dir develop BUILDFLAGS="$(BUILDFLAGS)"; \ @@ -53,7 +53,7 @@ develop: pyenv buildhash prepare .PHONY: run run: develop - set -eo pipefail && \ + @set -eo pipefail && \ . "${ACTIVATE_SCRIPT}" && \ echo "Starting Anki..."; \ python qt/runanki $(RUNFLAGS) @@ -75,22 +75,22 @@ build: clean-dist build-rspy build-pylib build-qt add-buildhash .PHONY: build-rspy build-rspy: pyenv buildhash - . "${ACTIVATE_SCRIPT}" && \ + @. "${ACTIVATE_SCRIPT}" && \ $(SUBMAKE) -C rspy build BUILDFLAGS="$(BUILDFLAGS)" .PHONY: build-pylib build-pylib: - . "${ACTIVATE_SCRIPT}" && \ + @. "${ACTIVATE_SCRIPT}" && \ $(SUBMAKE) -C pylib build .PHONY: build-qt build-qt: - . "${ACTIVATE_SCRIPT}" && \ + @. "${ACTIVATE_SCRIPT}" && \ $(SUBMAKE) -C qt build .PHONY: clean clean: clean-dist - set -eo pipefail && \ + @set -eo pipefail && \ for dir in $(DEVEL); do \ $(SUBMAKE) -C $$dir clean; \ done @@ -101,7 +101,7 @@ clean-dist: .PHONY: check check: pyenv buildhash - set -eo pipefail && \ + @set -eo pipefail && \ for dir in $(CHECKABLE_RS); do \ $(SUBMAKE) -C $$dir check; \ done; \ @@ -116,7 +116,7 @@ check: pyenv buildhash .PHONY: fix fix: - set -eo pipefail && \ + @set -eo pipefail && \ . "${ACTIVATE_SCRIPT}" && \ for dir in $(CHECKABLE_RS) $(CHECKABLE_PY); do \ $(SUBMAKE) -C $$dir fix; \ From faaab30809b71c09fec45c8ebfa5f433eccdd6ed Mon Sep 17 00:00:00 2001 From: evandrocoan Date: Thu, 27 Feb 2020 00:42:49 -0300 Subject: [PATCH 13/13] Fixed syntax error near unexpected token `&&' due ANKI_EXTRA_PIP variable being undefined and added the last missing @ silencer on the Makefile. --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 50e51c844..e0d614d69 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,10 @@ else 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 @@ -124,7 +128,7 @@ fix: .PHONY: add-buildhash add-buildhash: - ver=$$(cat meta/version); \ + @ver=$$(cat meta/version); \ hash=$$(cat meta/buildhash); \ rename "s/-$${ver}-/-$${ver}+$${hash}-/" dist/*-$$ver-*