Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setup.py script to build the package using setuptools #143

Merged
merged 1 commit into from
Jun 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
*.egg-info/
*.pyc
*.pyo
.tox/
/*.html
build/
dist/
7 changes: 7 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include completions/git-imerge
include COPYING
include t/create-test-repo
include t/test-conflicted
include t/test-drop
include t/test-unconflicted
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be clear...the files under t/ are only needed for testing. Their inclusion here doesn't imply that they will be installed for end-users, does it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct.

It is customary to include test files in an sdist (source distribution).

  1. Many Linux distro packagers require tests and for them to pass when adding a new package to their repository.
  2. It allows end users to sanity check the state of the released package.

While these files are included in the .tar.gz file, they are not installed on the user's system.

include tox.ini
14 changes: 0 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@

BIN=git-imerge
PREFIX=/usr/local

RST := \
README.rst \
TODO.rst
Expand All @@ -20,13 +16,3 @@ html: $(module)/talk.html

$(module)/talk.html: $(module)/talk.rst
rst2s5 --theme=small-white --current-slide $< $@

install: $(BIN)
@mkdir -p $(DESTDIR)$(PREFIX)/bin
install $(BIN) $(DESTDIR)$(PREFIX)/bin
@mkdir -p $(DESTDIR)/etc/bash_completion.d
cp -f git-imerge.bashcomplete $(DESTDIR)/etc/bash_completion.d/git-imerge

uninstall:
rm $(DESTDIR)$(PREFIX)/bin/$(BIN)
rm -f $(DESTDIR)/etc/bash_completion.d/git-imerge
41 changes: 31 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ command.
An incremental merge can be interrupted and resumed arbitrarily, or
even pushed to a server to allow somebody else to work on it.

``git-imerge`` comes with a Bash completion script. It can be installed
by copying ``git-imerge.bashcomplete`` to the place where usually completion
scripts are installed on your system, e.g. /etc/bash_completion.d/.
``git-imerge`` comes with a Bash completion script, ``completions/git-imerge``,
that is installed automatically when installing ``git-imerge``.


Requirements
Expand All @@ -66,16 +65,24 @@ Requirements

* Python 3.x, version 3.3 or later.

The script tries to use a Python interpreter called ``python`` in
your ``PATH``. If your Python interpreter has a different name or
is not in your ``PATH``, please adjust the first line of the script
accordingly.

* A recent version of Git.

Bash completion requires Git's completion being available.


Installation
============

``git-imerge`` is available on PyPI_, so you can install it with ``pip``::

$ pip install git-imerge


or using ``setup.py`` if you have downloaded the source package locally::

$ python setup.py install


Instructions
============

Expand Down Expand Up @@ -399,6 +406,22 @@ line or change the default in your configuration::
git config --global imerge.editmergemessages true


Testing
=======

``git-imerge`` uses tox_ to run tests. To run the test suite with the system's
default Python::

$ tox

To run with a specific Python version, such as 3.7, pass the ``-e`` argument to
tox::

$ tox -e py37

.. _tox: https://tox.readthedocs.io/


License
=======

Expand All @@ -423,5 +446,3 @@ References
* http://softwareswirl.blogspot.com/2009/04/truce-in-merge-vs-rebase-war.html
* http://softwareswirl.blogspot.com/2009/08/upstream-rebase-just-works-if-history.html
* http://softwareswirl.blogspot.com/2009/08/rebase-with-history-implementation.html


File renamed without changes.
7 changes: 5 additions & 2 deletions git-imerge → gitimerge.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright 2012-2013 Michael Haggerty <[email protected]>
Expand Down Expand Up @@ -4137,11 +4136,15 @@ def add_tip2_argument(subparser):
parser.error('Unrecognized subcommand')


if __name__ == '__main__':
def climain():
try:
main(sys.argv[1:])
except Failure as e:
sys.exit(str(e))


if __name__ == "__main__":
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block and the if __name__ == '__main__': block just above it seem to be redundant. And this one doesn't appear to pass the command-line arguments into main().

climain()


# vim: set expandtab ft=python:
44 changes: 44 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import errno
import subprocess

from setuptools import setup

data_files = []
try:
completionsdir = subprocess.check_output(
["pkg-config", "--variable=completionsdir", "bash-completion"]
)
except OSError as e:
if e.errno != errno.ENOENT:
raise
else:
completionsdir = completionsdir.strip().decode('utf-8')
if completionsdir:
data_files.append((completionsdir, ["completions/git-imerge"]))


setup(
name="gitimerge",
description="Incremental merge for git",
url="https://github.com/mhagger/git-imerge",
author="Michael Haggerty",
author_email="[email protected]",
license="GPLv2+",
version="1.1.0",
py_modules=["gitimerge"],
data_files=data_files,
entry_points={"console_scripts": ["git-imerge = gitimerge:climain"]},
python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*",
classifiers=[
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
],
)
2 changes: 1 addition & 1 deletion t/reset-test-repo
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

BASE="$(dirname "$(cd $(dirname "$0") && pwd)")"
TMP="$BASE/t/tmp/main"
GIT_IMERGE="$BASE/git-imerge"
GIT_IMERGE="git-imerge"

cd "$TMP"

Expand Down
2 changes: 1 addition & 1 deletion t/test-conflicted
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set -x

BASE="$(dirname "$(cd $(dirname "$0") && pwd)")"
TMP="$BASE/t/tmp/main"
GIT_IMERGE="$BASE/git-imerge"
GIT_IMERGE="git-imerge"

cd "$TMP"

Expand Down
2 changes: 1 addition & 1 deletion t/test-drop
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ modify() {

BASE="$(dirname "$(cd $(dirname "$0") && pwd)")"
TMP="$BASE/t/tmp/drop"
GIT_IMERGE="$BASE/git-imerge"
GIT_IMERGE="git-imerge"

rm -rf "$TMP"
mkdir -p "$TMP"
Expand Down
2 changes: 1 addition & 1 deletion t/test-unconflicted
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set -x

BASE="$(dirname "$(cd $(dirname "$0") && pwd)")"
TMP="$BASE/t/tmp/main"
GIT_IMERGE="$BASE/git-imerge"
GIT_IMERGE="git-imerge"

cd "$TMP"

Expand Down
9 changes: 9 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[tox]
envlist = py

[testenv]
commands =
/bin/sh t/create-test-repo
/bin/sh t/test-unconflicted
/bin/sh t/test-conflicted
/bin/sh t/test-drop