Patchwork setup: move cffi stuff to mercurial/cffi

login
register
mail settings
Submitter Jun Wu
Date Nov. 9, 2016, 10:10 p.m.
Message ID <ffa2f1f1fd81fc55bfd8.1478729423@x1c>
Download mbox | patch
Permalink /patch/17431/
State Accepted
Headers show

Comments

Jun Wu - Nov. 9, 2016, 10:10 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1478729310 0
#      Wed Nov 09 22:08:30 2016 +0000
# Node ID ffa2f1f1fd81fc55bfd8cf667fe900d31490b05f
# Parent  e81d72b4b0ae4a4155377c36f4ae974e524a41cd
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r ffa2f1f1fd81
setup: move cffi stuff to mercurial/cffi

This patch moves all setup*cffi stuff to mercurial/cffi to make the root
directory cleaner. The idea was from mpm [1]:

  > It seems like we could have a fair amount of cffi definitions, and
  > cluttering the root directory (or mercurial/) with them is probably not
  > a great long-term solution. We could probably add a cffi/ directory
  > under mercurial/ to parallel pure/.

[1]: https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-July/086442.html
Pierre-Yves David - Nov. 10, 2016, 12:17 a.m.
On 11/09/2016 10:10 PM, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark@fb.com>
> # Date 1478729310 0
> #      Wed Nov 09 22:08:30 2016 +0000
> # Node ID ffa2f1f1fd81fc55bfd8cf667fe900d31490b05f
> # Parent  e81d72b4b0ae4a4155377c36f4ae974e524a41cd
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r ffa2f1f1fd81
> setup: move cffi stuff to mercurial/cffi

Good idea, pushed.

thanks,

Patch

diff --git a/mercurial/cffi/__init__.py b/mercurial/cffi/__init__.py
new file mode 100644
diff --git a/setup_bdiff_cffi.py b/mercurial/cffi/bdiff.py
rename from setup_bdiff_cffi.py
rename to mercurial/cffi/bdiff.py
--- a/setup_bdiff_cffi.py
+++ b/mercurial/cffi/bdiff.py
@@ -6,5 +6,5 @@  import os
 ffi = cffi.FFI()
 ffi.set_source("_bdiff_cffi",
-    open(os.path.join(os.path.join(os.path.dirname(__file__), 'mercurial'),
+    open(os.path.join(os.path.join(os.path.dirname(__file__), '..'),
         'bdiff.c')).read(), include_dirs=['mercurial'])
 ffi.cdef("""
diff --git a/setup_mpatch_cffi.py b/mercurial/cffi/mpatch.py
rename from setup_mpatch_cffi.py
rename to mercurial/cffi/mpatch.py
--- a/setup_mpatch_cffi.py
+++ b/mercurial/cffi/mpatch.py
@@ -5,5 +5,5 @@  import os
 
 ffi = cffi.FFI()
-mpatch_c = os.path.join(os.path.join(os.path.dirname(__file__), 'mercurial',
+mpatch_c = os.path.join(os.path.join(os.path.dirname(__file__), '..',
                                      'mpatch.c'))
 ffi.set_source("_mpatch_cffi", open(mpatch_c).read(),
diff --git a/setup_osutil_cffi.py b/mercurial/cffi/osutil.py
rename from setup_osutil_cffi.py
rename to mercurial/cffi/osutil.py
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -319,12 +319,14 @@  class hgbuildpy(build_py):
             self.distribution.ext_modules = []
         elif self.distribution.cffi:
-            import setup_mpatch_cffi
-            import setup_bdiff_cffi
-            exts = [setup_mpatch_cffi.ffi.distutils_extension(),
-                    setup_bdiff_cffi.ffi.distutils_extension()]
+            from mercurial.cffi import (
+                bdiff,
+                mpatch,
+            )
+            exts = [mpatch.ffi.distutils_extension(),
+                    bdiff.ffi.distutils_extension()]
             # cffi modules go here
             if sys.platform == 'darwin':
-                import setup_osutil_cffi
-                exts.append(setup_osutil_cffi.ffi.distutils_extension())
+                from mercurial.cffi import osutil
+                exts.append(osutil.ffi.distutils_extension())
             self.distribution.ext_modules = exts
         else: