Added win_add2path.py to Tools/scripts/

Added builddoc.bat to Doc/
This commit is contained in:
Christian Heimes 2008-01-18 11:58:50 +00:00
parent b222bbc321
commit bd865db90c
3 changed files with 113 additions and 0 deletions

52
Doc/builddoc.bat Normal file
View File

@ -0,0 +1,52 @@
@echo off
setlocal
set SVNROOT=http://svn.python.org/projects
if "%PYTHON%" EQU "" set PYTHON=python25
if "%1" EQU "" goto help
if "%1" EQU "html" goto build
if "%1" EQU "htmlhelp" goto build
if "%1" EQU "web" goto build
if "%1" EQU "webrun" goto webrun
if "%1" EQU "checkout" goto checkout
if "%1" EQU "update" goto update
:help
echo HELP
echo.
echo builddoc checkout
echo builddoc update
echo builddoc html
echo builddoc htmlhelp
echo builddoc web
echo builddoc webrun
echo.
goto end
:checkout
svn co %SVNROOT%/doctools/trunk/sphinx tools/sphinx
svn co %SVNROOT%/external/docutils-0.4/docutils tools/docutils
svn co %SVNROOT%/external/Pygments-0.9/pygments tools/pygments
goto end
:update
svn update tools/sphinx
svn update tools/docutils
svn update tools/pygments
goto end
:build
if not exist build mkdir build
if not exist build\%1 mkdir build\%1
if not exist build\doctrees mkdir build\doctrees
cmd /C %PYTHON% tools\sphinx-build.py -b%1 -dbuild\doctrees . build\%1
if "%1" EQU "htmlhelp" "%ProgramFiles%\HTML Help Workshop\hhc.exe" build\htmlhelp\pydoc.hhp
goto end
:webrun
set PYTHONPATH=tools
%PYTHON% -m sphinx.web build\web
goto end
:end

View File

@ -1196,6 +1196,10 @@ Tests
Tools
-----
- Tools/scripts/win_add2path.py was added. The simple script modifes the
PATH environment var of the HKCU tree and adds the python bin and script
directory.
- Tools/18n/pygettext.py was added to the list of scripts installed by
Tools/scripts/setup.py (tracker item 642309).

View File

@ -0,0 +1,57 @@
"""Add Python to the search path on Windows
This is a simple script to add Python to the Windows search path. It
modifies the current user (HKCU) tree of the registry.
Copyright (c) 2008 by Christian Heimes <christian@cheimes.de>
Licensed to PSF under a Contributor Agreement.
"""
import sys
import site
import os
import _winreg
HKCU = _winreg.HKEY_CURRENT_USER
ENV = "Environment"
PATH = "PATH"
DEFAULT = u"%PATH%"
def modify():
pythonpath = os.path.dirname(os.path.normpath(sys.executable))
scripts = os.path.join(pythonpath, "Scripts")
appdata = os.environ["APPDATA"]
if hasattr(site, "USER_SITE"):
userpath = site.USER_SITE.replace(appdata, "%APPDATA%")
userscripts = os.path.join(userpath, "Scripts")
else:
userscripts = None
with _winreg.CreateKey(HKCU, ENV) as key:
try:
envpath = _winreg.QueryValueEx(key, PATH)[0]
except WindowsError:
envpath = DEFAULT
paths = [envpath]
for path in (pythonpath, scripts, userscripts):
if path and path not in envpath and os.path.isdir(path):
paths.append(path)
envpath = os.pathsep.join(paths)
_winreg.SetValueEx(key, PATH, 0, _winreg.REG_EXPAND_SZ, envpath)
return paths, envpath
def main():
paths, envpath = modify()
if len(paths) > 1:
print "Path(s) added:"
print '\n'.join(paths[1:])
else:
print "No path was added"
print "\nPATH is now:\n%s\n" % envpath
print "Expanded:"
print _winreg.ExpandEnvironmentStrings(envpath)
if __name__ == '__main__':
main()