Skip to content

Commit

Permalink
Merge pull request #26 from quillcraftsman/ci_cd
Browse files Browse the repository at this point in the history
Docs and Package updates
  • Loading branch information
quillcraftsman authored Oct 16, 2023
2 parents 90d4c2b + 3f4092a commit af98b58
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 49 deletions.
9 changes: 7 additions & 2 deletions docs/about.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,10 @@ Requirements
Development Status
------------------

.. automodule:: package
:members:
- |project_name|

- |version|

- |development_status|

`Project on PyPi <https://pypi.org/project/django-dry-tests/>`_
14 changes: 9 additions & 5 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
import os
import sys
sys.path.insert(0, os.path.abspath('..'))
from dry_tests.package import name, version, status # pylint: disable=wrong-import-position

project = 'django-dry-tests'
copyright = '2023, quillcraftsman' # pylint: disable=redefined-builtin
project = name
author = 'quillcraftsman'
release = '0.2.1'
copyright = f'2023, {author}' # pylint: disable=redefined-builtin
release = version

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand All @@ -30,10 +31,13 @@
templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']



# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'sphinx_rtd_theme'
html_static_path = ['_static']

rst_prolog = f"""
.. |development_status| replace:: {status}
.. |project_name| replace:: {project}
"""
6 changes: 6 additions & 0 deletions dry_tests/package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""
Package info
"""
name = 'django-dry-tests'
version = '1.0.0'
status = '4 - Beta'
5 changes: 0 additions & 5 deletions package.json

This file was deleted.

9 changes: 0 additions & 9 deletions package.py

This file was deleted.

77 changes: 49 additions & 28 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,52 +1,72 @@
"""
Setup.py file to build and install package
"""
import codecs
import os
import json
from setuptools import setup, find_packages
# from . import package

# allow setup.py to be run from any path
os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))


def read(filename):
def open_local(paths, mode="r", encoding="utf8"):
"""
read some file
Open local package file
:param paths: list of paths to file
:param mode: read, write, ...
:param encoding: Encoding
:return: file object
"""
with open(filename, "r", encoding="utf-8") as file:
return file.read()
path = os.path.join(os.path.abspath(os.path.dirname(__file__)), *paths)
return codecs.open(path, mode, encoding)


def get_package_info():
def get_value_from_package_info(line, value, old_value):
"""
Get Package Info
Get value from text line
:param line: file text line
:param value: value to parse
:param old_value: if value has already founded
:return:
"""
package_info = read('package.json')
return json.loads(package_info)
if old_value:
return old_value
if line.startswith(value):
_, val = line.split('=')
return val.strip().replace("'", '')
return None


PACKAGE_PYPI_NAME = 'django-dry-tests'
PACKAGE_NAME = "dry_tests"
PACKAGE_VERSION = "0.2.1"
DEVELOPMENT_STATUS = '3 - Alpha'
PROJECT_URLS = {
'Documentation': 'https://drytest.craftsman.lol',
'Source': 'https://github.com/quillcraftsman/django-dry-tests',
'Tracker': 'https://github.com/quillcraftsman/django-dry-tests/issues',
'Release notes': 'https://github.com/quillcraftsman/django-dry-tests/releases',
'Changelog': 'https://github.com/quillcraftsman/django-dry-tests/releases',
'Download': 'https://pypi.org/project/django-dry-tests/',
}

with open_local([PACKAGE_NAME, "package.py"]) as fp:
package_pypi_name, package_version, package_status = None, None, None
for file_line in fp:
package_pypi_name = get_value_from_package_info(file_line, 'name', package_pypi_name)
package_version = get_value_from_package_info(file_line, 'version', package_version)
package_status = get_value_from_package_info(file_line, 'status', package_status)

if not (package_pypi_name and package_version and package_status):
raise RuntimeError("Unable to determine Package Info.")

# class PackageInfo:
# PyPi = 'django-dry-tests'
# version = '0.2.1'
# status = '3 - Alpha'
# allow setup.py to be run from any path
# os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))

#package_info = get_package_info()
# package_name = package_info['name']
# package_version = package_info['version']
# package_status = package_info['status']
def read(filename):
"""
read some file
"""
with open(filename, "r", encoding="utf-8") as file:
return file.read()

# https://github.com/sanic-org/sanic/blob/main/setup.py - here example how to get version from file
setup(
name=PACKAGE_NAME,
version=PACKAGE_VERSION,
name=package_pypi_name,
version=package_version,
packages=find_packages(
include=[PACKAGE_NAME, f'{PACKAGE_NAME}.*']
),
Expand All @@ -66,7 +86,7 @@ def get_package_info():
# ],
python_requires=">=3",
classifiers=[
f'Development Status :: {DEVELOPMENT_STATUS}',
f'Development Status :: {package_status}',
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
Expand All @@ -75,4 +95,5 @@ def get_package_info():
"Operating System :: OS Independent",
"Topic :: Software Development :: Testing",
],
project_urls= PROJECT_URLS,
)

0 comments on commit af98b58

Please sign in to comment.