Skip to content

Commit a727a8d

Browse files
committed
diff.py: replaced '-->' by '?' for notifying upgrade version infos
0 parents  commit a727a8d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+5190
-0
lines changed

.hgignore

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
\.pyc$
2+
\.pyo$
3+
\.exe$
4+
\.settings$
5+
\.spyderproject$
6+
\.ropeproject$
7+
\.orig$
8+
\.DS_Store$
9+
^build/
10+
^dist/
11+
^bin/
12+
^tools/gnuwin32/
13+
^tools/TortoiseHg/
14+
^tools/WinMerge/
15+
^winpython.egg-info/
16+
MANIFEST$
17+
\Thumbs.db

MANIFEST.in

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
recursive-include winpython *.svg *.png *.ini
2+
recursive-include tools *.*
3+
include scripts/*
4+
include MANIFEST.in
5+
include README

README

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
WinPython tools
2+
===============
3+
4+
Copyright © 2012 Pierre Raybaut
5+
Licensed under the terms of the MIT License
6+
(see winpython/__init__.py for details)
7+
8+
9+
Overview
10+
11+
WinPython is a portable distribution of the Python programming
12+
language for Windows (http://code.google.com/p/winpython).
13+
14+
This is the `winpython` Python package, not the distribution itself.
15+
It includes two main features:
16+
17+
The WinPython Package Manager (WPPM): let you install/uninstall
18+
to your WinPython distribution any standard Python package built
19+
with distutils (e.g. "dummypackage-2.1.win-amd64-py2.7.‌exe")
20+
21+
The WinPython build toolchain: make.py is the script used to
22+
build a WinPython distribution from (almost) scratch.
23+
24+
Dependencies
25+
26+
Python >=2.6 or Python >=3.0
27+
PyQt4 >=4.5 or PySide >=1.1.1 (PyQt4 is recommended)
28+
spyderlib >=2.1
29+
guidata >=1.6
30+
31+
Requirements
32+
33+
7zip (directory has to be available in PATH)
34+
NSIS:
35+
* "Large strings" special build (http://nsis.sourceforge.net/Special_Builds)
36+
* with TextReplace plugin installed
37+
Microsoft Visual C++ DLLs -- the versions have to be the same as the
38+
one used to build your Python installation. For example, when using the
39+
official Python 2.7 build, you will need v9.0.21022.8:
40+
* 32bit: http://www.microsoft.com/en-us/download/details.aspx?id=29
41+
* 64bit: http://www.microsoft.com/en-us/download/confirmation.aspx?id=15336
42+
43+
Installation
44+
45+
From the source package (see section 'Building dependencies'), you may
46+
install WinPython using the integrated setup.py script based on Python
47+
standard library `distutils` with the following command:
48+
`python setup.py install`
49+
50+
Note that `distutils` does *not* uninstall previous versions of Python
51+
packages: it simply copies files on top of an existing installation.
52+
When using this command, it is thus highly recommended to uninstall
53+
manually any previous version of WinPython by removing the associated
54+
directory ('winpython' in your site-packages directory).
55+
56+
From the Python package index, you may simply install WinPython *and*
57+
upgrade an existing installation using `pip`:
58+
http://pypi.python.org/pypi
59+
60+
But the easiest way to install the last stable release of WinPython is
61+
by using an executable installer: http://winpython.googlecode.com
62+
63+
More informations
64+
65+
Downloads, bug reports and feature requests:
66+
http://code.google.com/p/winpython/
67+
Discussions:
68+
http://groups.google.com/group/winpython

build_dist.bat

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
rmdir /S /Q build
2+
rmdir /S /Q dist
3+
python setup.py build bdist_wininst --plat-name=win32
4+
python setup.py build bdist_wininst --plat-name=win-amd64
5+
pause

checklist.txt

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
01. Extract Python python-2.7.3.amd64.msi installer to the python-2.7.3.amd64 directory
2+
02. Rename python.exe to python-2.7.3.amd64.exe
3+
03. Create the python.bat, adding necessary env vars and changing PATH
4+
04. Extract PyQt NSIS installer
5+
05. Copy the qt.conf file to python-2.7.3.amd64 directory
6+
06. Add Qt docs to the appropriate directory
7+
07. Add all library docs in Python's Doc folder

diff.py

+177
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Copyright © 2013 Pierre Raybaut
4+
# Licensed under the terms of the MIT License
5+
# (see winpython/__init__.py for details)
6+
7+
"""
8+
WinPython diff script
9+
10+
Created on Tue Jan 29 11:56:54 2013
11+
"""
12+
13+
from __future__ import print_function, with_statement
14+
15+
import os.path as osp
16+
import re
17+
18+
# Local imports
19+
from winpython import utils
20+
21+
22+
class Package(object):
23+
PATTERN = r'\|\| \[([a-zA-Z\-\:\/\.\_0-9]*) ([^\]\ ]*)] \|\| ([^\|]*) \|\| ([^\|]*) \|\|'
24+
def __init__(self):
25+
self.name = None
26+
self.version = None
27+
self.description = None
28+
self.url = None
29+
30+
def __str__(self):
31+
text = "%s %s" % (self.name, self.version)
32+
text += "\r\n%s\r\nWebsite: %s" % (self.description, self.url)
33+
return text
34+
35+
def from_text(self, text):
36+
match = re.match(self.PATTERN, text)
37+
self.url, self.name, self.version, self.description = match.groups()
38+
39+
def to_wiki(self):
40+
return " * [%s %s] %s (%s)\r\n" % (self.url, self.name,
41+
self.version, self.description)
42+
43+
def upgrade_wiki(self, other):
44+
assert self.name == other.name
45+
return " * [%s %s] %s → %s (%s)\r\n" % (self.url, self.name,
46+
other.version, self.version, self.description)
47+
48+
49+
def get_basedir(version, rootdir=None):
50+
"""Return basedir from WinPython version"""
51+
rootdir = rootdir if rootdir is not None else utils.ROOT_DIR
52+
assert rootdir is not None, "The *rootdir* directory must be specified"
53+
return osp.join(rootdir, 'basedir%s' % version[::2][:2])
54+
55+
56+
class PackageIndex(object):
57+
WINPYTHON_PATTERN = r'== WinPython ([0-9\.a-zA-Z]*) =='
58+
TOOLS_LINE = '=== Tools ==='
59+
PYTHON_PACKAGES_LINE = '=== Python packages ==='
60+
def __init__(self, version, rootdir=None):
61+
self.version = version
62+
self.other_packages = {}
63+
self.python_packages = {}
64+
basedir = get_basedir(version, rootdir=rootdir)
65+
self.from_file(basedir)
66+
67+
def from_file(self, basedir):
68+
fname = osp.join(basedir, 'build', 'WinPython-%s.txt' % self.version)
69+
with open(fname, 'rb') as fdesc:
70+
text = fdesc.read()
71+
self.from_text(text)
72+
73+
def from_text(self, text):
74+
version = re.match(self.WINPYTHON_PATTERN, text).groups()[0]
75+
assert version == self.version
76+
tools_flag = False
77+
python_flag = False
78+
for line in text.splitlines():
79+
if line:
80+
if line == self.TOOLS_LINE:
81+
tools_flag = True
82+
continue
83+
elif line == self.PYTHON_PACKAGES_LINE:
84+
tools_flag = False
85+
python_flag = True
86+
continue
87+
if tools_flag or python_flag:
88+
package = Package()
89+
package.from_text(line)
90+
if tools_flag:
91+
self.other_packages[package.name] = package
92+
else:
93+
self.python_packages[package.name] = package
94+
95+
96+
def diff_package_dicts(dict1, dict2):
97+
"""Return difference between package dict1 and package dict2"""
98+
text = ""
99+
set1, set2 = set(dict1.keys()), set(dict2.keys())
100+
# New packages
101+
new = set2 - set1
102+
if new:
103+
text += "New packages:\r\n\r\n"
104+
for name in new:
105+
package = dict2[name]
106+
text += package.to_wiki()
107+
text += '\r\n'
108+
# Upgraded packages
109+
upgraded_list = []
110+
for name in set1 & set2:
111+
package1 = dict1[name]
112+
package2 = dict2[name]
113+
if package1.version != package2.version:
114+
upgraded_list.append(package2.upgrade_wiki(package1))
115+
if upgraded_list:
116+
text += "Upgraded packages:\r\n\r\n%s\r\n" % "".join(upgraded_list)
117+
# Removed packages
118+
removed = set1 - set2
119+
if removed:
120+
text += "Removed packages:\r\n\r\n"
121+
for name in removed:
122+
package = dict1[name]
123+
text += package.to_wiki()
124+
text += '\r\n'
125+
return text
126+
127+
128+
def compare_package_indexes(version1, version2, rootdir=None):
129+
"""Compare two package index Wiki pages"""
130+
text = '\r\n'.join(["== History of changes for WinPython %s ==" % version2,
131+
"", "The following changes were made to WinPython "\
132+
"distribution since version %s." % version1, "", ""])
133+
pi1 = PackageIndex(version1, rootdir=rootdir)
134+
pi2 = PackageIndex(version2, rootdir=rootdir)
135+
tools_text = diff_package_dicts(pi1.other_packages, pi2.other_packages)
136+
if tools_text:
137+
text += PackageIndex.TOOLS_LINE + '\r\n\r\n' + tools_text
138+
py_text = diff_package_dicts(pi1.python_packages, pi2.python_packages)
139+
if py_text:
140+
text += PackageIndex.PYTHON_PACKAGES_LINE + '\r\n\r\n' + py_text
141+
text += '----\r\n'
142+
return text
143+
144+
145+
def write_changelog(version1, version2, rootdir=None):
146+
"""Write changelog between version1 and version2 of WinPython"""
147+
text = compare_package_indexes(version1, version2, rootdir=rootdir)
148+
basedir = get_basedir(version1, rootdir=rootdir)
149+
fname = osp.join(basedir, 'build', 'WinPython-%s_History.txt' % version2)
150+
with open(fname, 'wb') as fdesc:
151+
fdesc.write(text)
152+
153+
154+
def test_parse_package_index_wiki(version, rootdir=None):
155+
"""Parse the package index Wiki page"""
156+
pi = PackageIndex(version, rootdir=rootdir)
157+
utils.print_box("WinPython %s:" % pi.version)
158+
utils.print_box("Tools:")
159+
for package in pi.other_packages.values():
160+
print(package)
161+
print('')
162+
utils.print_box("Python packages:")
163+
for package in pi.python_packages.values():
164+
print(package)
165+
print('')
166+
167+
168+
def test_compare(basedir, version1, version2):
169+
print(compare_package_indexes(basedir, version1, version2))
170+
171+
172+
if __name__ == '__main__':
173+
# test_parse_package_index_wiki('2.7.3.3')
174+
# print(compare_package_indexes('2.7.3.1', '2.7.3.3'))
175+
write_changelog('2.7.3.1', '2.7.3.2')
176+
write_changelog('2.7.3.2', '2.7.3.3')
177+
write_changelog('3.3.0.0beta1', '3.3.0.0beta2')

0 commit comments

Comments
 (0)