From 656bb160a41ce917bbdcebadebd13628f7015416 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Tue, 6 Feb 2024 13:33:06 +0000 Subject: [PATCH] fix tests: drop setup.py, flake8 lint --- CONTRIBUTING.md | 43 +++++++++++++++++++++---------------------- Makefile | 4 ++-- README.rst | 3 +-- pymake/_pymake.py | 10 +++++----- tox.ini | 3 ++- 5 files changed, 31 insertions(+), 32 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5aa9a68..7c97908 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,7 +11,7 @@ Makefile: ``` make [] # on UNIX-like environments -python setup.py make [] # if make is unavailable +python -m pymake [] # if make is unavailable ``` Use the alias `help` (or leave blank) to list all available aliases. @@ -50,7 +50,7 @@ The standard way to run the tests: - run the following command: ``` -[python setup.py] make test +[python -m py]make test # or: tox --skip-missing-interpreters ``` @@ -71,11 +71,11 @@ Alternative unit tests with PyTest Alternatively, use `pytest` to run the tests just for the current Python version: -- install `pytest` and `flake8` +- install `pytest`, `flake8` and `flake8-pyproject` - run the following command: ``` -[python setup.py] make alltests +[python -m py]make alltests ``` @@ -85,7 +85,7 @@ MANAGE A NEW RELEASE This section is intended for the project's maintainers and describes how to build and upload a new release. Once again, -`[python setup.py] make []` will help. +`[python -m py]make []` will help. SEMANTIC VERSIONING @@ -104,21 +104,21 @@ Note: tools can be used to automate this process, such as [python-semanticversion](https://github.com/rbarrois/python-semanticversion/). -CHECKING SETUP.PY ------------------ +CHECKING SETUP +-------------- -To check that the `setup.py` file is compliant with PyPi requirements (e.g. +To check that the setup is compliant with PyPi requirements (e.g. version number; reStructuredText in README.rst) use: ``` -[python setup.py] make testsetup +[python -m py]make testsetup ``` To upload just metadata (including overwriting mistakenly uploaded metadata) to PyPi, use: ``` -[python setup.py] make pypimeta +[python -m py]make pypimeta ``` @@ -172,7 +172,7 @@ git merge --no-ff pr-branch-name ~~~~~~ ``` -[python setup.py] make alltests +[python -m py]make alltests ``` 5 Version @@ -202,9 +202,8 @@ Test ~~~~ - ensure that all online CI tests have passed -- check `setup.py` and `MANIFEST.in` - which define the packaging -process and info that will be uploaded to [pypi](pypi.python.org) - -using `[python setup.py] make installdev` +- check setup - which define the packaging process and info that will be uploaded to [pypi](pypi.python.org) - +using `[python -m py]make install_dev` Tag ~~~ @@ -221,7 +220,7 @@ Upload Build pymake into a distributable python package: ``` -[python setup.py] make build +[python -m py]make build ``` This will generate several builds in the `dist/` folder. On non-windows @@ -231,12 +230,12 @@ Finally, upload everything to pypi. This can be done easily using the [twine](https://github.com/pypa/twine) module: ``` -[python setup.py] make pypi +[python -m py]make pypi ``` Also, the new release can (should) be added to `github` by creating a new release from the web interface; uploading packages from the `dist/` folder -created by `[python setup.py] make build`. +created by `[python -m py]make build`. Notes ~~~~~ @@ -246,7 +245,7 @@ before the real deployment - in case of a mistake, you can delete an uploaded release on pypi, but you cannot re-upload another with the same version number - in case of a mistake in the metadata on pypi (e.g. bad README), -updating just the metadata is possible: `[python setup.py] make pypimeta` +updating just the metadata is possible: `[python -m py]make pypimeta` QUICK DEV SUMMARY @@ -255,12 +254,12 @@ QUICK DEV SUMMARY For expereinced devs, once happy with local master: 1. bump version in `pymake/_version.py` -2. test (`[python setup.py] make alltests`) +2. test (`[python -m py]make alltests`) 3. `git commit [--amend] # -m "bump version"` 4. `git push` 5. wait for tests to pass a) in case of failure, fix and go back to (2) 6. `git tag vM.m.p && git push --tags` -7. `[python setup.py] make distclean` -8. `[python setup.py] make build` -9. `[python setup.py] make pypi` +7. `[python -m py]make distclean` +8. `[python -m py]make build` +9. `[python -m py]make pypi` diff --git a/Makefile b/Makefile index a89796e..456f290 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# IMPORTANT: for compatibility with `python setup.py make [alias]`, ensure: +# IMPORTANT: for compatibility with `python -m pymake [alias]`, ensure: # 1. Every alias is preceded by @[+]make (eg: @make alias) # 2. A maximum of one @make alias or command per line # see: https://github.com/tqdm/py-make/issues/1 @@ -27,7 +27,7 @@ run help: - @python setup.py make -p + @python -m pymake -p alltests: @+make testcoverage diff --git a/README.rst b/README.rst index 2366148..789da06 100644 --- a/README.rst +++ b/README.rst @@ -91,8 +91,7 @@ Sample makefile compatible with ``pymake``: test: pytest install: - python setup.py\ - install + python -m pip install compile: $(PY) test.py circle: diff --git a/pymake/_pymake.py b/pymake/_pymake.py index 2536653..34bb2e0 100644 --- a/pymake/_pymake.py +++ b/pymake/_pymake.py @@ -45,8 +45,8 @@ def parse_makefile_aliases(filepath): ini_lines = ['[root]'] + list(ini_lines) # Substitute macros - macros = dict(found for l in ini_lines - for found in RE_MACRO_DEF.findall(l) if found) + macros = dict(found for line in ini_lines + for found in RE_MACRO_DEF.findall(line) if found) ini_str = '\n'.join(ini_lines) # allow finite amount of nesting for _ in range(99): @@ -54,8 +54,8 @@ def parse_makefile_aliases(filepath): ini_str = re.sub(r"\$\(%s\)" % m, expr, ini_str) if not RE_MACRO.search(ini_str): # Strip macro definitions for rest of parsing - ini_str = '\n'.join(l for l in ini_str.splitlines() - if not RE_MACRO_DEF.search(l)) + ini_str = '\n'.join(line for line in ini_str.splitlines() + if not RE_MACRO_DEF.search(line)) break else: raise PymakeKeyError("No substitution for macros: " + @@ -140,6 +140,6 @@ def execute_makefile_commands( # Launch the command and wait to finish (synchronized call) try: check_call(parsed_cmd) - except: + except Exception: if not ignore_errors: raise diff --git a/tox.ini b/tox.ini index d0ff3d6..771b9ef 100644 --- a/tox.ini +++ b/tox.ini @@ -35,10 +35,11 @@ allowlist_externals=codacy [testenv:check] deps= flake8 + flake8-pyproject build twine commands= flake8 -j 8 --count --statistics . {envpython} -m build {envpython} -m twine check dist/* - {envpython} setup.py make none + {envpython} -m pymake none