Repository: JoshData/fast_diff_match_patch (language: python)

Issue:
Name collision on PyPI
Just a note that this package name collides with https://pypi.python.org/pypi/diff-match-patch/ -- that is, both of them come in under `import diff_match_patch`, but have different APIs.

This makes it impossible to use both in the same project, or to use any combination of libraries that depend on both. As a specific usecase, I was working on a script using https://github.com/sachinrekhi/richtextpy, which depends on the other lib, and then tried to use this library for some fast diffing in another part of the script, and as far as I can tell that's not possible. (Maybe by installing this library outside of sys.path and doing some clever import magic?)

I realize this is no one's problem but my own. :) If you're open to working on it, though, it might be nice to also publish this with an alternate package name like `fast_diff_match_patch`, since the colliding library is just a straight packaging of the original google script.

Thanks!


Discussion / hints:
Hey, yes, I'm totally open to changing the names to fix that. This has been bothering me too. If you submit a PR renaming both the module (i.e. the import name) and the pypi package (in setup.py) like you said, I'll take care of fixing how it's published on pypi (and I'll rename this repo to match too).

(You might be interested in https://github.com/joshdata/jot by the way.)
This seems to have been fixed.

Fix patch:
diff --git a/README.rst b/README.rst
index a73ec72..e24044e 100644
--- a/README.rst
+++ b/README.rst
@@ -19,7 +19,7 @@ First::
 
 Then write (this is Python 3)::
 
-	from diff_match_patch import diff
+	from fast_diff_match_patch import diff
 
 	changes = diff("Hello world.", "Goodbye moon.",
 		timelimit=0, checklines=False)
@@ -63,3 +63,10 @@ And to test without installing::
 
  PYTHONPATH=build/lib.linux-x86_64-2.7/ python test.py
  PYTHONPATH=build/lib.linux-x86_64-3.4/ python3 test.py
+
+Changelog
+---------
+
+2.0.0 (unreleased)
+******************
+* Rename package import from `diff_match_patch` to `fast_diff_match_patch` to avoid import naming collision with `<https://pypi.org/project/diff-match-patch/>`_.
\ No newline at end of file
diff --git a/interface.cpp b/interface.cpp
index 368c8a2..321d4b0 100644
--- a/interface.cpp
+++ b/interface.cpp
@@ -302,9 +302,9 @@ static PyMethodDef MyMethods[] = {
 };
 
 PyMODINIT_FUNC
-initdiff_match_patch(void)
+initfast_diff_match_patch(void)
 {
-    (void) Py_InitModule("diff_match_patch", MyMethods);
+    (void) Py_InitModule("fast_diff_match_patch", MyMethods);
 }
 #endif
 
@@ -335,7 +335,7 @@ static PyMethodDef MyMethods[] = {
 
 static struct PyModuleDef mymodule = {
    PyModuleDef_HEAD_INIT,
-   "diff_match_patch",   /* name of module */
+   "fast_diff_match_patch",   /* name of module */
    NULL, /* module documentation, may be NULL */
    -1,       /* size of per-interpreter state of the module,
                 or -1 if the module keeps state in global variables. */
@@ -343,7 +343,7 @@ static struct PyModuleDef mymodule = {
 };
 
 PyMODINIT_FUNC
-PyInit_diff_match_patch(void)
+PyInit_fast_diff_match_patch(void)
 {
     return PyModule_Create(&mymodule);
 }
diff --git a/setup.py b/setup.py
index 74cb98b..179ed24 100644
--- a/setup.py
+++ b/setup.py
@@ -5,14 +5,14 @@
 # python setup.py sdist bdist_wheel
 # twine upload dist/*
 
-module1 = Extension('diff_match_patch',
+module1 = Extension('fast_diff_match_patch',
                     sources = ['interface.cpp'],
                     include_dirs = [],
                     libraries = [])
 
 setup(
-    name='diff_match_patch_python',
-    version='1.0.2',
+    name='fast_diff_match_patch',
+    version='2.0.0',
     description=u'A Python extension module that wraps Google\'s diff_match_patch C++ implementation for very fast string comparisons. Version 1.0.2 fixes a build issue on Macs.',
     long_description=open("README.rst").read(),
     author=u'Joshua Tauberer',


Test patch:
diff --git a/tests/test_diff.py b/tests/test_diff.py
index 3313c3a..f0f23a5 100644
--- a/tests/test_diff.py
+++ b/tests/test_diff.py
@@ -3,7 +3,7 @@
 import sys
 import unittest
 
-import diff_match_patch
+import fast_diff_match_patch as diff_match_patch
 
 if sys.version_info[0] == 3:
     diff = diff_match_patch.diff
diff --git a/tests/test_match.py b/tests/test_match.py
index c20055e..281fc16 100644
--- a/tests/test_match.py
+++ b/tests/test_match.py
@@ -3,7 +3,7 @@
 import unittest
 import sys
 
-import diff_match_patch
+import fast_diff_match_patch as diff_match_patch
 
 if sys.version_info[0] == 3:
     diff = diff_match_patch.diff