Skip to content

Commit c8bb30e

Browse files
Merge pull request #11 from neogeographica/1.0
1.0
2 parents adcb3df + 457d03c commit c8bb30e

8 files changed

+125
-43
lines changed

.travis.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ language: python
22
python:
33
- "2.7"
44
- "2.6"
5-
# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors
6-
install: "pip install ."
7-
# command to run tests, e.g. python setup.py test
5+
install:
6+
- python setup.py sdist --formats=zip -k -d dist
7+
- find ./dist -iname "*.zip" -print0 | xargs -0 pip install
88
script: python setup.py test

HISTORY.rst

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
Changelog
2-
===================
2+
---------
3+
4+
- **1.0** (2013-11-21)
5+
6+
- Minor improvements to setup script, comments, and docs.
7+
- Support for "python -m expak".
8+
- Removal of race in subdirectory creation in nop_converter.
39

410
- **0.9** (2013-11-19)
511

Makefile

+19-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: test docs clean sdist infup publish winpublish
1+
.PHONY: test readme docs clean infup publish dist
22

33
test:
44
tox
@@ -7,25 +7,29 @@ sphinxbox/expak.py:
77
-mkdir sphinxbox
88
cd sphinxbox; ln -s ../expak.py .
99

10-
docs: sphinxbox/expak.py
11-
sphinx-apidoc -o docs sphinxbox
12-
cd docs; make html
10+
readme:
1311
python make_readme.py
1412

15-
sdist:
16-
python setup.py sdist
13+
docs: sphinxbox/expak.py readme
14+
sphinx-apidoc -o docs sphinxbox
15+
cd docs; make html
1716

18-
infup:
17+
infup: readme
1918
python setup.py register
2019

21-
publish:
22-
python setup.py sdist upload
20+
publish: infup
21+
python setup.py sdist --formats=gztar,zip upload
2322
python2.6 setup.py bdist_egg upload
2423
python2.7 setup.py bdist_egg upload
24+
python setup.py bdist_wininst -p win32 upload
25+
python setup.py bdist_wininst -p win-amd64 upload
2526

26-
winpublish:
27-
C:\Python26\python.exe setup.py bdist_wininst --target-version=2.6 upload
28-
C:\Python27\python.exe setup.py bdist_wininst --target-version=2.7 upload
27+
dist: readme
28+
python setup.py sdist --formats=gztar,zip
29+
python2.6 setup.py bdist_egg
30+
python2.7 setup.py bdist_egg
31+
python setup.py bdist_wininst -p win32
32+
python setup.py bdist_wininst -p win-amd64
2933

