5f64e4c5d9a9 draft — Oben Sonne 11 months ago
Add sourcehut builds file

Also: do not create poole shortcut shell file as pooly.py is very likely
used in per-project virtual envs which have dependencies according to
the macros.py file used in a project.
5 files changed, 32 insertions(+), 36 deletions(-)

A => .build.yml
M .hgignore
M Makefile
M README.md
M tests/run.py
A => .build.yml +11 -0
@@ 0,0 1,11 @@ 
+image: ubuntu/lts
+packages:
+  - python3
+  - python3-venv
+  - python3-pip
+source:
+  - hg+https://hg.sr.ht/~obensonne/poole
+tasks:
+  - test: |
+      cd poole
+      make test

          
M .hgignore +0 -2
@@ 1,7 1,5 @@ 
 syntax: glob
 env/
-bin/
-poole
 tests/actual
 tests/errors.diff
 *.pyc

          
M Makefile +13 -29
@@ 1,10 1,11 @@ 
-APP := poole
-
+# =============================================================================
+# Make file for development and testing poole
+#
+# You most likely will run poole.py in your own virtual env.
 # =============================================================================
 
 export LC_ALL := en_US.UTF-8
-
-VIRTUALENV := virtualenv --python=python3
+export PYTHONIOENCODING := UTF-8:replace
 
 HERE:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
 

          
@@ 16,46 17,29 @@ HERE:=$(shell dirname $(realpath $(first
 
 .PHONY: clean
 clean:
-	rm *.pyc
+	rm -f *.pyc
 	touch requirements.txt
-	rm -f env/_done_*
 
 .PHONY: distclean
 distclean: clean
-	rm -f bin
 	rm -rf env
 
 # =============================================================================
-# build
+# build virtual environment
 # =============================================================================
 
 env/bin/python:
-	$(VIRTUALENV) env
+	python3 -m venv env
 
-env/_done_requirements: requirements.txt
+env/_requirements: requirements.txt
+	env/bin/pip install --upgrade pip
 	env/bin/pip install -U -r requirements.txt
 	touch $@
 
-bin:
-	ln -s env/bin
-
-.PHONY: env
-env: env/bin/python bin
-env: env/_done_requirements
-
-define POOLE_BIN
-#!/bin/bash
+.PHONY: build
+build: ## build everything needed to run tests and deploy releases
+build: env/bin/python env/_requirements
 
-$(HERE)/env/bin/python $(HERE)/poole.py $$@
-endef
-export POOLE_BIN
-
-poole: poole.py Makefile
-	@echo "$$POOLE_BIN" > $@
-	chmod +x poole
-
-.PHONY: build
-build: env poole
 
 # =============================================================================
 # tests

          
M README.md +1 -1
@@ 28,7 28,7 @@ env, then make Poole easily runnable via
     $ hg clone https://hg.sr.ht/~obensonne/poole /some/where/poole
     $ cd /some/where/poole
     $ make
-    $ alias poole=/some/where/poole/poole
+    $ alias poole=/some/where/poole/poole.py
 
 **TIP**: You might want to add the last command to your `~/.bashrc`.
 

          
M tests/run.py +7 -4
@@ 7,7 7,10 @@ import sys
 import glob
 
 HERE = os.path.dirname(__file__)
-POOLE = os.path.join(HERE, "..", "poole")
+POOLE = [
+    os.path.join(HERE, "..", "env", "bin", "python"),
+    os.path.join(HERE, "..", "poole.py"),
+]
 ACTUAL = os.path.join(HERE, "actual")
 EXPECTED = os.path.join(HERE, "expected")
 ERRORS = os.path.join(HERE, "errors.diff")

          
@@ 20,9 23,9 @@ if os.path.exists(ACTUAL):
 if os.path.exists(ERRORS):
     os.remove(ERRORS)
 
-cmd_init = [POOLE, ACTUAL, "--init"]
-cmd_build_dry_run = [POOLE, ACTUAL, "--build", "--dry-run"]
-cmd_build = [POOLE, ACTUAL, "--build"]
+cmd_init = POOLE + [ACTUAL, "--init"]
+cmd_build_dry_run = POOLE + [ACTUAL, "--build", "--dry-run"]
+cmd_build = POOLE + [ACTUAL, "--build"]
 cmd_diff = ["diff", "-Naur", EXPECTED, ACTUAL]
 
 r = subprocess.call(cmd_init, stdout=subprocess.PIPE)