Browse Source

Copy executable and create virtualenv in $prefix/share/napiman

Michał Góral 3 years ago
parent
commit
320b849de4
5 changed files with 23 additions and 17 deletions
  1. 4
    5
      Makefile
  2. 6
    1
      README.md
  3. 2
    2
      config.mk
  4. 2
    2
      napiman-start.in
  5. 9
    7
      tools/gen-in

+ 4
- 5
Makefile View File

@@ -21,10 +21,10 @@ ZIP_EXCLUDE_FLAGS=$(foreach e, $(ZIP_EXCLUDES), -x $e)
21 21
 PYTHON_SOURCES=$(shell find $(SRC_DIR) -type f -name '*.py') \
22 22
 			   __main__.py
23 23
 
24
-# DO NOT CHANGE IT or it may break napiman-start.in
25
-VENV_DIR = .venv
24
+INSTALL_PATH=$(DESTDIR)$(prefix)
25
+VENV_DIR = $(INSTALL_PATH)/share/napiman/venv
26 26
 
27
-INSTALL_PATH=$(DESTDIR)$(PREFIX)
27
+GEN = NAPIMAN_VENV_DIR=$(VENV_DIR) tools/gen-in
28 28
 
29 29
 .PHONY: all
30 30
 all: $(EXEC_PATH)
@@ -38,12 +38,11 @@ install: all bootstrap napiman-start
38 38
 .PHONY: uninstall
39 39
 uninstall:
40 40
 	$(RM) "$(INSTALL_PATH)/bin/$(EXECUTABLE)"
41
-	$(RM) "$(VENV_DIR)/bin/$(EXECUTABLE)"
41
+	$(RM) -rf "$(INSTALL_PATH)/share/napiman"
42 42
 
43 43
 .PHONY: clean
44 44
 clean:
45 45
 	$(RM) -r "$(BUILD_DIR)"
46
-	$(RM) -r "$(VENV_DIR)"
47 46
 	$(RM) "$(GEN_FILES)"
48 47
 
49 48
 .PHONY: bootstrap

+ 6
- 1
README.md View File

@@ -17,13 +17,18 @@ searches and downloads. To learn more about them, type `napiman -h`.
17 17
 Installation is quite simple: just type `make install`. If you wish to install
18 18
 in a different prefix than the default one (`$HOME/.local`), you can edit a
19 19
 `config.mk` file. NapiMan also respects `$DESTDIR` environment variable, so the
20
-full installation path is in fact `${DESTDIR}${PREFIX}`.
20
+full installation path is in fact `${DESTDIR}${prefix}`. You can also set
21
+prefix when calling make: `make install prefix=/usr`.
21 22
 
22 23
 When installing, NapiMan will create a [virtualenv][venv] and download all its
23 24
 dependencies so you are required to only have a virtualenv installed and
24 25
 accessible in your `$PATH`. NapiMan dependencies are listed in
25 26
 [requirements.txt][reqs].
26 27
 
28
+If your system has all dependencies installed (or you simply don't want create a
29
+virtualenv), just call `make` and grab the executable from a `build` directory.
30
+You can call it directly.
31
+
27 32
 # Legal issues
28 33
 
29 34
 This program is licensed under GPLv3 or (at your opinion) any later version of

+ 2
- 2
config.mk View File

@@ -4,7 +4,8 @@ EXECUTABLE=napiman
4 4
 ## Paths
5 5
 ##
6 6
 
7
-PREFIX=${HOME}/.local
7
+# Lower case on purpose so user can type a standard `make install prefix=/usr`
8
+prefix = ${HOME}/.local
8 9
 
9 10
 ####################################################################################################
10 11
 ## Important commands
@@ -14,7 +15,6 @@ CD = cd
14 15
 RM = rm -f
15 16
 MKDIR = mkdir -p
16 17
 INSTALL ?= install
17
-GEN = tools/gen-in
18 18
 VIRTUALENV = virtualenv
19 19
 
20 20
 ####################################################################################################

+ 2
- 2
napiman-start.in View File

@@ -1,3 +1,3 @@
1
-#!/bin/bash
1
+#!/bin/sh
2 2
 
3
-source "@NAPIMAN_DIR@/.venv/bin/activate" && napiman "$@"
3
+. "@VENV_DIR@/bin/activate" && napiman "$@"

+ 9
- 7
tools/gen-in View File

@@ -6,12 +6,14 @@ if [[ $# -ne 1 ]]; then
6 6
     exit 1
7 7
 fi
8 8
 
9
-IN_FILE="$1"
10
-SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
9
+in_file="$1"
10
+script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
11 11
 
12
-APP_NAME=napiman
12
+app_name=${NAPIMAN_APP_NAME:=napiman}
13
+venv_dir=${NAPIMAN_VENV_DIR:=.venv}
13 14
 
14
-sed -e "s|@PACKAGE_NAME[@]|$APP_NAME|g" \
15
-    -e "s|@VERSION[@]|$($SCRIPT_DIR/gen-version)|g" \
16
-    -e "s|@NAPIMAN_DIR[@]|$(dirname $SCRIPT_DIR)|g" \
17
-    $IN_FILE
15
+sed -e "s|@PACKAGE_NAME[@]|$app_name|g" \
16
+    -e "s|@VERSION[@]|$($script_dir/gen-version)|g" \
17
+    -e "s|@NAPIMAN_DIR[@]|$(dirname $script_dir)|g" \
18
+    -e "s|@VENV_DIR[@]|$venv_dir|g" \
19
+    $in_file

Loading…
Cancel
Save