Skip to content

Commit

Permalink
Merge pull request #3 from lachmanfrantisek/packaging
Browse files Browse the repository at this point in the history
Introduce packaging
  • Loading branch information
TomasTomecek authored Jan 11, 2019
2 parents 24dcd14 + 640bbf3 commit 29ca3ca
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 0 deletions.
1 change: 1 addition & 0 deletions .git_archival.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ref-names: $Format:%D$
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Needed for setuptools-scm-git-archive
.git_archival.txt export-subst
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
25 changes: 25 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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 || :) \
'
8 changes: 8 additions & 0 deletions ogr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
41 changes: 41 additions & 0 deletions recipe.yaml
Original file line number Diff line number Diff line change
@@ -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
50 changes: 50 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -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 = [email protected]
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


6 changes: 6 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/python3

import setuptools

setuptools.setup(use_scm_version=True,
packages=setuptools.find_packages(exclude=['tests*']), )

0 comments on commit 29ca3ca

Please sign in to comment.