From dc864e5331ec9434a5f49d9739f0ea6aa5a731b0 Mon Sep 17 00:00:00 2001 From: RobertoRoos Date: Thu, 29 Aug 2024 10:29:17 +0200 Subject: [PATCH] Removed test from setup.py + Replaced all direct setup.py calls by new standards --- .github/workflows/ci.yml | 9 +++------ .github/workflows/python-publish.yml | 8 ++++---- Dockerfile | 5 ++--- README.md | 2 +- setup.py | 22 ---------------------- 5 files changed, 10 insertions(+), 36 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 015fa129..86a8c328 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,11 +21,11 @@ jobs: steps: - name: Checkout repository and submodules - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: submodules: recursive - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -33,12 +33,9 @@ jobs: python -m pip install --upgrade pip python -m pip install flake8 pytest==7.4.4 coverage coveralls pytest-cov if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Build adslib - run: | - python setup.py build - name: Install package run: | - python setup.py develop + pip install . - name: Test with pytest run: | pytest -v --cov pyads diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 56d2150b..be95592e 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -15,21 +15,21 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: submodules: recursive - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: '3.x' - name: Install dependencies run: | python -m pip install --upgrade pip - pip install setuptools wheel twine + pip install build twine - name: Build and publish env: TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | - python setup.py sdist + python -m build sdist twine upload dist/* diff --git a/Dockerfile b/Dockerfile index b0ca8283..624b228a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,13 @@ # This Dockerfile is for running the tests on a windows system where the # TwinCat router can interfere with the tests. In the first instance tests should be run with tox. -ARG python_version=3.8 +ARG python_version=3.12 # Build python environment and setup pyads FROM python:${python_version} COPY . /pyads WORKDIR /pyads -RUN python setup.py build -RUN python setup.py develop +RUN python -m pip install . # Test commands RUN pip install pytest diff --git a/README.md b/README.md index 043feaa1..083a564c 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ From source: ```bash git clone https://github.com/stlehmann/pyads.git --recursive cd pyads -python setup.py install +pip install . ``` ## Features diff --git a/setup.py b/setup.py index e69d6f87..ef2eee79 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,6 @@ import functools import operator from setuptools import setup -from setuptools.command.test import test as TestCommand from setuptools.command.install import install as _install from distutils.command.build import build as _build from distutils.command.clean import clean as _clean @@ -118,27 +117,7 @@ def run(self): _install.run(self) -class PyTest(TestCommand): - user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")] - - def initialize_options(self): - TestCommand.initialize_options(self) - self.pytest_args = ['--cov-report', 'html', '--cov-report', 'term', - '--cov=pyads'] - - def finalize_options(self): - TestCommand.finalize_options(self) - self.test_args = [] - self.test_suite = True - - def run_tests(self): - import pytest - errno = pytest.main(self.pytest_args) - sys.exit(errno) - - cmdclass = { - 'test': PyTest, 'build': build, 'clean': clean, 'sdist': sdist, @@ -177,6 +156,5 @@ def run_tests(self): ], cmdclass=cmdclass, data_files=data_files, - tests_require=['pytest', 'pytest-cov'], has_ext_modules=lambda: True, )