From 086d135aa894ebbda527abf0d0d3641ee341e619 Mon Sep 17 00:00:00 2001 From: Vaughn Kottler Date: Thu, 5 Oct 2023 13:36:54 -0500 Subject: [PATCH] 2.0.0 - Remove use of pkg_resources --- .github/workflows/python-package.yml | 4 ++-- README.md | 13 ++++++---- config | 2 +- local/variables/package.yaml | 6 ++--- pyproject.toml | 2 +- setup.py | 2 +- tasks/conf.py | 2 +- vmklib/__init__.py | 6 ++--- vmklib/__main__.py | 2 +- vmklib/app.py | 14 +++++------ vmklib/data/data/header.mk | 2 +- vmklib/entry.py | 2 +- vmklib/resources.py | 36 ---------------------------- 13 files changed, 29 insertions(+), 64 deletions(-) delete mode 100644 vmklib/resources.py diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 4d0ff22..ec58dee 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -55,7 +55,7 @@ jobs: env: PY_TEST_EXTRA_ARGS: --cov-report=xml - - uses: codecov/codecov-action@main + - uses: codecov/codecov-action@v3 - run: mk pypi-upload-ci env: @@ -68,7 +68,7 @@ jobs: - run: | mk python-release owner=vkottler \ - repo=vmklib version=1.10.6 + repo=vmklib version=2.0.0 if: | matrix.python-version == '3.11' && matrix.system == 'ubuntu-latest' diff --git a/README.md b/README.md index d6c7c90..c57a464 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -# vmklib ([1.10.6](https://pypi.org/project/vmklib/)) +# vmklib ([2.0.0](https://pypi.org/project/vmklib/)) [![python](https://img.shields.io/pypi/pyversions/vmklib.svg)](https://pypi.org/project/vmklib/) ![Build Status](https://github.com/vkottler/vmklib/workflows/Python%20Package/badge.svg) @@ -70,8 +70,8 @@ else with simple package updates. ``` $ ./venv3.11/bin/mk -h -usage: mk [-h] [--version] [-v] [-C DIR] [-p PREFIX] [-d] [-D DEFAULT] - [-f FILE] [-c CONFIG] [-P PROJ] +usage: mk [-h] [--version] [-v] [-q] [--curses] [--no-uvloop] [-C DIR] + [-p PREFIX] [-d] [-D DEFAULT] [-f FILE] [-c CONFIG] [-P PROJ] [targets ...] Simplify project workflows by standardizing use of GNU Make. @@ -83,6 +83,9 @@ options: -h, --help show this help message and exit --version show program's version number and exit -v, --verbose set to increase logging verbosity + -q, --quiet set to reduce output + --curses whether or not to use curses.wrapper when starting + --no-uvloop whether or not to disable uvloop as event loop driver -C DIR, --dir DIR execute from a specific directory -p PREFIX, --prefix PREFIX a prefix to apply to all targets diff --git a/config b/config index 713208b..f8271b5 160000 --- a/config +++ b/config @@ -1 +1 @@ -Subproject commit 713208b1cebe73d2a19e0266052f442f6bffdec7 +Subproject commit f8271b54f578880060f0136fbc9ed9b7c2649902 diff --git a/local/variables/package.yaml b/local/variables/package.yaml index fb4efb0..e78c2af 100644 --- a/local/variables/package.yaml +++ b/local/variables/package.yaml @@ -1,5 +1,5 @@ --- -major: 1 -minor: 10 -patch: 6 +major: 2 +minor: 0 +patch: 0 entry: mk diff --git a/pyproject.toml b/pyproject.toml index 1d3efb1..aa911e4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta:__legacy__" [project] name = "vmklib" -version = "1.10.6" +version = "2.0.0" description = "Simplify project workflows by standardizing use of GNU Make." readme = "README.md" requires-python = ">=3.10" diff --git a/setup.py b/setup.py index e59f5b7..a843b9a 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ # ===================================== # generator=datazen -# version=3.1.2 +# version=3.1.3 # hash=b10cdc2e4759a797bc0d36b525de6ade # ===================================== diff --git a/tasks/conf.py b/tasks/conf.py index c03d36d..d5f7942 100644 --- a/tasks/conf.py +++ b/tasks/conf.py @@ -1,6 +1,6 @@ # ===================================== # generator=datazen -# version=3.1.2 +# version=3.1.3 # hash=9f62028523c3b5a953733ca89dcc3018 # ===================================== """ diff --git a/vmklib/__init__.py b/vmklib/__init__.py index fd05073..8443b61 100644 --- a/vmklib/__init__.py +++ b/vmklib/__init__.py @@ -1,7 +1,7 @@ # ===================================== # generator=datazen -# version=3.1.2 -# hash=08161d666b1ba6755b8b52d5679ad51c +# version=3.1.3 +# hash=323a37ac953da26ff2b3ae5654e60ac6 # ===================================== """ @@ -10,4 +10,4 @@ DESCRIPTION = "Simplify project workflows by standardizing use of GNU Make." PKG_NAME = "vmklib" -VERSION = "1.10.6" +VERSION = "2.0.0" diff --git a/vmklib/__main__.py b/vmklib/__main__.py index 53f5748..2d57e42 100644 --- a/vmklib/__main__.py +++ b/vmklib/__main__.py @@ -1,6 +1,6 @@ # ===================================== # generator=datazen -# version=3.1.2 +# version=3.1.3 # hash=e3b25ef71e1382c4879938c082dd3893 # ===================================== """ diff --git a/vmklib/app.py b/vmklib/app.py index 6dab446..c26ae47 100644 --- a/vmklib/app.py +++ b/vmklib/app.py @@ -17,13 +17,13 @@ # third-party from vcorelib.dict import GenericStrDict from vcorelib.io import ARBITER +from vcorelib.paths import find_file from vcorelib.target import Substitutions from vcorelib.task import TaskFailed from vcorelib.task.manager import TaskManager # internal from vmklib import PKG_NAME -from vmklib.resources import get_resource LOG = logging.getLogger(__name__) DEFAULT_FILE = Path("Makefile") @@ -65,7 +65,7 @@ def build_makefile( # get the path to this package's data to include our "conf.mk" include_strs = [ "-include $($(PROJ)_MK_DIR)/init.mk", - f"include {get_resource('conf.mk')}", + f"include {find_file('conf.mk', package=PKG_NAME)}", "-include $($(PROJ)_MK_DIR)/conf.mk", ] @@ -106,12 +106,10 @@ def initialize_task_manager( """Load internal and external tasks to the task manager.""" # register task-manager targets from this package + conf = find_file("lib_tasks", "conf.py", package=PKG_NAME) + assert conf is not None assert manager.script( - get_resource(os.path.join("lib_tasks", "conf.py")), - "register", - proj, - directory, - substitutions, + conf, "register", proj, directory, substitutions ), "Couldn't register package tasks from '{get_resource(task_register)}'!" # register task-manager targets for the project @@ -167,7 +165,7 @@ def entry(args: argparse.Namespace) -> int: if args.file.name != str(DEFAULT_FILE): LOG.error("'%s' not found", args.file) return 1 - args.file = get_resource(os.path.join("data", "header.mk")) + args.file = find_file("data", "header.mk", package=PKG_NAME) # Add the default target early if nothing was specified. if not args.targets and args.default: diff --git a/vmklib/data/data/header.mk b/vmklib/data/data/header.mk index ef468e2..1e61d9d 100644 --- a/vmklib/data/data/header.mk +++ b/vmklib/data/data/header.mk @@ -1,6 +1,6 @@ # ===================================== # generator=datazen -# version=3.1.2 +# version=3.1.3 # hash=22a8a762623587d443724e0f1a2a9ee4 # ===================================== ############################################################################### diff --git a/vmklib/entry.py b/vmklib/entry.py index 870cdf3..da5ade5 100644 --- a/vmklib/entry.py +++ b/vmklib/entry.py @@ -1,6 +1,6 @@ # ===================================== # generator=datazen -# version=3.1.2 +# version=3.1.3 # hash=745689313e0947f30ccf35892bb72cd4 # ===================================== diff --git a/vmklib/resources.py b/vmklib/resources.py deleted file mode 100644 index ae14c97..0000000 --- a/vmklib/resources.py +++ /dev/null @@ -1,36 +0,0 @@ -""" -A module for finding package resources. -""" - -# built-in -import os -from pathlib import Path - -# third-party -import pkg_resources -from vcorelib.paths import find_file - - -def get_resource(resource_name: str) -> Path: - """Locate the path to a package resource.""" - - resource_path = str(Path(os.path.join("data", resource_name)).parent) - - locations = [ - pkg_resources.resource_filename(__name__, resource_path), - os.path.join( - os.path.dirname(os.path.realpath(__file__)), - resource_path, - ), - ] - found = find_file( - Path(resource_name).name, - search_paths=locations, - ) - - # ensure that the resource can actually be found - assert found is not None, ( - f"Couldn't load resource '{resource_name}' in: " - f"{', '.join(locations)}!" - ) - return found