Skip to content

Commit fa02e3b

Browse files
committed
1 parent 46579c2 commit fa02e3b

File tree

10 files changed

+297
-0
lines changed

10 files changed

+297
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Metadata-Version: 1.0
2+
Name: setuptools-darcs
3+
Version: 1.2.11
4+
Summary: setuptools plugin for darcs
5+
Home-page: http://tahoe-lafs.org/trac/setuptools_darcs
6+
Author: Zooko O'Whielacronx
7+
Author-email: [email protected]
8+
License: BSD
9+
Description: UNKNOWN
10+
Keywords: distutils setuptools setup darcs
11+
Platform: UNKNOWN
12+
Classifier: Framework :: Setuptools Plugin
13+
Classifier: Development Status :: 5 - Production/Stable
14+
Classifier: License :: OSI Approved :: BSD License
15+
Classifier: License :: DFSG approved
16+
Classifier: Intended Audience :: Developers
17+
Classifier: Operating System :: Microsoft
18+
Classifier: Operating System :: Microsoft :: Windows
19+
Classifier: Operating System :: Unix
20+
Classifier: Operating System :: POSIX :: Linux
21+
Classifier: Operating System :: POSIX
22+
Classifier: Operating System :: MacOS :: MacOS X
23+
Classifier: Operating System :: Microsoft :: Windows :: Windows NT/2000
24+
Classifier: Operating System :: OS Independent
25+
Classifier: Natural Language :: English
26+
Classifier: Programming Language :: Python
27+
Classifier: Programming Language :: Python :: 2
28+
Classifier: Programming Language :: Python :: 2.4
29+
Classifier: Programming Language :: Python :: 2.5
30+
Classifier: Programming Language :: Python :: 2.6
31+
Classifier: Topic :: Utilities
32+
Classifier: Topic :: Software Development :: Libraries
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
README.txt
3+
setup.cfg
4+
setup.py
5+
setuptools_darcs/__init__.py
6+
setuptools_darcs/_version.py
7+
setuptools_darcs/setuptools_darcs.py
8+
setuptools_darcs.egg-info/PKG-INFO
9+
setuptools_darcs.egg-info/SOURCES.txt
10+
setuptools_darcs.egg-info/dependency_links.txt
11+
setuptools_darcs.egg-info/entry_points.txt
12+
setuptools_darcs.egg-info/not-zip-safe
13+
setuptools_darcs.egg-info/top_level.txt
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[setuptools.file_finders]
2+
darcs = setuptools_darcs.setuptools_darcs:find_files_for_darcs
3+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
setuptools_darcs
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
__version__ = "unknown"
2+
try:
3+
from _version import __version__
4+
except ImportError:
5+
# We're running in a tree that hasn't run darcsver from the pyutil library,
6+
# and didn't come with a _version.py, so we don't know what our version
7+
# is. This should not happen very often.
8+
pass
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
# This is the version of this tree, as created by setup.py darcsver from the Darcs patch
3+
# information: the main version number is taken from the most recent release
4+
# tag. If some patches have been added since the last release, this will have a
5+
# -NN "build number" suffix, or else a -rNN "revision number" suffix. Please see
6+
# pyutil.version_class for a description of what the different fields mean.
7+
8+
verstr = "1.2.11"
9+
try:
10+
from pyutil.version_class import Version as pyutil_Version
11+
__version__ = pyutil_Version(verstr)
12+
except (ImportError, ValueError):
13+
# Maybe there is no pyutil installed, or this may be an older version of
14+
# pyutil.version_class which does not support SVN-alike revision numbers.
15+
from distutils.version import LooseVersion as distutils_Version
16+
__version__ = distutils_Version(verstr)
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import os, re
2+
3+
from subprocess import Popen, PIPE
4+
5+
THISDIR_RE=re.compile("What's new in \"(.*)\"")
6+
7+
def exec_darcs(darcscmd):
8+
cmd = ['darcs'] + darcscmd
9+
try:
10+
p = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
11+
except EnvironmentError:
12+
cmd = ['realdarcs.exe'] + darcscmd
13+
p = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
14+
15+
output = p.communicate()[0]
16+
return (p.returncode, output)
17+
18+
def run_darcs_query_manifest():
19+
return exec_darcs(['query', 'manifest'])
20+
21+
def run_darcs_whatsnew_dot():
22+
return exec_darcs(['whatsnew', '.'])
23+
24+
def find_files_for_darcs(dirname):
25+
try:
26+
unused, whatsnewoutput = run_darcs_whatsnew_dot()
27+
queryretcode, queryoutput = run_darcs_query_manifest()
28+
except EnvironmentError:
29+
if not os.path.exists('PKG-INFO'):
30+
from distutils import log
31+
log.warn("Unable to execute darcs -- if you are building a package with 'setup.py sdist', 'setup.py bdist_egg', or other package-building commands, then the resulting package might be missing some files. If you are not building a package then you can ignore this warning.")
32+
# Oh well -- just return None.
33+
return
34+
35+
if queryretcode != 0:
36+
if not os.path.exists('PKG-INFO'):
37+
from distutils import log
38+
log.warn("Failure to get the list of managed files from darcs -- if you are building a package with 'setup.py sdist', 'setup.py bdist_egg', or other package-building commands, then the resulting package might be missing some files. If you are not building a package then you can ignore this warning.")
39+
# Oh well -- just return None.
40+
return
41+
42+
# We got output.
43+
mo = THISDIR_RE.search(whatsnewoutput)
44+
if mo:
45+
curdirname = mo.group(1)
46+
while curdirname.endswith('/'):
47+
curdirname = curdirname[:-1]
48+
curdirname += "/"
49+
else:
50+
curdirname = ""
51+
52+
# Prepend this directory.
53+
rel_to_repo_dirname = curdirname + dirname
54+
55+
# Normalize rel_to_repo_dirname from local form to the form that setuptools uses to the form that "darcs query manifest" outputs (unix form).
56+
rel_to_repo_dirname = rel_to_repo_dirname.replace('\\', '/')
57+
while rel_to_repo_dirname.endswith('/'):
58+
rel_to_repo_dirname = rel_to_repo_dirname[:-1]
59+
60+
# Append a '/' to make sure we don't match "foobar" when rel_to_repo_dirname is "foo".
61+
if rel_to_repo_dirname:
62+
rel_to_repo_dirname += '/'
63+
64+
warn = True
65+
for fn in queryoutput.split('\n'):
66+
if fn == ".":
67+
continue
68+
if fn.startswith('./'):
69+
fn = fn[2:]
70+
if fn.startswith(rel_to_repo_dirname):
71+
fn = fn[len(rel_to_repo_dirname):]
72+
warn = False
73+
# We need to replace "/" by "\\" because setuptools can't includes web/*.xhtml files on Windows, due of path separator
74+
# This correct ticket #1033
75+
yield fn.replace('/', os.sep)
76+
77+
if warn and not os.path.exists('PKG-INFO'):
78+
from distutils import log
79+
log.warn("Didn't find any files in directory \"%s\" (full path: \"%s\") that were managed by darcs revision control -- if you are building a package with 'setup.py sdist', 'setup.py bdist_egg', or other package-building commands, then the resulting package might be missing some files. If you are not building a package then you can ignore this warning." % (dirname, os.path.abspath(rel_to_repo_dirname),))
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
2+
setuptools_darcs Manual
3+
=======================
4+
5+
About
6+
-----
7+
8+
This is a plugin for setuptools that integrates darcs. Once
9+
installed, Setuptools can be told to include in a package distribution
10+
all the files tracked by darcs. This is an alternative to explicit
11+
inclusion specifications with `MANIFEST.in`.
12+
13+
A distribution here refers to a package that you create using
14+
setup.py, ex:
15+
16+
python setup.py sdist
17+
python setup.py bdist_egg
18+
python setup.py bdist_rpm
19+
20+
This package was formerly known as setuptools_darcs_plugin. The name
21+
change is the result of an agreement by the setuptools plugin
22+
developers to provide a uniform naming convention.
23+
24+
25+
Installation
26+
------------
27+
28+
With easy_install:
29+
30+
easy_install setuptools_darcs
31+
32+
Alternative manual installation:
33+
34+
tar -zxvf setuptools_darcs-X.Y.Z.tar.gz
35+
cd setuptools_darcs-X.Y.Z
36+
python setup.py install
37+
38+
Where X.Y.Z is a version number.
39+
40+
Alternative to make a specific package use setuptools_darcs without
41+
installing setuptools_darcs into the system:
42+
43+
Put "setup_requires=['setuptools_darcs']" in the call to setup() in
44+
the package's setup.py file.
45+
46+
47+
Usage
48+
-----
49+
50+
To use this plugin, you must first package your python module with
51+
`setup.py` and use setuptools. The former is well documented in the
52+
distutils manual:
53+
54+
http://docs.python.org/dist/dist.html
55+
56+
To use setuptools instead of distutils, just edit `setup.py` and
57+
change
58+
59+
from distutils.core import setup
60+
61+
to
62+
63+
from setuptools import setup
64+
65+
When setuptools builds a source package, it always includes all files
66+
tracked by your revision control system, if it knows how to learn what
67+
those files are.
68+
69+
When setuptools builds a binary package, you can ask it to include all
70+
files tracked by your revision control system, by adding this argument
71+
to your invocation of `setup()`:
72+
73+
setup(...,
74+
include_package_data=True,
75+
...)
76+
77+
This plugin lets setuptools know what files are tracked by your darcs
78+
revision control tool. setuptools ships with support for cvs and
79+
subversion. Other plugins like this one are available for bzr, git,
80+
monotone, and mercurial, at least.
81+
82+
It might happen that you track files with your revision control system
83+
that you don't want to include in your packages. In that case, you
84+
can prevent setuptools from packaging those files with a directive in
85+
your `MANIFEST.in`, ex:
86+
87+
exclude .darcs-boringfile
88+
recursive-exclude images *.xcf *.blend
89+
90+
In this example, we prevent setuptools from packaging
91+
`.darcs-boringfile` and the Gimp and Blender source files found under
92+
the `images` directory.
93+
94+
Alternatively, files to exclude from the package can be listed in the
95+
`setup()` directive:
96+
97+
setup(...,
98+
exclude_package_data = {'': ['.darcs-boringfile'],
99+
'images': ['*.xcf', '*.blend']},
100+
...)
101+
102+
103+
Gotchas
104+
-------
105+
106+
If someone clones your darcs repository using darcs but does not
107+
install this plugin, then when they run a package building command
108+
they will not get all the right files. On the other hand if someone
109+
gets a source distribution that was created by "./setup.py sdist",
110+
then it will come with a list of all files, so they will not need
111+
darcs in order to build a distribution themselves.
112+
113+
You can make sure that anyone who uses your setup.py file has this
114+
plugin by adding a `setup_requires` argument.
115+
116+
setup_requires=[]
117+
# setuptools_darcs is required to produce complete distributions (such as with
118+
# "sdist" or "bdist_egg"), unless there is a ${PKG}.egg-info/SOURCES.txt file
119+
# present which contains a complete list of files that should be included in
120+
# distributions.
121+
# http://pypi.python.org/pypi/setuptools_darcs
122+
setup_requires.append('setuptools_darcs >= 1.1.0')
123+
124+
setup(...,
125+
setup_requires = setup_requires,
126+
...)
127+
128+
129+
References
130+
----------
131+
132+
How to distribute Python modules with Distutils:
133+
134+
http://docs.python.org/dist/dist.html
135+
136+
137+
Setuptools complete manual:
138+
139+
http://peak.telecommunity.com/DevCenter/setuptools
140+
141+
142+
Thanks to Yannick Gingras for providing the prototype for this
143+
README.txt.

0 commit comments

Comments
 (0)