diff --git a/CONTRIBUTORS b/CONTRIBUTORS index ee5253fd3..6c59e4b8e 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -26,6 +26,7 @@ Arthur Milchior Yngve Hoiseth Ijgnd Yoonchae Lee +Evandro Coan Alan Du ******************** diff --git a/Makefile b/Makefile index 60448e2de..e0d614d69 100644 --- a/Makefile +++ b/Makefile @@ -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; \ diff --git a/README.development b/README.development index d420fe815..bcc00b127 100644 --- a/README.development +++ b/README.development @@ -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/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 diff --git a/pylib/Makefile b/pylib/Makefile index 34766523f..c78af5bf4 100644 --- a/pylib/Makefile +++ b/pylib/Makefile @@ -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 diff --git a/qt/Makefile b/qt/Makefile index 85a8db955..0f95ceed8 100644 --- a/qt/Makefile +++ b/qt/Makefile @@ -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 diff --git a/qt/po/scripts/copy-qt-files b/qt/po/scripts/copy-qt-files index 6955bc4ea..0a8a7eb25 100755 --- a/qt/po/scripts/copy-qt-files +++ b/qt/po/scripts/copy-qt-files @@ -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" diff --git a/qt/po/scripts/extract-po-string.py b/qt/po/scripts/extract-po-string.py index 472537567..d467ba014 100644 --- a/qt/po/scripts/extract-po-string.py +++ b/qt/po/scripts/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..d39a2cf90 100644 --- a/react/Makefile +++ b/react/Makefile @@ -1,4 +1,5 @@ -SHELL := bash +SHELL := /bin/bash + .SHELLFLAGS := -eu -o pipefail -c .DELETE_ON_ERROR: MAKEFLAGS += --warn-undefined-variables diff --git a/rslib/Makefile b/rslib/Makefile index af629a269..58cbadfbe 100644 --- a/rslib/Makefile +++ b/rslib/Makefile @@ -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) diff --git a/rspy/Makefile b/rspy/Makefile index fee123722..787857e90 100644 --- a/rspy/Makefile +++ b/rspy/Makefile @@ -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) 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..db41f4270 100644 --- a/svelte/Makefile +++ b/svelte/Makefile @@ -1,4 +1,5 @@ -SHELL := bash +SHELL := /bin/bash + .SHELLFLAGS := -eu -o pipefail -c .DELETE_ON_ERROR: MAKEFLAGS += --warn-undefined-variables diff --git a/tslib/Makefile b/tslib/Makefile index a8668acf8..030d5ffe5 100644 --- a/tslib/Makefile +++ b/tslib/Makefile @@ -1,4 +1,5 @@ -SHELL := bash +SHELL := /bin/bash + .SHELLFLAGS := -eu -o pipefail -c .DELETE_ON_ERROR: MAKEFLAGS += --warn-undefined-variables