diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9062eba --- /dev/null +++ b/Makefile @@ -0,0 +1,19 @@ +test: + ./run_unittests.sh +.PHONY: test + +clean: + rm -rf dist packages/openshift_client.egg-info packages/openshift_client/__pycache__ build +.PHONY: clean + +release: clean + python -m build +.PHONY: release + +publish-testpypi: + twine upload --repository testpypi dist/* +.PHONY: publish-testpypi + +publish-pypi: + twine upload --repository pypi dist/* +.PHONY: publish-pypi diff --git a/README.md b/README.md index 8754c49..93e494c 100644 --- a/README.md +++ b/README.md @@ -76,8 +76,12 @@ the CLI documentation to find the pass-through arguments a given interaction req #### For development 1. Git clone https://github.com/openshift/openshift-client-python.git (or your fork). -2. Append ./packages to your PYTHONPATH environment variable (e.g. export PYTHONPATH=$(pwd)/packages:$PYTHONPATH). -3. Write and run your python script! +2. Add required libraries + ```bash + sudo pip install -r requirements.txt + ``` +3. Append ./packages to your PYTHONPATH environment variable (e.g. export PYTHONPATH=$(pwd)/packages:$PYTHONPATH). +4. Write and run your python script! ## Usage diff --git a/docs/PACKAGING.md b/docs/PACKAGING.md index 2abc52c..cd5f192 100644 --- a/docs/PACKAGING.md +++ b/docs/PACKAGING.md @@ -53,26 +53,14 @@ username = __token__ password = pypi- ``` -### setup.cfg -The openshift-client module has been tested to support both python2 and python3. Therefore, elect to build a `univeral` wheel instead of platform specific wheels. To do so, we have added the necessary flags to our `setup.cfg` file: -```text -[bdist_wheel] -universal = 1 - -[metadata] -license_file = LICENSE -``` - -The alternative is to add the necessary flag to the commandline when building your packages: - -```bash - python setup.py build bdist_wheel --universal -``` - ## Building For openshift-client, build both a source distribution and a universal wheel: ```bash - python setup.py build sdist bdist_wheel + python -m build +``` +or: +```bash + make release ``` ## Publishing @@ -82,11 +70,19 @@ Publishing to either package index is accomplished by using [Twine](https://pypi ```bash twine upload --repository testpypi dist/* ``` +or +```bash + make publish-testpypi +``` ### PyPI ```bash twine upload --repository pypi dist/* ``` +or +```bash + make publish-pypi: +``` ## Installation diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..bc9fb14 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,50 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[tool.setuptools.packages.find] +where = ["packages"] + +[tool.setuptools.dynamic] +version = {attr = "openshift_client.__VERSION__"} + +[project] +name = "openshift-client" +description = "OpenShift python client" +keywords = ["OpenShift"] +readme = "README.md" +license = {file = "LICENSE"} +authors = [ + {name = "Justin Pierce", email = "jupierce@redhat.com"}, +] +maintainers = [ + {name = "Brad Williams", email = "brawilli@redhat.com"}, +] +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "Intended Audience :: Information Technology", + "License :: OSI Approved :: Apache Software License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 2", + "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.12", + "Topic :: Utilities", +] +requires-python = ">= 2.7" +dependencies = [ + "pyyaml", + "six", +] +dynamic = [ + "version", +] + +[project.optional-dependencies] +ssh = ["paramiko"] + +[project.urls] +Homepage = "https://github.com/openshift/openshift-client-python" +Issues = "https://github.com/openshift/openshift-client-python/issues" diff --git a/requirements.txt b/requirements.txt index ca5258b..cc8e315 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,7 @@ +# +# This file can be used to install dependencies for local library development +# +build six pyyaml - -# paramiko is only required if ssh connections are required (e.g. use of client_host context) -paramiko \ No newline at end of file +paramiko diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index c2d7a6f..0000000 --- a/setup.cfg +++ /dev/null @@ -1,5 +0,0 @@ -[bdist_wheel] -universal = 1 - -[metadata] -license_files = LICENSE diff --git a/setup.py b/setup.py deleted file mode 100644 index 450a63f..0000000 --- a/setup.py +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/python - -import os -from setuptools import setup, find_packages - - -def get_requirements(filename="requirements.txt"): - """Extract requirements from a pip formatted requirements file.""" - - with open(filename, "r") as requirements_file: - return requirements_file.read().splitlines() - - -def get_long_description(): - """Returns README.md content.""" - return open("README.md", "r").read() - - -def read(rel_path): - """Returns the contents of the file at the specified relative path.""" - here = os.path.abspath(os.path.dirname(__file__)) - with open(os.path.join(here, rel_path), 'r') as fp: - return fp.read() - - -def get_version(rel_path): - """Returns the semantic version for the openshift_client module.""" - for line in read(rel_path).splitlines(): - if line.startswith('__VERSION__'): - delim = '"' if '"' in line else "'" - return line.split(delim)[1] - else: - raise RuntimeError("Unable to find version string.") - - -setup( - name="openshift-client", - version=get_version('packages/openshift_client/__init__.py'), - author="Justin Pierce", - author_email="jupierce@redhat.com", - maintainer="Brad Williams", - maintainer_email="brawilli@redhat.com", - url="https://github.com/openshift/openshift-client-python", - description="OpenShift python client", - packages=find_packages(where='packages'), - package_dir={"": "packages"}, - install_requires=get_requirements(), - keywords=["OpenShift"], - include_package_data=True, - data_files=[ - ("requirements.txt", ["requirements.txt"]), - ], - long_description=get_long_description(), - long_description_content_type="text/markdown", - classifiers=[ - "Development Status :: 4 - Beta", - "Topic :: Utilities", - "Intended Audience :: Developers", - "Intended Audience :: Information Technology", - "License :: OSI Approved :: Apache Software License", - "Operating System :: OS Independent", - "Programming Language :: Python", - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.12", - ], -)