From 26891f95e818a6b2bcae52fb54bbea655a399316 Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Sat, 17 Feb 2024 11:46:07 +0100 Subject: [PATCH] Standardized versioning --- .gitea/workflows/package.yml | 4 +--- .gitignore | 1 + datagraph/__init__.py | 4 ++-- datagraph/_version.py | 1 + setup.py | 23 +++++++++++++++++++---- test/test_datagraph.py | 22 +++++++++++++++++----- 6 files changed, 41 insertions(+), 14 deletions(-) create mode 100644 datagraph/_version.py diff --git a/.gitea/workflows/package.yml b/.gitea/workflows/package.yml index 3be4998..f62720a 100644 --- a/.gitea/workflows/package.yml +++ b/.gitea/workflows/package.yml @@ -3,9 +3,7 @@ on: [push] jobs: Package: - uses: jmaa/workflows/.gitea/workflows/python-package.yaml@v3.26 + uses: jmaa/workflows/.gitea/workflows/python-package.yaml@main secrets: PIPY_REPO_USER: ${{ secrets.PIPY_REPO_USER }} PIPY_REPO_PASS: ${{ secrets.PIPY_REPO_PASS }} - - diff --git a/.gitignore b/.gitignore index a52a74d..6f6a209 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ __pycache__/ *.egg-info/ dist/ +*.sqlite diff --git a/datagraph/__init__.py b/datagraph/__init__.py index ab21368..bc7571d 100644 --- a/datagraph/__init__.py +++ b/datagraph/__init__.py @@ -4,9 +4,9 @@ import sys, os sys.path.append(os.path.join(os.path.dirname(__file__))) +from _version import __version__ + import format import parse import schemeld import wikidata_ext - - diff --git a/datagraph/_version.py b/datagraph/_version.py new file mode 100644 index 0000000..df9144c --- /dev/null +++ b/datagraph/_version.py @@ -0,0 +1 @@ +__version__ = '0.1.1' diff --git a/setup.py b/setup.py index 484c3c6..8e1b435 100644 --- a/setup.py +++ b/setup.py @@ -1,13 +1,28 @@ + +#!/usr/bin/env python from setuptools import setup +import re + +PACKAGE_NAME = 'datagraph' + +with open('README.md', 'r') as f: + readme = f.read() + +with open(PACKAGE_NAME+'/_version.py', 'r') as f: + match = re.match(r'^__version__\s*=\s*"([\d\.]+)"$', f.read()) + version = match.group(1) + del match setup( - name='datagraph', - version='0.1.0', + name=PACKAGE_NAME, + version=version, description='Extensions to wikidata library', + long_description=readme, + long_description_content_type='text/markdown', author='Jmaa', author_email='jonjmaa@gmail.com', - url='https://gitfub.space/Jmaa/socials-util', - packages=['datagraph'], + url='https://gitfub.space/Jmaa/'+PACKAGE_NAME, + packages=[PACKAGE_NAME], install_requires=['requests', 'ratelimit', 'wikidata'], keywords=[], classifiers=[], diff --git a/test/test_datagraph.py b/test/test_datagraph.py index c661ebd..98e7811 100644 --- a/test/test_datagraph.py +++ b/test/test_datagraph.py @@ -1,6 +1,14 @@ -import schemeld -import wikidata -import wikidata_ext +import wikidata.client + +import datagraph.schemeld +import datagraph.wikidata_ext + +import requests_cache + +datagraph.wikidata_ext.REQUEST_SESSION = requests_cache.CachedSession('testing') + +def test_version(): + assert datagraph.__version__ is not None def test_get_triples(): client = wikidata.client.Client() @@ -9,5 +17,9 @@ def test_get_triples(): schema_root = "https://schema.org/" schema_prop = "image" - triples = wikidata_ext.get_triples(client, predicate = EQV_PROPERTY, "{}{}".format(schema_root, schema_prop)) - + triples_iter = datagraph.wikidata_ext.get_triples( + client = client, + predicate = EQV_PROPERTY, + object = "{}{}".format(schema_root, schema_prop), + ) + assert triples_iter is not None