[py-svn] r11044 - in py/dist: . py py/misc
hpk at codespeak.net
hpk at codespeak.net
Sat Apr 23 00:05:49 CEST 2005
Author: hpk
Date: Sat Apr 23 00:05:49 2005
New Revision: 11044
Added:
py/dist/py/misc/_dist.py
py/dist/setup.py
Modified:
py/dist/ (props changed)
py/dist/py/__init__.py
py/dist/py/initpkg.py
Log:
preliminary distutils setup.py support slightly hackish but
that may just be neccessary fluff, who knows.
currently the setup.py installs all .svn files which i am not
100% sure yet that it is a good idea.
However, i like that i can just go to the installed package
and issue "svn st" and "svn info" and even "svn up". Also
when someone patches things on his system he can simply sent a
"svn diff" for making a patch. and so on. And what does disk
space cost these days?
Oh, and c-extension modules are not handled at all yet.
and the distutils hacks could use a few tests, actually.
well, but it's a start, i guess.
Modified: py/dist/py/__init__.py
==============================================================================
--- py/dist/py/__init__.py (original)
+++ py/dist/py/__init__.py Sat Apr 23 00:05:49 2005
@@ -1,5 +1,25 @@
+"""
+the py lib is a development support library featuring
+py.test, an interactive testing tool which supports
+unittesting and ReST-integrity testing with practically
+no boilerplate.
+"""
from initpkg import initpkg
-initpkg(__name__, exportdefs = {
+
+initpkg(__name__,
+ name = "py",
+ description = "py.test and the py lib",
+ version = "0.8.0-prealpha",
+ url = "http://codespeak.net/py",
+ download_url = "http://codespeak.net/download/py-0.8.0-pre-alpha.tgz",
+ license = "MIT license",
+ platforms = ['unix', 'linux', 'cygwin'],
+ author = "holger krekel & others",
+ author_email = "hpk at merlinux.de",
+ long_description = globals()['__doc__'],
+
+ exportdefs = {
+ '_dist.setup' : ('./misc/_dist.py', 'setup'),
# helpers for use from test functions or collectors
'test.raises' : ('./test/raises.py', 'raises'),
Modified: py/dist/py/initpkg.py
==============================================================================
--- py/dist/py/initpkg.py (original)
+++ py/dist/py/initpkg.py Sat Apr 23 00:05:49 2005
@@ -204,10 +204,12 @@
# Bootstrap Virtual Module Hierarchy
# ---------------------------------------------------
-def initpkg(pkgname, exportdefs):
+def initpkg(pkgname, exportdefs, **kw):
#print "initializing package", pkgname
# bootstrap Package object
pkg = Package(pkgname, exportdefs)
+ for name, value in kw.items():
+ setattr(pkg, name, value)
seen = { pkgname : pkg.module }
deferred_imports = []
Added: py/dist/py/misc/_dist.py
==============================================================================
--- (empty file)
+++ py/dist/py/misc/_dist.py Sat Apr 23 00:05:49 2005
@@ -0,0 +1,112 @@
+import py
+import sys
+from distutils import sysconfig
+from distutils import core
+
+
+class Params:
+ """ a crazy hack to convince distutils to please
+ install all of our files inside the package.
+ """
+ _sitepackages = py.path.local(sysconfig.get_python_lib())
+ def __init__(self, pkgmod):
+ name = pkgmod.__name__
+ self._pkgdir = py.path.local(pkgmod.__file__).dirpath()
+ self._rootdir = self._pkgdir.dirpath()
+ self._pkgtarget = self._sitepackages.join(name)
+ self._datadict = {}
+ self.packages = []
+ self.scripts = []
+ self.hacktree()
+ self.data_files = self._datadict.items()
+ self.data_files.sort()
+ self.packages.sort()
+ self.scripts.sort()
+
+ def hacktree(self):
+ for p in self._pkgdir.visit():
+ if p.check(file=1):
+ if p.ext in ('.pyc', '.pyo'):
+ continue
+ if p.ext == '.py':
+ self.addpythonfile(p)
+ elif p.dirpath().basename == 'bin':
+ self.scripts.append(p.relto(self._rootdir))
+ self.adddatafile(p)
+ else:
+ self.adddatafile(p)
+ else:
+ if not p.listdir():
+ self.adddatafile(p.ensure('dummy'))
+
+ def adddatafile(self, p):
+ if p.ext in ('.pyc', 'pyo'):
+ return
+ target = self._pkgtarget.join(p.dirpath().relto(self._pkgdir))
+ l = self._datadict.setdefault(str(target), [])
+ l.append(p.relto(self._rootdir))
+
+ def addpythonfile(self, p):
+ parts = p.parts()
+ for above in p.parts(reverse=True)[1:]:
+ if self._pkgdir.relto(above):
+ dottedname = p.dirpath().relto(self._rootdir).replace(p.sep, '.')
+ if dottedname not in self.packages:
+ self.packages.append(dottedname)
+ break
+ if not above.join('__init__.py').check():
+ self.adddatafile(p)
+ #print "warning, added data file", p
+ break
+
+#if sys.platform != 'win32':
+# scripts.remove('py/bin/pytest.cmd')
+#else:
+# scripts.remove('py/bin/py.test')
+#
+
+# helpers:
+def checknonsvndir(p):
+ if p.basename != '.svn' and p.check(dir=1):
+ return True
+
+def dump(params):
+ print "packages"
+ for x in params.packages:
+ print "package ", x
+ print
+ print "scripts"
+ for x in params.scripts:
+ print "script ", x
+ print
+
+ print "data files"
+ for x in params.data_files:
+ print "data file ", x
+ print
+
+def setup(pkg):
+ """ invoke distutils on a given package.
+ """
+ params = Params(pkg)
+ #dump(params)
+ source = getattr(pkg, '__package__', pkg)
+
+ kw = {}
+ namelist = list(core.setup_keywords)
+ namelist.extend(['packages', 'scripts', 'data_files'])
+ for name in namelist:
+ try:
+ kw[name] = getattr(source, name,
+ getattr(params, name))
+ except AttributeError:
+ pass
+ #print "couldn't find", name
+
+ #script_args = sys.argv[1:]
+ #if 'install' in script_args:
+ # script_args = ['--quiet'] + script_args
+ # #print "installing", py
+
+ #py.std.pprint.pprint(kw)
+ core.setup(**kw)
Added: py/dist/setup.py
==============================================================================
--- (empty file)
+++ py/dist/setup.py Sat Apr 23 00:05:49 2005
@@ -0,0 +1,2 @@
+import py
+py._dist.setup(py)
More information about the pytest-commit
mailing list