Browse Source

Merge pull request #2 from cstradtman/master

Spelling correction in path, addition of packaging and CI/CD information, cleanup of filesystem, additions of .gitignore
rmboggan 1 year ago
parent
commit
746f4bb20c

+ 160 - 0
.gitignore

@@ -0,0 +1,160 @@
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+build/
+develop-eggs/
+dist/
+downloads/
+eggs/
+.eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+wheels/
+share/python-wheels/
+*.egg-info/
+.installed.cfg
+*.egg
+MANIFEST
+
+# PyInstaller
+#  Usually these files are written by a python script from a template
+#  before PyInstaller builds the exe, so as to inject date/other infos into it.
+*.manifest
+*.spec
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.nox/
+.coverage
+.coverage.*
+.cache
+nosetests.xml
+coverage.xml
+*.cover
+*.py,cover
+.hypothesis/
+.pytest_cache/
+cover/
+
+# Translations
+*.mo
+*.pot
+
+# Django stuff:
+*.log
+local_settings.py
+db.sqlite3
+db.sqlite3-journal
+
+# Flask stuff:
+instance/
+.webassets-cache
+
+# Scrapy stuff:
+.scrapy
+
+# Sphinx documentation
+docs/_build/
+
+# PyBuilder
+.pybuilder/
+target/
+
+# Jupyter Notebook
+.ipynb_checkpoints
+
+# IPython
+profile_default/
+ipython_config.py
+
+# pyenv
+#   For a library or package, you might want to ignore these files since the code is
+#   intended to run in multiple environments; otherwise, check them in:
+# .python-version
+
+# pipenv
+#   According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
+#   However, in case of collaboration, if having platform-specific dependencies or dependencies
+#   having no cross-platform support, pipenv may install dependencies that don't work, or not
+#   install all needed dependencies.
+#Pipfile.lock
+
+# poetry
+#   Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
+#   This is especially recommended for binary packages to ensure reproducibility, and is more
+#   commonly ignored for libraries.
+#   https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
+#poetry.lock
+
+# pdm
+#   Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
+#pdm.lock
+#   pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
+#   in version control.
+#   https://pdm.fming.dev/#use-with-ide
+.pdm.toml
+
+# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
+__pypackages__/
+
+# Celery stuff
+celerybeat-schedule
+celerybeat.pid
+
+# SageMath parsed files
+*.sage.py
+
+# Environments
+.env
+.venv
+env/
+venv/
+ENV/
+env.bak/
+venv.bak/
+
+# Spyder project settings
+.spyderproject
+.spyproject
+
+# Rope project settings
+.ropeproject
+
+# mkdocs documentation
+/site
+
+# mypy
+.mypy_cache/
+.dmypy.json
+dmypy.json
+
+# Pyre type checker
+.pyre/
+
+# pytype static type analyzer
+.pytype/
+
+# Cython debug symbols
+cython_debug/
+
+# PyCharm
+#  JetBrains specific template is maintained in a separate JetBrains.gitignore that can
+#  be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
+#  and can be added to the global gitignore or merged into this file.  For a more nuclear
+#  option (not recommended) you can uncomment the following to ignore the entire idea folder.
+#.idea/

+ 54 - 0
.gitlab-ci.yml

