浏览代码

Create symlink automatically for packaging

Matthew Wang 11 年前
父节点
当前提交
661acfd3cb
共有 4 个文件被更改,包括 37 次插入29 次删除
  1. 2
    5
      Makefile
  2. 27
    22
      README.rst
  3. 8
    1
      setup.py
  4. 0
    1
      src/cdiff

+ 2
- 5
Makefile 查看文件

@@ -3,7 +3,7 @@
3 3
 TESTS = git svn crlf strange
4 4
 TESTPYPI = http://testpypi.python.org/pypi
5 5
 
6
-.PHONY: dogfood test $(TESTS) clean dist
6
+.PHONY: dogfood test $(TESTS) clean dist-test dist
7 7
 
8 8
 dogfood:
9 9
 	src/cdiff.py -s
@@ -21,14 +21,11 @@ $(TESTS):
21 21
 	python3 src/cdiff.py tests/$@.diff | diff -u tests/$@.diff -
22 22
 
23 23
 clean:
24
-	rm -rf MANIFEST build/ cdiff.egg-info/ dist/
24
+	rm -rf src/cdiff MANIFEST build/ cdiff.egg-info/ dist/
25 25
 
26 26
 dist-test:
27 27
 	./setup.py build sdist upload -r $(TESTPYPI)
28 28
 
29
-install-test:
30
-	pip install -r $(TESTPYPI)
31
-
32 29
 dist:
33 30
 	./setup.py build sdist upload
34 31
 

+ 27
- 22
README.rst 查看文件

@@ -16,32 +16,37 @@ with **auto pager**.  Requires python (>= 2.5.0) and ``less``.
16 16
 Installation
17 17
 ------------
18 18
 
19
-Cdiff is not in PyPI yet, so far you could download the script directly or use
20
-the ``setup.py`` to install.
21
- 
22
-**Download directly**
19
+**Install with pip**
23 20
 
24
-Save `src/cdiff.py <https://raw.github.com/ymattw/cdiff/master/src/cdiff.py>` to
25
-whatever directory which is in your ``$PATH``, for example, ``$HOME/bin`` is in
26
-my ``$PATH``, so I save the script there and name as ``cdiff``.
21
+Cdiff is already listed on `PyPI <http://pypi.python.org/pypi/cdiff>`, you can
22
+install with ``pip`` if you have the tool.
27 23
 
28
-.. code:: shell
29
-
30
-    curl -ksS https://raw.github.com/ymattw/cdiff/master/src/cdiff.py > ~/bin/cdiff
31
-    chmod +x ~/bin/cdiff
24
+.. code:: sh
25
+ 
26
+    sudo pip install cdiff
32 27
 
33
-**Install with the setup.py**
28
+**Install with setup.py**
34 29
 
35
-You can run the setup.py from the source to install ``cdiff`` to system wide
36
-directory.
30
+You can also run the setup.py from the source if you don't have ``pip``.
37 31
 
38
-.. code:: shell
32
+.. code:: sh
39 33
 
40 34
     git clone https://github.com/ymattw/cdiff.git
41 35
     cd cdiff
42 36
     sudo ./setup.py install
43 37
 
44
-This usually installs it as ``/usr/local/bin/cdiff``.
38
+**Download directly**
39
+
40
+Both ``pip`` and ``setup.py`` installs cdiff to system wide directory, if you
41
+want a minimal tool without the boring external dependencies (like me), just
42
+save `src/cdiff.py <https://raw.github.com/ymattw/cdiff/master/src/cdiff.py>` to
43
+whatever directory which is in your ``$PATH``, for example, ``$HOME/bin`` is
44
+in my ``$PATH``, so I save the script there and name as ``cdiff``.
45
+
46
+.. code:: sh
47
+
48
+    curl -ksS https://raw.github.com/ymattw/cdiff/master/src/cdiff.py > ~/bin/cdiff
49
+    chmod +x ~/bin/cdiff
45 50
 
46 51
 Usage
47 52
 -----
@@ -57,7 +62,7 @@ Show usage::
57 62
 
58 63
 View a diff (patch) file:
59 64
 
60
-.. code:: shell
65
+.. code:: sh
61 66
 
62 67
     cdiff foo.patch             # view colored incremental udiff
63 68
     cdiff foo.patch -s          # view side by side
@@ -65,7 +70,7 @@ View a diff (patch) file:
65 70
 
66 71
 Read diff from local modification in a svn, git, or hg workspace:
67 72
 
68
-.. code:: shell
73
+.. code:: sh
69 74
 
70 75
     cd proj-workspace
71 76
     cdiff
@@ -74,15 +79,15 @@ Read diff from local modification in a svn, git, or hg workspace:
74 79
 
75 80
 Pipe in a diff:
76 81
 
77
-.. code:: shell
82
+.. code:: sh
78 83
 
79
-    svn diff -r PREV | cdiff -s
80 84
     git log -p -2 | cdiff -s
81
-    git show <commit> | cdiff -s
85
+    git show 15bfa56 | cdiff -s
86
+    svn diff -r PREV | cdiff -s
82 87
 
83 88
 Redirect output to another patch file is safe:
84 89
 
85
-.. code:: shell
90
+.. code:: sh
86 91
 
87 92
     svn diff | cdiff -s > my.patch
88 93
 

+ 8
- 1
setup.py 查看文件

@@ -2,13 +2,20 @@
2 2
 
3 3
 from __future__ import with_statement
4 4
 from distutils.core import setup
5
+import os
6
+
7
+# Create symlink so that to use 'scripts' w/o '.py'
8
+link_name = 'src/cdiff'
9
+if os.path.exists(link_name):
10
+    os.unlink(link_name)
11
+os.symlink('cdiff.py', 'src/cdiff')
5 12
 
6 13
 with open('README.rst') as doc:
7 14
     long_description = doc.read()
8 15
 
9 16
 setup(
10 17
     name = 'cdiff',
11
-    version = '0.0.1',
18
+    version = '0.0.2',
12 19
     author = 'Matthew Wang',
13 20
     author_email = 'mattwyl@gmail.com',
14 21
     license = 'BSD-3',

+ 0
- 1
src/cdiff 查看文件

@@ -1 +0,0 @@
1
-cdiff.py