cleanup readme, drop pypngtile bits from Makefile, fixup setup.py for pypngtile
--- a/.hgignore Sun Sep 14 15:24:58 2014 +0300
+++ b/.hgignore Sun Sep 14 16:08:40 2014 +0300
@@ -1,12 +1,14 @@
-syntax: regexp
-
-\.[^/]+\.sw[op]$
-\.pyc$
+syntax: glob
-^build/
-^bin/pngtile(-static)?$
-^data
-^lib/libpngtile.(so|a)$
-^doc/html
-^dist
-^python/pypngtile.c$
+.*.swo
+.*.swp
+*.pyc
+
+bin/pngtile
+bin/pngtile-static
+build/
+dist/
+doc/html
+lib/
+opt/
+python/pypngtile.c
--- a/Makefile Sun Sep 14 15:24:58 2014 +0300
+++ b/Makefile Sun Sep 14 16:08:40 2014 +0300
@@ -21,10 +21,10 @@
# output name
DIST_NAME = pngtile-${shell hg id -i}
-DIST_DEPS = python/pypngtile.c
-DIST_RESOURCES = README python/ pngtile/ static/ bin/
+DIST_DEPS =
+DIST_RESOURCES = README pngtile/ static/ bin/
-all: depend lib/libpngtile.so bin/pngtile lib/pypngtile.so
+all: depend lib/libpngtile.so bin/pngtile
lib/libpngtile.so : \
build/obj/lib/ctx.o build/obj/lib/image.o build/obj/lib/cache.o build/obj/lib/tile.o build/obj/lib/png.o build/obj/lib/error.o \
@@ -34,9 +34,6 @@
build/obj/lib/ctx.o build/obj/lib/image.o build/obj/lib/cache.o build/obj/lib/tile.o build/obj/lib/png.o build/obj/lib/error.o \
build/obj/shared/util.o build/obj/shared/log.o
-lib/pypngtile.so : \
- lib/libpngtile.so
-
bin/pngtile : \
build/obj/pngtile/main.o \
lib/libpngtile.so build/obj/shared/log.o
@@ -56,12 +53,11 @@
dirs:
mkdir -p bin lib dist
mkdir -p $(SRC_DIRS:%=build/deps/%)
- mkdir -p $(SRC_DIRS:%=build/obj/%) build/obj/python
+ mkdir -p $(SRC_DIRS:%=build/obj/%)
clean:
rm -f build/obj/*/*.o build/deps/*/*.d
rm -f bin/pngtile bin/pngtile-static lib/*.so lib/*.a
- rm -f pngtile/*.pyc
rm -f */.*.swp */*/.*.swp
# .h dependencies
@@ -99,15 +95,6 @@
lib/lib%.a :
$(AR) rc $@ $+
-python/%.c : python/%.pyx
- cython -o $@ $<
-
-build/obj/python/%.o : python/%.c
- $(CC) -c -fPIC -I/usr/include/python2.5 $(CPPFLAGS) $(CFLAGS) $< -o $@
-
-lib/py%.so : build/obj/python/py%.o
- $(CC) -shared $(LDFLAGS) $+ $(LOADLIBES) $(LDLIBS) -o $@
-
dist: $(DIST_DEPS)
rm -rf dist/$(DIST_NAME)
mkdir -p dist/$(DIST_NAME)
--- a/README Sun Sep 14 15:24:58 2014 +0300
+++ b/README Sun Sep 14 16:08:40 2014 +0300
@@ -1,16 +1,15 @@
-pngtile
+# libpngtile
Constant-time/memory tile-based handling of large PNG images.
-ABOUT:
- pngtile is a library (and associated command-line utility) offering efficient random access to partial regions of
+## About
+ pngtile is a C library (and associated command-line utility) offering efficient random access to partial regions of
very large PNG images (gigapixel range).
For this purpose, the library linearly decodes the PNG image to an uncompressed memory-mapped file, which can then
be later used to encode a portion of this raw pixel data back into a PNG image.
-
-NOTES:
+## Notes
The command-line utility is mainly intended for maintining the image caches and testing, primary usage is expected
to be performed using the library interface directly. A simple Cython wrapper for a Python extension module is
provided under python/.
@@ -25,23 +24,26 @@
hexadecimal notation (--background 0xFFFFFF - for 24bpp RGB white), and consecutive regions of that color will
be omitted in the cache file, which may provide significant gains in space efficiency.
-
-COMPILING:
+## Build
The library depends on libpng and pthreads. The code was developed and tested using:
-
- * libpng 1.2.15~beta5-3ubuntu0.1
- * NPTL 2.7 (glibc 2.7-10ubuntu5)
+
+ * libpng12-dev png.h 1.2.15~beta5-3ubuntu0.1
+ * libc6-dev pthread.h NPTL 2.7 (glibc 2.7-10ubuntu5)
To compile dist versions, simply execute
- make
+ $ make
+
+ To compile source versions, execute:
+
+ $ make dirs
+ $ make
The libpngtile.so and pypngtile.so libraries will be placed under lib/, and the 'pngtile' binary under bin/.
XXX: If compiling the pypngtile.so library with make fails, then `setup.py build_ext -i` should build it.
-
-USAGE:
+## Usage
Store the .png data files in a directory. You must have write access to the directory when updating the caches,
which are written as a .cache file alongside the .png file.
@@ -66,11 +68,24 @@
Alternatively, to not update an image's cache, use the -N/--no-update option.
-
-TODO/BUGS:
+## Issues
At this stage, the library is primarily designed to handle a specific set of PNG images, and hence does not support
all aspects of the PNG format, nor any other image formats.
The pt_images opened by main() are not cleaned up before process exit, due to the asynchronous nature of the tile
render operation's accesses to the underlying pt_cache object.
+# pypngtile
+
+Python extension for pngtile
+
+## Dependencies
+
+ * python-cython
+ * python-dev
+
+## Build
+
+ $ python setup.py build_ext
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/setup.cfg Sun Sep 14 16:08:40 2014 +0300
@@ -0,0 +1,4 @@
+[build_ext]
+build-lib = lib/
+include-dirs = include/
+library-dirs = lib/
--- a/setup.py Sun Sep 14 15:24:58 2014 +0300
+++ b/setup.py Sun Sep 14 16:08:40 2014 +0300
@@ -3,39 +3,32 @@
import os.path
-build_root = os.path.abspath(os.path.dirname(__file__))
-
-pypngtile_c = "python/pypngtile.c"
-pypngtile_name = "python/pypngtile.pyx"
-
-cmdclass = dict()
-
try :
- from Cython.Distutils import build_ext
-
- cmdclass['build_ext'] = build_ext
-
-except ImportError :
- path = os.path.join(build_root, pypngtile_c)
+ from Cython.Build import cythonize
- if os.path.exists(path) :
- print "Warning: falling back from .pyx -> .c due to missing Cython"
- # just use the .c
- pypngtile_name = pypngtile_c
-
- else :
- # fail
- raise
+ CYTHON = True
+except ImportError :
+ CYTHON = False
+
+if CYTHON:
+ pypngtile_sources = [ "python/pypngtile.pyx" ]
+elif os.path.exists("python/pypngtile.c"):
+ pypngtile_sources = [ "python/pypngtile.c" ]
+else:
+ raise Exception("Building from source requires Cython")
+
+ext_modules = [Extension("pypngtile",
+ sources = pypngtile_sources,
+ libraries = ['pngtile'],
+)]
+
+if CYTHON:
+ ext_modules = cythonize(ext_modules)
setup(
- name = 'pngtiles',
- cmdclass = cmdclass,
- ext_modules = [
- Extension("pypngtile", [pypngtile_name],
- include_dirs = ['include'],
- library_dirs = ['lib'],
- libraries = ['pngtile'],
- ),
- ],
+ name = 'pngtile',
+ version = '1.0-dev',
+
+ ext_modules = ext_modules,
)