@@ -0,0 +1,54 @@
+# This file is a template, and might need editing before it works on your project.
+# To contribute improvements to CI/CD templates, please follow the Development guide at:
+# https://docs.gitlab.com/ee/development/cicd/templates.html
+# This specific template is located at:
+# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Python.gitlab-ci.yml
+# Official language image. Look for the different tagged releases at:
+# https://hub.docker.com/r/library/python/tags/
+image: python:latest
+# Change pip's cache directory to be inside the project directory since we can
+# only cache local items.
+variables:
+  PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
+# Pip's cache doesn't store the python packages
+# https://pip.pypa.io/en/stable/topics/caching/
+#
+# If you want to also cache the installed packages, you have to install
+# them in a virtualenv and cache it as well.
+cache:
+  paths:
+    - .cache/pip
+    - venv/
+before_script:
+  - python --version  # For debugging
+  - pip install virtualenv
+  - virtualenv venv
+  - source venv/bin/activate
+test:
+  script:
+    - pip install pytest
+    - pytest -v --pyargs src/ll_sdk
+
+run:
+  script:
+   # - python setup.py bdist_wheel
+    # an alternative approach is to install and run:
+    #- pip install dist/*
+    - pip install build twine
+    - python -m build
+    # run the command here
+    - TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python -m twine upload --verbose --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/*
+  artifacts:
+    paths:
+      - dist/*.whl
+#pages:
+#  script:
+#    - pip install sphinx sphinx-rtd-theme
+#    - cd doc
+#    - make html
+#    - mv build/html/ ../public/
+#  artifacts:
+#    paths:
+#      - public
+#  rules:
+#    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

+ 24 - 0
pyproject.toml

@@ -0,0 +1,24 @@
+[build-system]
+requires = ["setuptools>=61.0"]
+build-backend = "setuptools.build_meta"
+
+[project]
+name = "llnw_sdk_python"
+version = "0.1.3"
+authors = [
+  { name="Example Author", email="opensource@llnw.com" },
+]
+description = "Limelight Networks Python SDK"
+readme = "README.md"
+license = { file="LICENSE" }
+requires-python = ">=3.6"
+classifiers=[
+        "Programming Language :: Python :: 3",
+        "Development Status :: 4 - Beta",
+        "License :: OSI Approved :: Apache Software License"
+    ]
+
+[project.urls]
+"Homepage" = "https://github.com/llnw/llnw-sdk-python"
+"Bug Tracker" = "https://github.com/llnw/llnw-sdk-python/issues"
+

+ 0 - 23
setup.py

@@ -1,23 +0,0 @@
-import setuptools
-
-with open("README.md", "r") as fh:
-    long_description = fh.read()
-
-setuptools.setup(
-    name="llnw-sdk-python",
-    version="0.1",
-    author="Roman Maksymiv",
-    author_email="opensource@llnw.com",
-    description="Limelight Networks Python SDK",
-    long_description=long_description,
-    long_description_content_type="text/markdown",
-    url="https://github.com/llnw/llnw-sdk-python",
-    packages=setuptools.find_packages(),
-    classifiers=[
-        "Programming Language :: Python :: 3",
-        "Development Status :: 4 - Beta",
-        "License :: OSI Approved :: Apache Software License"
-    ],
-    python_requires='>=3.6',
-    install_requires=['requests>2', 'dateutils', 'pytest']
-)

sdk/__init__.py → src/ll_sdk/__init__.py


+ 1 - 1
sdk/base_client.py

@@ -75,7 +75,7 @@ class BaseRestAuthClient(object):
     def __init__(self, hostname, context, username, api_shared_key, schema, port, default_headers=None):
         self.username = username
         self.api_shared_key = api_shared_key
-        self.logger = logging.getLogger('sdk.' + self.__class__.__name__)
+        self.logger = logging.getLogger('ll_sdk.' + self.__class__.__name__)
         self.base = build_base_url(hostname, context, port, schema)
         self.auth = LlnwUserAuth(self.username, self.api_shared_key)
         self.default_headers = default_headers or {}

+ 1 - 1
sdk/config_api.py

@@ -3,7 +3,7 @@
 
 import json
 from urllib.parse import parse_qs
-from sdk.base_client import BaseRestAuthClient
+from ll_sdk.base_client import BaseRestAuthClient
 
 __all__ = ['ConfigApiClient']
 __docformat__ = 'restructuredtext'

+ 2 - 2
sdk/realtime_reporting_api.py

@@ -2,8 +2,8 @@
 # -*- coding: utf-8 -*-
 
 import json
-from sdk.base_client import BaseRestReportingClient
-from sdk.utils.reporting_api_helper.time_utils import _timespan as timespan
+from ll_sdk.base_client import BaseRestReportingClient
+from ll_sdk.utils.reporting_api_helper.time_utils import _timespan as timespan
 
 __all__ = ['RealtimeReportingClient']
 __docformat__ = 'restructuredtext'

+ 2 - 2
sdk/reporting_api.py

@@ -3,8 +3,8 @@
 
 import json
 from itertools import chain
-from sdk.base_client import BaseRestReportingClient
-from sdk.utils.reporting_api_helper.time_utils import _timespan as timespan
+from ll_sdk.base_client import BaseRestReportingClient
+from ll_sdk.utils.reporting_api_helper.time_utils import _timespan as timespan
 
 __all__ = ['ReportingClient']
 __docformat__ = 'restructuredtext'

sdk/test/__init__.py → src/ll_sdk/test/__init__.py


sdk/test/utils/__init__.py → src/ll_sdk/test/utils/__init__.py


sdk/test/utils/config_api_helper/__init__.py → src/ll_sdk/test/utils/config_api_helper/__init__.py


+ 1 - 1
sdk/test/utils/config_api_helper/test_cert.py

@@ -2,7 +2,7 @@
 # -*- coding: utf-8 -*-
 
 import pytest
-from sdk.utils.config_api_helper.cert import SSLCertObj
+from ll_sdk.utils.config_api_helper.cert import SSLCertObj
 
 shortname = "testname"
 certificate = "-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"

+ 1 - 1
sdk/test/utils/config_api_helper/test_deliver.py

@@ -2,7 +2,7 @@
 # -*- coding: utf-8 -*-
 
 import pytest
-from sdk.utils.config_api_helper.deilver import DeliverServiceInstanceObj, DeliverInstanceBaseException
+from ll_sdk.utils.config_api_helper.deliver import DeliverServiceInstanceObj, DeliverInstanceBaseException
 
 shortname = "testname"
 published_host = "www.example.com"

+ 1 - 1
sdk/test/utils/config_api_helper/test_httpcs.py

@@ -2,7 +2,7 @@
 # -*- coding: utf-8 -*-
 
 import pytest
-from sdk.utils.config_api_helper.httpcs import HttpCsServiceInstanceObj, HttpCsSvcInstanceBaseException
+from ll_sdk.utils.config_api_helper.httpcs import HttpCsServiceInstanceObj, HttpCsSvcInstanceBaseException
 
 shortname = "testname"
 published_host = "www.example.com"

sdk/utils/__init__.py → src/ll_sdk/utils/__init__.py


sdk/utils/config_api_helper/__init__.py → src/ll_sdk/utils/config_api_helper/__init__.py


+ 1 - 1
sdk/utils/config_api_helper/cert.py

@@ -6,7 +6,7 @@ __docformat__ = 'restructuredtext'
 
 import uuid
 from copy import deepcopy
-from sdk.utils.config_api_helper.templates.ssl_cert_template import *
+from ll_sdk.utils.config_api_helper.templates.ssl_cert_template import *
 
 
 class SSLCertObj(dict):

+ 1 - 1
sdk/utils/config_api_helper/deilver.py

@@ -7,7 +7,7 @@ __docformat__ = 'restructuredtext'
 import uuid
 import requests
 from copy import deepcopy
-from sdk.utils.config_api_helper.templates.delivery_template import *
+from ll_sdk.utils.config_api_helper.templates.delivery_template import *
 
 
 class DeliverServiceInstanceObj(dict):

+ 1 - 1
sdk/utils/config_api_helper/httpcs.py

@@ -8,7 +8,7 @@ import uuid
 import requests
 from itertools import product
 from copy import deepcopy
-from sdk.utils.config_api_helper.templates.httpcs_template import *
+from ll_sdk.utils.config_api_helper.templates.httpcs_template import *
 
 
 class HttpCsServiceInstanceObj(dict):

sdk/utils/config_api_helper/templates/__init__.py → src/ll_sdk/utils/config_api_helper/templates/__init__.py


sdk/utils/config_api_helper/templates/delivery_template.py → src/ll_sdk/utils/config_api_helper/templates/delivery_template.py


sdk/utils/config_api_helper/templates/httpcs_template.py → src/ll_sdk/utils/config_api_helper/templates/httpcs_template.py


sdk/utils/config_api_helper/templates/ssl_cert_template.py → src/ll_sdk/utils/config_api_helper/templates/ssl_cert_template.py


sdk/utils/reporting_api_helper/__init__.py → src/ll_sdk/utils/reporting_api_helper/__init__.py


sdk/utils/reporting_api_helper/time_utils.py → src/ll_sdk/utils/reporting_api_helper/time_utils.py