3034
clean:
3135
python setup.py clean
@@ -34,8 +38,11 @@ clean:
3438
-rm -rf htmlcov
3539
-rm -rf expak.egg-info
3640
-rm *.pyc
41+
-rm test/*.pyc
42+
-rm -rf test/__pycache__
3743
cd docs; make clean
3844

3945
superclean: clean
4046
-rm -rf *.egg
4147
-rm -rf sphinxbox
48+
-rm -rf .tox

README.rst

+19-8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _header_section:
2+
13
expak: Extract and process resources from Quake-style pak files
24
===============================================================
35

@@ -9,6 +11,8 @@ expak: Extract and process resources from Quake-style pak files
911
:target: http://travis-ci.org/neogeographica/expak
1012
:alt: build status of the master branch
1113

14+
.. _blurb_section:
15+
1216
*expak* is a GPLv3_-licensed tool to extract and optionally process resources
1317
from one or more `Quake-style pak files`_.
1418

@@ -23,8 +27,10 @@ outside of the standard Python modules.
2327
.. _Quake-style pak files: http://quakewiki.org/wiki/.pak
2428

2529

30+
.. _prerequisites_section:
31+
2632
Prerequisites
27-
=============
33+
-------------
2834

2935
It's a Python module and utility, so you need Python! If you don't have Python
3036
installed, `go get it`_. Note that while both Python 2 and Python 3 are
@@ -46,8 +52,10 @@ but you can ignore all of its complexity for the purposes of installing expak.
4652
.. _pip: http://www.pip-installer.org/en/latest
4753
.. _instructions for installing pip: http://www.pip-installer.org/en/latest/installing.html
4854

55+
.. _installation_section:
56+
4957
Installation
50-
============
58+
------------
5159

5260
The latest version of expak can always be installed or updated to via the `pip`_
5361
package manager, and this is the preferred method:
@@ -66,18 +74,21 @@ installed but can't or don't want to use pip:
6674
Finally, if you are on Windows, you could also choose to use an installer
6775
program, although the methods above work fine on Windows. Custom expak
6876
installers are included in the downloads list for expak
69-
`at the Python Package Index`_ (PyPI).
77+
`at the Python Package Index`_ (PyPI), and also `at Crate.io`_ or other PyPI
78+
mirrors.
7079

71-
If PyPI is down, the Windows installers and all the other distribution files
72-
are mirrored `at Crate.io`_ and other PyPI mirrors, and here at GitHub in the
73-
`releases for this repo`_.
80+
If PyPI and its mirrors are down, the Windows installers and other forms of
81+
distribution files (including source distribution) are mirrored
82+
`in the releases for the GitHub repo`_.
7483

7584
.. _at the Python Package Index: https://pypi.python.org/pypi/expak
7685
.. _at Crate.io: https://crate.io/packages/expak
77-
.. _releases for this repo: https://github.com/neogeographica/expak/releases
86+
.. _in the releases for the GitHub repo: https://github.com/neogeographica/expak/releases
87+
88+
.. _documentation_section:
7889

7990
Documentation
80-
=============
91+
-------------
8192

8293
- `expak module`_
8394
- `simple expak utility`_

README.rst.in

+18-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _header_section:
2+
13
expak: Extract and process resources from Quake-style pak files
24
===============================================================
35

@@ -9,10 +11,14 @@ expak: Extract and process resources from Quake-style pak files
911
:target: http://travis-ci.org/neogeographica/expak
1012
:alt: build status of the master branch
1113

14+
.. _blurb_section:
15+
1216
.. include:: docs/blurb.txt
1317

18+
.. _prerequisites_section:
19+
1420
Prerequisites
15-
=============
21+
-------------
1622

1723
It's a Python module and utility, so you need Python! If you don't have Python
1824
installed, `go get it`_. Note that while both Python 2 and Python 3 are
@@ -34,8 +40,10 @@ but you can ignore all of its complexity for the purposes of installing expak.
3440
.. _pip: http://www.pip-installer.org/en/latest
3541
.. _instructions for installing pip: http://www.pip-installer.org/en/latest/installing.html
3642

43+
.. _installation_section:
44+
3745
Installation
38-
============
46+
------------
3947

4048
The latest version of expak can always be installed or updated to via the `pip`_
4149
package manager, and this is the preferred method:
@@ -54,15 +62,18 @@ installed but can't or don't want to use pip:
5462
Finally, if you are on Windows, you could also choose to use an installer
5563
program, although the methods above work fine on Windows. Custom expak
5664
installers are included in the downloads list for expak
57-
`at the Python Package Index`_ (PyPI).
65+
`at the Python Package Index`_ (PyPI), and also `at Crate.io`_ or other PyPI
66+
mirrors.
5867

59-
If PyPI is down, the Windows installers and all the other distribution files
60-
are mirrored `at Crate.io`_ and other PyPI mirrors, and here at GitHub in the
61-
`releases for this repo`_.
68+
If PyPI and its mirrors are down, the Windows installers and other forms of
69+
distribution files (including source distribution) are mirrored
70+
`in the releases for the GitHub repo`_.
6271

6372
.. _at the Python Package Index: https://pypi.python.org/pypi/expak
6473
.. _at Crate.io: https://crate.io/packages/expak
65-
.. _releases for this repo: https://github.com/neogeographica/expak/releases
74+
.. _in the releases for the GitHub repo: https://github.com/neogeographica/expak/releases
75+
76+
.. _documentation_section:
6677

6778
.. include:: docs/rtdlinks.txt
6879

docs/rtdlinks.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Documentation
2-
=============
2+
-------------
33

44
- `expak module`_
55
- `simple expak utility`_

expak.py

+18-3
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,13 @@ def ogg_converter(orig_data, name):
9393
'nop_converter',
9494
'print_err']
9595

96-
__version__ = "0.9"
96+
__version__ = "1.0"
9797

9898

9999
import struct
100100
import sys
101101
import os
102+
import errno
102103

103104
PAK_FILE_SIGNATURE = "PACK"
104105
RESOURCE_NAME_LEN = 56
@@ -147,6 +148,8 @@ def read_header(instream):
147148
"""
148149
instream.seek(0)
149150
file_id = instream.read(len(PAK_FILE_SIGNATURE))
151+
# We don't raise IOError on a short read here... IOError is for use after
152+
# we've determined it's actually a pak file.
150153
if file_id != PAK_FILE_SIGNATURE:
151154
return None
152155
ftable_off = read_uint(instream)
@@ -377,8 +380,12 @@ def nop_converter(orig_data, name):
377380
"""
378381
real_path = os.path.join(*name.split("/"))
379382
out_dir = os.path.dirname(real_path)
380-
if out_dir and not os.path.exists(out_dir):
381-
os.makedirs(out_dir)
383+
if out_dir:
384+
try:
385+
os.makedirs(out_dir)
386+
except OSError, e:
387+
if e.errno != errno.EEXIST:
388+
raise
382389
with open(real_path, 'wb') as outstream:
383390
outstream.write(orig_data)
384391
return True
@@ -523,6 +530,11 @@ def simple_expak(argv=None):
523530
paks/resources as possible, it will exit with a status of 0 if no such
524531
exceptions were encountered, or 1 otherwise.
525532
533+
.. note::
534+
535+
:program:`python -m expak` behaves identically to
536+
:program:`simple_expak`.
537+
526538
"""
527539
# Normal use (when invoked from the utility) passes in None for argv, and
528540
# arguments are then taken from the command line. For testing however, other
@@ -554,3 +566,6 @@ def simple_expak(argv=None):
554566
return 0
555567
else:
556568
return 1
569+
570+
if __name__ == "__main__":
571+
sys.exit(simple_expak())

setup.py

+40-8
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,21 @@
66
import sys
77
import re
88

9+
ANCHOR_PATTERN = re.compile('^\.\. _([^:]+):$')
10+
911
# Work around 2.6 error when exiting tests:
1012
try:
1113
import multiprocessing
1214
except ImportError:
1315
pass
1416

17+
# Force bdist_wininst to use the correct bundled installer, even when building
18+
# on non-Windows platforms.
19+
import distutils.msvccompiler
20+
def correct_build_version():
21+
return 9.0
22+
distutils.msvccompiler.get_build_version = correct_build_version
23+
1524
here = os.path.abspath(os.path.dirname(__file__))
1625

1726
def read(*parts):
@@ -26,10 +35,6 @@ def find_version(*file_paths):
2635
return version_match.group(1)
2736
raise RuntimeError("Unable to find version string.")
2837

29-
long_description = '\n\n'.join([read('docs', 'blurb.txt'),
30-
read('docs', 'rtdlinks.txt'),
31-
read('HISTORY.rst')])
32-
3338
class PyTest(TestCommand):
3439
def finalize_options(self):
3540
TestCommand.finalize_options(self)
@@ -43,18 +48,45 @@ def run_tests(self):
4348
errno = pytest.main(self.test_args)
4449
sys.exit(errno)
4550

51+
# Set a default description just in case we don't find it in the readme.
52+
description = 'Extract and process resources from Quake-style pak files'
53+
54+
# Pick the desired sections out of the readme for use in the long description,
55+
# and also look for the short description in the readme header.
56+
readme_orig = read('README.rst')
57+
readme_sections = set(['blurb_section', 'documentation_section'])
58+
readme = ''
59+
section = None
60+
include_line = False
61+
for readme_line in readme_orig.splitlines(True):
62+
is_anchor = ANCHOR_PATTERN.match(readme_line)
63+
if is_anchor:
64+
section = is_anchor.group(1)
65+
include_line = False
66+
continue
67+
if section == 'header_section':
68+
if readme_line.startswith('expak:'):
69+
description = readme_line[6:].strip()
70+
if include_line:
71+
readme = readme + readme_line
72+
elif section in readme_sections:
73+
include_line = True
74+
75+
# Form long description from select readme sections + history/changelog.
76+
long_description = readme + read('HISTORY.rst')
77+
4678
setup(
4779
py_modules = ['expak'],
4880
name = 'expak',
4981
version = find_version('expak.py'),
5082
author = 'Joel Baxter',
5183
author_email = '[email protected]',
5284
url = 'http://github.com/neogeographica/expak',
53-
description = 'Extract and process resources from Quake-style pak files',
85+
description = description,
5486
long_description = long_description,
5587
classifiers = [
56-
'Development Status :: 4 - Beta',
57-
# 'Development Status :: 5 - Production/Stable',
88+
# 'Development Status :: 4 - Beta',
89+
'Development Status :: 5 - Production/Stable',
5890
'Environment :: Console',
5991
'Intended Audience :: Developers',
6092
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
@@ -72,7 +104,7 @@ def run_tests(self):
72104
install_requires = [],
73105
entry_points={'console_scripts': ['simple_expak = expak:simple_expak']},
74106
test_suite = 'test.test_expak',
75-
# disabling coverage in "setup.py test" for now (& see above)
107+
# disabling coverage in "setup.py test" for now (& see above)
76108
# tests_require = ['pytest-cov', 'pytest'],
77109
tests_require = ['pytest'],
78110
cmdclass = {'test': PyTest}

0 commit comments

Comments
 (0)