From 2686e8ad55ee891bc7797cf2bce00574c21e7245 Mon Sep 17 00:00:00 2001 From: Steven Serrata <9343811+sserrata@users.noreply.github.com> Date: Mon, 18 Oct 2021 17:59:10 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9A=99=EF=B8=8F=20Migrating=20to=20pyproject?= =?UTF-8?q?.toml=20and=20flit=20(#173)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * bump version and change description * add pyproject.toml * remove legacy package files * fix package description * adapt workflows to use flit * update documentation URL * fix project dependencies * fix requests dep * fix tinydb dep --- .github/workflows/pythonpackage.yml | 6 +-- .github/workflows/pythonpublish.yml | 9 ++--- pan_cortex_data_lake/__init__.py | 4 +- pyproject.toml | 60 +++++++++++++++++++++++++++++ requirements.txt | 30 --------------- requirements_dev.txt | 6 --- setup.cfg | 22 ----------- setup.py | 56 --------------------------- 8 files changed, 68 insertions(+), 125 deletions(-) create mode 100644 pyproject.toml delete mode 100644 requirements.txt delete mode 100644 requirements_dev.txt delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index caf3911..e80e7f4 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9] + python-version: [3.5, 3.6, 3.7, 3.8, 3.9] steps: - uses: actions/checkout@v2 @@ -25,15 +25,13 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r requirements_dev.txt + pip install .[test] - name: Lint with flake8 run: | - pip install flake8 # stop the build if there are Python syntax errors or undefined names flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Test with pytest run: | - pip install pytest pytest diff --git a/.github/workflows/pythonpublish.yml b/.github/workflows/pythonpublish.yml index f351220..60b76dd 100644 --- a/.github/workflows/pythonpublish.yml +++ b/.github/workflows/pythonpublish.yml @@ -17,11 +17,10 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install setuptools wheel twine + pip install flit - name: Build and publish env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + FLIT_USERNAME: ${{ secrets.PYPI_USERNAME }} + FLIT_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | - python setup.py sdist bdist_wheel - twine upload dist/* + flit publish diff --git a/pan_cortex_data_lake/__init__.py b/pan_cortex_data_lake/__init__.py index f91b302..0219d96 100644 --- a/pan_cortex_data_lake/__init__.py +++ b/pan_cortex_data_lake/__init__.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- -"""Main package for cortex.""" +"""Python idiomatic SDK for Cortex™ Data Lake.""" __author__ = "Palo Alto Networks" -__version__ = "2.0.0-a14" +__version__ = "2.0.0b1" from .exceptions import ( # noqa: F401 CortexError, diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..71a53df --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,60 @@ +[build-system] +requires = ["flit_core >=3.2,<4"] +build-backend = "flit_core.buildapi" + +[project] +name = "pan-cortex-data-lake" +keywords = [ + "cortex", + "data", + "lake", + "datalake", + "sdk", + "api", + "palo alto networks", +] +authors = [ + {name = "Steven Serrata", email = "sserrata@paloaltonetworks.com"}, +] +maintainers = [ + {name = "Steven Serrata", email = "sserrata@paloaltonetworks.com"}, + {name = "Developer Relations", email = "devrel@paloaltonetworks.com"}, +] +readme = "README.md" +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "License :: OSI Approved :: ISC License (ISCL)", + "Natural Language :: English", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", +] +license = {file = "LICENSE"} +requires-python = ">=3.5" +dynamic = ["version", "description"] +dependencies = [ + "requests >=2", + "tinydb >=3,<4" +] + +[project.optional-dependencies] +test = [ + "pytest >=2.7.3", + "pytest-cov", + "flake8", + "tox", + "coverage", +] + +[project.urls] +Home = "https://cortex.pan.dev" +Source = "https://github.com/PaloAltoNetworks/pan-cortex-data-lake-python" +Documentation = "https://cortex.pan.dev/docs/develop/cdl_python_installation" + +[tool.flit.module] +name = "pan_cortex_data_lake" + diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 4a0e931..0000000 --- a/requirements.txt +++ /dev/null @@ -1,30 +0,0 @@ -# -# This file is autogenerated by pip-compile -# To update, run: -# -# pip-compile --generate-hashes -# -certifi==2019.11.28 \ - --hash=sha256:017c25db2a153ce562900032d5bc68e9f191e44e9a0f762f373977de9df1fbb3 \ - --hash=sha256:25b64c7da4cd7479594d035c08c2d809eb4aab3a26e5a990ea98cc450c320f1f \ - # via requests -chardet==3.0.4 \ - --hash=sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae \ - --hash=sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691 \ - # via requests -idna==2.9 \ - --hash=sha256:7588d1c14ae4c77d74036e8c22ff447b26d0fde8f007354fd48a7814db15b7cb \ - --hash=sha256:a068a21ceac8a4d63dbfd964670474107f541babbd2250d61922f029858365fa \ - # via requests -requests==2.23.0 \ - --hash=sha256:43999036bfa82904b6af1d99e4882b560e5e2c68e5c4b0aa03b655f3d7d73fee \ - --hash=sha256:b3f43d496c6daba4493e7c431722aeb7dbc6288f52a6e04e7b6023b0247817e6 \ - # via pan-cortex-data-lake (setup.py) -tinydb==3.15.2 \ - --hash=sha256:1087ade5300c47dbf9539d9f6dafd53115bd5e85a67d480d8188bdbfa2d9eaf4 \ - --hash=sha256:f273d9b6d8b1b5e1d094a6eb8b72851b39b81099293344132c73332b60e3b893 \ - # via pan-cortex-data-lake (setup.py) -urllib3==1.25.8 \ - --hash=sha256:2f3db8b19923a873b3e5256dc9c2dedfa883e33d87c690d9c7913e1f40673cdc \ - --hash=sha256:87716c2d2a7121198ebcb7ce7cccf6ce5e9ba539041cfbaeecfb641dc0bf6acc \ - # via requests diff --git a/requirements_dev.txt b/requirements_dev.txt deleted file mode 100644 index c1a1864..0000000 --- a/requirements_dev.txt +++ /dev/null @@ -1,6 +0,0 @@ -flake8 -tox -coverage -pytest -pytest-runner -pan-cortex-data-lake \ No newline at end of file diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 60ced2d..0000000 --- a/setup.cfg +++ /dev/null @@ -1,22 +0,0 @@ -[bumpversion] -current_version = 2.0.0a14 -commit = True -tag = True - -[bumpversion:file:setup.py] -search = version='{current_version}' -replace = version='{new_version}' - -[bumpversion:file:pan_cortex_data_lake/__init__.py] -search = __version__ = '{current_version}' -replace = __version__ = '{new_version}' - -[bdist_wheel] -universal = 1 - -[flake8] -exclude = docs - -[aliases] -test = pytest - diff --git a/setup.py b/setup.py deleted file mode 100644 index 1dcff5b..0000000 --- a/setup.py +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -"""Palo Alto Networks Cloud Python SDK setup script.""" - -from setuptools import setup, find_packages -import re - -with open("README.md") as readme_file: - readme = readme_file.read() - -with open("HISTORY.md") as history_file: - history = history_file.read() - -with open("requirements.txt") as requirements_file: - regex = re.compile(r"(.+==[0-9]+\.[0-9]+\.[0-9]+)") - requirements = regex.findall(requirements_file.read()) - -setup_requirements = ["pytest-runner"] - -test_requirements = ["pytest"] - -setup( - name="pan-cortex-data-lake", - version="2.0.0-a14", - description="Python idiomatic SDK for Cortex™ Data Lake.", - long_description=readme + "\n\n" + history, - long_description_content_type="text/markdown", - author="Steven Serrata", - author_email="sserrata@paloaltonetworks.com", - url="https://github.com/PaloAltoNetworks/pan-cortex-data-lake-python", - packages=find_packages( - include=["pan_cortex_data_lake", "pan_cortex_data_lake.adapters"] - ), - include_package_data=True, - install_requires=requirements, - license="ISC license", - zip_safe=False, - keywords="cortex data lake", - classifiers=[ - "Development Status :: 3 - Alpha", - "Intended Audience :: Developers", - "License :: OSI Approved :: ISC License (ISCL)", - "Natural Language :: English", - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - ], - test_suite="tests", - tests_require=test_requirements, - setup_requires=setup_requirements, -)