diff --git a/.git_archival.txt b/.git_archival.txt new file mode 100644 index 00000000..95cb3eea --- /dev/null +++ b/.git_archival.txt @@ -0,0 +1 @@ +ref-names: $Format:%D$ diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..9e8fe43e --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Needed for setuptools-scm-git-archive +.git_archival.txt export-subst diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..46a7d044 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Red Hat + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..99874e7a --- /dev/null +++ b/Makefile @@ -0,0 +1,25 @@ +BASE_IMAGE := registry.fedoraproject.org/fedora:29 +TEST_TARGET := ./tests/ +PY_PACKAGE := ogr +OGR_IMAGE := ogr + +build: recipe.yaml + sudo ansible-bender build --build-volumes $(CURDIR):/src:Z -- ./recipe.yaml $(BASE_IMAGE) $(OGR_IMAGE) + +check: + PYTHONPATH=$(CURDIR) pytest-3 -v $(TEST_TARGET) + +shell: + sudo podman run --rm -ti -v $(CURDIR):/src:Z -w /src $(OGR_IMAGE) bash + +check-pypi-packaging: + sudo podman run --rm -ti -v $(CURDIR):/src:Z -w /src $(OGR_IMAGE) bash -c '\ + set -x \ + && rm -f dist/* \ + && python3 ./setup.py sdist bdist_wheel \ + && pip3 install dist/*.tar.gz \ + && pip3 show $(PY_PACKAGE) \ + && twine check ./dist/* \ + && python3 -c "import ogr; assert ogr.__version__" \ + && pip3 show -f $(PY_PACKAGE) | ( grep test && exit 1 || :) \ + ' diff --git a/ogr/__init__.py b/ogr/__init__.py index a828fb76..87d29f81 100644 --- a/ogr/__init__.py +++ b/ogr/__init__.py @@ -3,3 +3,11 @@ - simplifying the python work with git - intruduce one api for multiple git services (github/gitlab/pagure) """ + +from pkg_resources import get_distribution, DistributionNotFound + +try: + __version__ = get_distribution(__name__).version +except DistributionNotFound: + # package is not installed + pass diff --git a/recipe.yaml b/recipe.yaml new file mode 100644 index 00000000..1967d39d --- /dev/null +++ b/recipe.yaml @@ -0,0 +1,41 @@ +--- +- name: This is a recipe for how to cook with ogr + hosts: all + tasks: + - name: Install all packages needed to hack on ogr. + dnf: + name: + - python3-pip + - python3-setuptools + - git + - python3-setuptools_scm + - python3-setuptools_scm_git_archive + - python3-wheel # for bdist_wheel + - name: Install latest twine for sake of check command + pip: + name: + - twine # we need newest twine, b/c of the check command + - readme_renderer[md] + state: latest + - name: Install dependencies for git APIs + dnf: + name: + - python3-requests + - python3-pygithub + - python3-libpagure + - python3-gitlab + state: present + - name: stat /src + stat: + path: /src + tags: + - no-cache + register: src_path + - name: Let's make sure /src is present + assert: + that: + - 'src_path.stat.isdir' + # this requires to have sources mounted inside at /src + - name: Install ogr from the current working directory + pip: + name: /src diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..e0910573 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,50 @@ +[bdist_wheel] +universal = 1 + +[metadata] +name = ogr +url = https://github.com/user-cont/ogr +description = One API for multiple git forges. +long_description = file: README.md +long_description_content_type = text/markdown +author = Red Hat +author_email = user-cont-team@redhat.com +license = MIT +license_file = LICENSE +classifiers = + Development Status :: 4 - Beta + Intended Audience :: Developers + License :: OSI Approved :: MIT License + Operating System :: POSIX :: Linux + Programming Language :: Python + Programming Language :: Python :: 3.6 + Programming Language :: Python :: 3.7 + Topic :: Software Development + Topic :: Utilities +keywords = + git + api + github + gitlab + pagure + + +[options] +python_requires = >=3.6 +include_package_data = True + +setup_requires = + setuptools_scm + setuptools_scm_git_archive + +install_requires = + GitPython + PyGithub + libpagure + python-gitlab + +[options.extras_require] +testing = + pytest + + diff --git a/setup.py b/setup.py new file mode 100644 index 00000000..46fa4c25 --- /dev/null +++ b/setup.py @@ -0,0 +1,6 @@ +#!/usr/bin/python3 + +import setuptools + +setuptools.setup(use_scm_version=True, + packages=setuptools.find_packages(exclude=['tests*']), )