[pyosmium] 01/07: Imported Upstream version 2.10.2
Bas Couwenberg
sebastic at debian.org
Wed Nov 16 19:14:30 UTC 2016
This is an automated email from the git hooks/post-receive script.
sebastic pushed a commit to branch master
in repository pyosmium.
commit ff96bf317508234936ec70e0b2f822735cdda415
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date: Wed Nov 16 18:46:46 2016 +0100
Imported Upstream version 2.10.2
---
.travis.yml | 1 +
CHANGELOG.md | 19 ++++++++++
MANIFEST.in | 6 +++
README.rst | 55 +++++++++++++++++++++++++++
doc/conf.py | 13 ++++++-
doc/intro.rst | 12 +++---
lib/generic_writer.hpp | 10 ++---
lib/io.cc | 3 ++
lib/osmium.cc | 2 +-
osmium/replication/server.py | 12 +++---
osmium/version.py | 11 ++++++
setup.py | 89 ++++++++++++++++++++++++++++++++++++++++----
test/test_io.py | 2 +
13 files changed, 207 insertions(+), 28 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 4535dbf..8a275d5 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -55,6 +55,7 @@ addons:
- python3
- python3-dev
- python3-nose
+ - python3-setuptools
install:
- git clone --quiet --depth 1 https://github.com/osmcode/libosmium.git ../libosmium
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ba9cded..75170a3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,25 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Fixed
+## [2.10.2] - 2016-11-16
+
+### Added
+
+- support for sdist creation (now published via Pypi)
+- custom locations for libosmium and boost can be set via the
+ environment variables LIBOSMIUM_PREFIX and BOOST_PREFIX.
+- export bounding box from osmium::io::Header
+
+### Changed
+
+- Use libosmium 2.10.2
+
+### Fixed
+
+- various typos in documentation
+- crash in replication handler on incomplete state files
+
+
## [2.9.0] - 2016-09-15
### Changed
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..02d7924
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,6 @@
+include *md
+include LICENSE.TXT
+include lib/*.hpp
+include doc/*.rst
+include examples/*py
+include test/*py
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..5a3fe97
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,55 @@
+========
+pyosmium
+========
+
+This library provides Python bindings for the `Libosmium`_ C++
+library, a library for working with OpenStreetMap data in a fast and flexible
+manner.
+
+.. _Libosmium: https://github.com/osmcode/libosmium
+
+Installation
+============
+
+pyosmium can be installed with pip:
+
+ pip install osmium
+
+The Pypi source package already comes bundled with a matching version of
+libosmium. The library uses `Boost.Python`_ to create the C++ bindings.
+On Debian/Ubuntu install `libboost-python-dev`.
+On OS X run `brew install boost-python` or `brew install boost-python --with-python3`
+depending on which python version you want to use. You can also (re)install both.
+
+Python >= 2.7 is supported but a version >= 3.3 is strongly recommended.
+
+Other dependencies are expat, libz, and libbz2. See `Libosmium dependencies`_
+for required packages for various distributions.
+
+.. _Boost.Python: http://www.boost.org/doc/libs/1_56_0/libs/python/doc/index.html
+.. _Libosmium dependencies: https://github.com/osmcode/libosmium/wiki/Libosmium-dependencies
+
+Documentation
+=============
+
+The documentation for the latest release is available at
+`osmcode.org`_.
+
+.. _osmcode.org: http://docs.osmcode.org/pyosmium/latest
+
+Examples
+========
+
+The package contains an `example` directory with small examples on how to use
+the library. They are mostly ports of the examples in Libosmium and
+osmium-contrib.
+
+Fineprint
+=========
+
+Pyosmium is available under the BSD 2-Clause License. See LICENSE.TXT.
+
+The source code can be found on `GitHub`_. There is also the issue tracker
+for reporting bugs.
+
+.. _GitHub: https://github.com/osmcode/pyosmium
diff --git a/doc/conf.py b/doc/conf.py
index c937140..272692d 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -28,6 +28,15 @@ build_dir = "../build/lib.%s-%d.%d" % (
# insert after the current directory
sys.path.insert(0, os.path.normpath(os.path.join(os.path.abspath('.'), build_dir)))
+try:
+ from osmium.version import pyosmium_major, pyosmium_release
+except ImportError:
+ print("""
+ Compiled version of pyosmium not found, please build pyosmium
+ for Python %d.%d.
+ Expected build directory: %s """
+ % (sys.version_info[0], sys.version_info[1], build_dir))
+ raise
# -- General configuration ------------------------------------------------
@@ -63,9 +72,9 @@ copyright = '2015-2016, Sarah Hoffmann'
# built documents.
#
# The short X.Y version.
-version = '2.9'
+version = pyosmium_major
# The full version, including alpha/beta/rc tags.
-release = '2.9.0'
+release = pyosmium_release
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
diff --git a/doc/intro.rst b/doc/intro.rst
index 74cb783..fe2f35b 100644
--- a/doc/intro.rst
+++ b/doc/intro.rst
@@ -123,9 +123,9 @@ Interfacing with Shapely
^^^^^^^^^^^^^^^^^^^^^^^^
Pyosmium is a library for processing OSM files and therefore offers almost
-no functionality for processing geometries further. For this other libraries
-exist. To interface with these libraries you can simply convert the osmium
-geometries into WKB or WKT format and import the result. The following
+no functionality for processing geometries further. There are other libraries
+for that puspose. To interface with these libraries you can simply convert the
+osmium geometries into WKB or WKT format and import the result. The following
example uses the libgeos wrapper `Shapely`_ to compute the total way length::
import osmium
@@ -199,9 +199,9 @@ needs to be changed like that::
def node(self, n):
self.writer.add_node(n.replace(user=""))
-``replace()`` creates a new instance of an ``osmium.osm.mutable.`` object. These
-class a real python versions of the native object types in ``osmium.osm``. They
-have exactly the same attributes but they are mutable.
+``replace()`` creates a new instance of an ``osmium.osm.mutable`` object. These
+classes are python implementations of the native object types in ``osmium.osm``.
+They have exactly the same attributes but they are mutable.
A writer is able to process the mutable datatypes just like the native osmium
types. In fact, a writer is able to process any python object. It just expects
diff --git a/lib/generic_writer.hpp b/lib/generic_writer.hpp
index bb710fe..1dc7c4f 100644
--- a/lib/generic_writer.hpp
+++ b/lib/generic_writer.hpp
@@ -137,9 +137,7 @@ private:
if (hasattr(o, "user")) {
auto s = boost::python::extract<const char *>(o.attr("user"));
- builder.add_user(s);
- } else {
- builder.add_user("", 0);
+ builder.set_user(s);
}
}
@@ -150,7 +148,7 @@ private:
boost::python::extract<osmium::TagList&> otl(o);
if (otl.check()) {
if (otl().size() > 0)
- obuilder.add_item(&otl());
+ obuilder.add_item(otl());
return;
}
@@ -201,7 +199,7 @@ private:
boost::python::extract<osmium::NodeRefList&> onl(o);
if (onl.check()) {
if (onl().size() > 0)
- builder->add_item(&onl());
+ builder->add_item(onl());
return;
}
@@ -226,7 +224,7 @@ private:
boost::python::extract<osmium::RelationMemberList&> oml(o);
if (oml.check()) {
if (oml().size() > 0)
- builder->add_item(&oml());
+ builder->add_item(oml());
return;
}
diff --git a/lib/io.cc b/lib/io.cc
index 213cefe..9e6bc0c 100644
--- a/lib/io.cc
+++ b/lib/io.cc
@@ -17,6 +17,9 @@ BOOST_PYTHON_MODULE(io)
"True if there may be more than one version of the same "
"object in the file. This happens normally only in history "
"files.")
+ .def("box", &osmium::io::Header::box, arg("self"),
+ "Return the bounding box of the data in the file or an invalid "
+ "box if the information is not available.")
;
class_<osmium::io::Reader, boost::noncopyable>("Reader",
diff --git a/lib/osmium.cc b/lib/osmium.cc
index a571124..b1299f0 100644
--- a/lib/osmium.cc
+++ b/lib/osmium.cc
@@ -145,7 +145,7 @@ BOOST_PYTHON_MODULE(_osmium)
class_<pyosmium::MergeInputReader, boost::noncopyable>("MergeInputReader",
"Collects data from multiple input files and sorts and optionally "
- "deduplicates the data before apllying it to a handler.")
+ "deduplicates the data before applying it to a handler.")
.def("apply", &pyosmium::MergeInputReader::apply,
(arg("self"), arg("handler"), arg("simplify")=true),
"Apply collected data to a handler. The data will be sorted first. "
diff --git a/osmium/replication/server.py b/osmium/replication/server.py
index d8421f2..d7b01ab 100644
--- a/osmium/replication/server.py
+++ b/osmium/replication/server.py
@@ -169,11 +169,13 @@ class ReplicationServer(object):
else:
line = line.strip()
if line:
- key, val = line.split('=', 2)
- if key == 'sequenceNumber':
- seq = int(val)
- elif key == 'timestamp':
- ts = dt.datetime.strptime(val, "%Y-%m-%dT%H\\:%M\\:%SZ")
+ kv = line.split('=', 2)
+ if len(kv) != 2:
+ return None
+ if kv[0] == 'sequenceNumber':
+ seq = int(kv[1])
+ elif kv[0] == 'timestamp':
+ ts = dt.datetime.strptime(kv[1], "%Y-%m-%dT%H\\:%M\\:%SZ")
if sys.version_info >= (3,0):
ts = ts.replace(tzinfo=dt.timezone.utc)
line = response.readline()
diff --git a/osmium/version.py b/osmium/version.py
new file mode 100644
index 0000000..4ecc7e0
--- /dev/null
+++ b/osmium/version.py
@@ -0,0 +1,11 @@
+"""
+Version information.
+"""
+
+# the major version
+pyosmium_major = '2.10'
+# current release (Pip version)
+pyosmium_release = '2.10.2'
+
+# libosmium version shipped with the Pip release
+libosmium_version = '2.10.2'
diff --git a/setup.py b/setup.py
index 9d56a74..053dad5 100644
--- a/setup.py
+++ b/setup.py
@@ -1,15 +1,44 @@
-from distutils.core import setup, Extension
-from os import environ
+from setuptools import setup, Extension
+from setuptools.command.sdist import sdist as orig_sdist
+from subprocess import call
from sys import version_info as pyversion, platform as osplatform
from ctypes.util import find_library
+import os
includes = []
libs = []
libdirs = []
+class My_sdist(orig_sdist):
+
+ def make_release_tree(self, base_dir, files):
+ orig_sdist.make_release_tree(self, base_dir, files)
+ # checkout libosmium in the required version
+ tarball = 'https://github.com/osmcode/libosmium/archive/v%s.tar.gz' % libosmium_version
+ print("Downloading and adding libosmium sources from", tarball)
+ call('cd %s && wget -O - -q %s | tar xz' % (base_dir, tarball), shell=True)
+
+def get_versions():
+ """ Read the version file.
+
+ The file cannot be directly imported because it is not installed
+ yet.
+ """
+ version_py = os.path.join(os.path.split(__file__)[0], "osmium/version.py")
+ v = {}
+ with open(version_py) as version_file:
+ # Execute the code in version.py.
+ exec(compile(version_file.read(), version_py, 'exec'), v)
+
+ return v['pyosmium_release'], v['libosmium_version']
+
+pyosmium_release, libosmium_version = get_versions()
+
## boost dependencies
-includes.append('/usr/include')
-if osplatform in ["linux", "linux2"]:
+includes.append(os.path.join(os.environ.get('BOOST_PREFIX', '/usr'), 'include'))
+if 'BOOST_PREFIX' in os.environ:
+ libdirs.append(os.path.join(os.environ['BOOST_PREFIX'], 'lib'))
+elif osplatform in ["linux", "linux2"]:
libdirs.append('/usr/lib/x86_64-linux-gnu/')
# try to find the boost library matching the python version
@@ -31,7 +60,23 @@ else:
raise Exception("Cannot find boost_python library")
### osmium dependencies
-includes.append('../libosmium/include')
+osmium_prefixes = [ 'libosmium-' + libosmium_version, '../libosmium' ]
+if 'LIBOSMIUM_PREFIX' in os.environ:
+ lo_version_h = os.path.join(os.environ['LIBOSMIUM_PREFIX'],
+ 'include/osmium/version.hpp')
+ if not os.path.isfile(lo_version_h):
+ raise RuntimeError("LIBOSMIUM_PREFIX is set but no libosmium was found in '%s'" % os.environ['LIBOSMIUM_PREFIX'])
+ includes.insert(0, os.path.join(os.environ['LIBOSMIUM_PREFIX'], 'include'))
+else:
+ # default search paths for libosmium
+ for prefix in [ 'libosmium-' + libosmium_version, '../libosmium' ]:
+ if os.path.isfile(os.path.join(prefix, 'include/osmium/version.hpp')):
+ print("libosmium found in '%s'" % prefix)
+ includes.insert(0, os.path.join(prefix, 'include'))
+ break
+ else:
+ print("Using global libosmium.")
+
osmium_libs = ('expat', 'pthread', 'z', 'bz2')
libs.extend(osmium_libs)
@@ -69,10 +114,38 @@ for ext in ('osm', 'replication'):
))
packages.append('osmium.%s' % ext)
-setup (name = 'pyosmium',
- version = '2.9.0',
- description = 'Provides python bindings for libosmium.',
+classifiers = [
+ "Development Status :: 4 - Beta",
+ "Intended Audience :: Developers",
+ "License :: OSI Approved :: BSD License",
+ "Programming Language :: Python :: 2.7",
+ "Programming Language :: Python :: 3.3",
+ "Programming Language :: Python :: 3.4",
+ "Programming Language :: Python :: 3.5",
+ "Programming Language :: Python :: 3.6",
+ "Programming Language :: Python :: Implementation :: CPython",
+ "Programming Language :: C++",
+ ]
+
+descfile=open('README.rst')
+long_description = descfile.read()
+descfile.close()
+
+setup (name = 'osmium',
+ version = pyosmium_release,
+ description = 'Python bindings for libosmium, the data processing library for OSM data',
+ long_description=long_description,
+ author='Sarah Hoffmann',
+ author_email='lonvia at denofr.de',
+ maintainer='Sarah Hoffmann',
+ maintainer_email='lonvia at denofr.de',
+ download_url='https://github.com/osmcode/pyosmium',
+ url='http://osmcode.org/pyosmium',
+ keywords=["OSM", "OpenStreetMap", "Osmium"],
+ license='BSD',
+ classifiers=classifiers,
packages = packages,
+ cmdclass={'sdist' : My_sdist },
ext_modules = extensions)
diff --git a/test/test_io.py b/test/test_io.py
index aef135b..6054461 100644
--- a/test/test_io.py
+++ b/test/test_io.py
@@ -56,6 +56,8 @@ class TestFileHeader(unittest.TestCase):
rd = o.io.Reader(fn)
h = rd.header()
assert_false(h.has_multiple_object_versions)
+ assert_true(h.box().valid())
+ assert_equals(h.box().size(), 64800.0)
rd.close()
finally:
os.remove(fn)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/pyosmium.git
More information about the Pkg-grass-devel
mailing list