From 17820bfb9b232c0e55298e745af3c0b0419f0a47 Mon Sep 17 00:00:00 2001 From: Marcel Nijenhof Date: Sat, 8 Jan 2022 16:50:41 +0100 Subject: [PATCH] Upload pypi - Changed to setup.cfg - Changed to tox - Moved module dir to src - Moved tests dir from module to tests dir - Corrected .drone for changes - Update to 0.9.0 --- .drone.yml | 49 ++++++++++++-------- .gitignore | 1 + LICENSE | 21 ++++++++- githooks/pre-commit | 4 +- setup.cfg | 28 +++++++++++ setup.py | 31 ++----------- {ddOperApi => src/ddOperApi}/__init__.py | 2 +- ddOperApi/tests/__init__.py => tests/main.py | 2 +- {ddOperApi/tests => tests}/testServer.py | 0 tox.ini | 6 +++ 10 files changed, 91 insertions(+), 53 deletions(-) create mode 100644 setup.cfg rename {ddOperApi => src/ddOperApi}/__init__.py (99%) rename ddOperApi/tests/__init__.py => tests/main.py (96%) rename {ddOperApi/tests => tests}/testServer.py (100%) create mode 100644 tox.ini diff --git a/.drone.yml b/.drone.yml index 1d9c5e6..5bc700d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -11,9 +11,9 @@ platform: steps: - name: Run unit test environment: - PYTHONPATH: . + PYTHONPATH: src commands: - - python3 setup.py test + - python3 tests/main.py --- kind: pipeline @@ -28,9 +28,9 @@ platform: steps: - name: Run unit test environment: - PYTHONPATH: . + PYTHONPATH: src commands: - - python3 setup.py test + - python3 tests/main.py --- kind: pipeline @@ -45,9 +45,9 @@ platform: steps: - name: Run unit test environment: - PYTHONPATH: . + PYTHONPATH: src commands: - - python3 setup.py test + - python3 tests/main.py --- kind: pipeline @@ -62,9 +62,9 @@ platform: steps: - name: Run unit test environment: - PYTHONPATH: . + PYTHONPATH: src commands: - - python3 setup.py test + - tox --- kind: pipeline @@ -75,10 +75,10 @@ steps: - name: Run unit test image: python:3.6 environment: - PYTHONPATH: . + PYTHONPATH: src commands: - pip install python-dateutil flask - - python setup.py test + - python tests/main.py --- kind: pipeline @@ -89,10 +89,11 @@ steps: - name: Run unit test image: python:latest environment: - PYTHONPATH: . + PYTHONPATH: src commands: - pip install python-dateutil flask - - python setup.py test + - python --version + - python tests/main.py --- kind: pipeline @@ -107,7 +108,10 @@ platform: steps: - name: Build package files commands: - - python3 setup.py sdist + - python3 -m build + - name: Run final test after build + commands: + - tox - name: Versie toevoegen aan download environment: DOWNLOADDIR: /usr/share/nginx/html/download/python/ddoperapi @@ -122,10 +126,18 @@ steps: echo version error exit 1 else - cp "$${f}" "$${DOWNLOADDIR}" + cp "$${f}" "$${DOWNLOADDIR}"; fi done - ls -l "$${DOWNLOADDIR}" + - name: Versie upload naar pypi + environment: + TWINE_USERNAME: + from_secret: twine_username + TWINE_PASSWORD: + from_secret: twine_password + commands: + - python3 -m twine upload dist/* when: branch: - master @@ -148,17 +160,14 @@ steps: image: python:3.6 # Make sure we run the pip installed version commands: - - rm -rf ddOperApi - - pip install flask - - > - pip install --extra-index-url - https://marceln.org/download/python ddOperApi + - rm -rf src + - pip install flask ddOperApi - python -c "import ddOperApi" - python -c "import ddOperApi; print(ddOperApi.__version__)" - > [ $(python -c "import ddOperApi; print(ddOperApi.__version__)") = $(python setup.py --version) ] - - python -m unittest -v ddOperApi.tests + - python tests/main.py when: branch: - master diff --git a/.gitignore b/.gitignore index dbb32ab..91151d7 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ PKG-INFO requires.txt SOURCES.txt top_level.txt +.tox diff --git a/LICENSE b/LICENSE index 1333ed7..633871c 100644 --- a/LICENSE +++ b/LICENSE @@ -1 +1,20 @@ -TODO +Copyright (c) 2022 Rijkswaterstaat + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/githooks/pre-commit b/githooks/pre-commit index 1c1a2bb..10520f2 100755 --- a/githooks/pre-commit +++ b/githooks/pre-commit @@ -1,7 +1,7 @@ #!/bin/sh -e VERSION=$(grep version setup.py | sed -e 's/.*="//' -e 's/",//') -sed -i "s/^__version__ = .*/__version__ = '${VERSION}'/" ddOperApi/__init__.py -git add ddOperApi/__init__.py +sed -i "s/^__version__ = .*/__version__ = '${VERSION}'/" src/ddOperApi/__init__.py +git add src/ddOperApi/__init__.py python setup.py test yamllint .drone.yml diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..2a0d2b6 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,28 @@ +[metadata] +name = ddOperApi +version = 0.9.0 +author = Marcel Nijenhof +author_email = pypi@marceln.org +description = Interface for the dd-oper protocol +long_description = file: README.md +long_description_content_type = text/markdown +url = https://git.marceln.org/marceln/ddOperApi +classifiers = + Programming Language :: Python :: 3 + License :: OSI Approved :: MIT License + Operating System :: OS Independent + Development Status :: 4 - Beta + +[options] +package_dir = + = src +install_requires = + python-dateutil + requests + numpy + pyopenssl +packages = find: +python_requires = >= 3.6 + +[options.packages.find] +where = src diff --git a/setup.py b/setup.py index e21b5bc..7f1a176 100644 --- a/setup.py +++ b/setup.py @@ -1,29 +1,4 @@ -import setuptools +from setuptools import setup -with open("README.md", "r") as fh: - long_description = fh.read() - -setuptools.setup( - name="ddOperApi", # Replace with your own username - version="0.1.3", - author="Marcel Nijenhof", - author_email="pip@pion.xs4all.nl", - description="Interface for dd-oper protocol", - long_description=long_description, - long_description_content_type="text/markdown", - url="https://marceln.org/git/Werk/lmwsip", - packages=setuptools.find_packages(), - install_requires=[ - 'python-dateutil', - 'requests', - 'numpy', - 'pyopenssl' - ], - classifiers=[ - "Programming Language :: Python :: 3", - "License :: TODO", - "Operating System :: OS Independent", - "Topic :: dd-oper api" - ], - python_requires='>=3.6', -) +if __name__ == "__main__": + setup() diff --git a/ddOperApi/__init__.py b/src/ddOperApi/__init__.py similarity index 99% rename from ddOperApi/__init__.py rename to src/ddOperApi/__init__.py index 7700476..8c00eff 100644 --- a/ddOperApi/__init__.py +++ b/src/ddOperApi/__init__.py @@ -20,7 +20,7 @@ from datetime import datetime, timedelta from dateutil.parser import parse """ Version info changed by git hook """ -__version__ = '0.1.3' +__version__ = '' class ddOperApi: """ diff --git a/ddOperApi/tests/__init__.py b/tests/main.py similarity index 96% rename from ddOperApi/tests/__init__.py rename to tests/main.py index 4464e43..6319c29 100644 --- a/ddOperApi/tests/__init__.py +++ b/tests/main.py @@ -3,7 +3,7 @@ import unittest import ddOperApi from time import sleep -from ddOperApi.tests.testServer import forkTestServer, stopTestServer +from testServer import forkTestServer, stopTestServer class ddOperApiTest(unittest.TestCase): diff --git a/ddOperApi/tests/testServer.py b/tests/testServer.py similarity index 100% rename from ddOperApi/tests/testServer.py rename to tests/testServer.py diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..146bbd2 --- /dev/null +++ b/tox.ini @@ -0,0 +1,6 @@ +[tox] +envlist = py36,py37,py38,py310 + +[testenv] +deps = flask +commands = python tests/main.py