Skip to content

Commit

Permalink
increment to 1.3.5 to resolve platform-specific loading issue
Browse files Browse the repository at this point in the history
  • Loading branch information
hobu committed May 16, 2017
1 parent 921a662 commit 759b3ab
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion mgrs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import ctypes
import re

__version__='1.3.4'
__version__='1.3.5'

class MGRS:
def __init__(self):
Expand Down
21 changes: 15 additions & 6 deletions mgrs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,26 @@ class RTreeError(Exception):
"RTree exception, indicates a RTree-related error."
pass


def get_windows_platform_name():
libname = 'libmgrs'
try:
import wheel.pep425tags
name = wheel.pep425tags.get_abbr_impl() + \
wheel.pep425tags.get_impl_ver() + \
'-' + wheel.pep425tags.get_platform()
return libname + '.' + name + '.pyd'
except ImportError:
return libname + '.pyd'

if os.name == 'nt':
try:
local_dlls = sys.path
original_path = os.environ['PATH']
os.environ['PATH'] = "%s;%s" % (';'.join(local_dlls), original_path)
try:
# Python 2
rt = ctypes.PyDLL('libmgrs.pyd')
except OSError:
# Python 3
rt = ctypes.PyDLL('libmgrs.cp35-win32.pyd')
# Python
platform = get_windows_platform_name()
rt = ctypes.PyDLL(platform)
def free(m):
try:
free = ctypes.cdll.msvcrt.free(m)
Expand Down
12 changes: 3 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@

from glob import glob
from setuptools import setup
from setuptools import setup, Extension

import os

from setuptools import Extension

sources = ['libmgrs/mgrs.c',
'libmgrs/utm.c',
'libmgrs/ups.c',
Expand All @@ -21,16 +19,13 @@
library_dirs = None
)

# Get text from README.txt
# readme_text = open('./README.rst', encoding='utf-8').read()

import codecs

with codecs.open('./README.rst', encoding="utf-8") as f:
readme_text = f.read()

setup(name = 'mgrs',
version = '1.3.4',
version = '1.3.5',
description = 'MGRS coordinate conversion for Python',
license = 'MIT',
keywords = 'gis coordinate conversion',
Expand All @@ -42,9 +37,8 @@
long_description = readme_text,
ext_modules = [mgrs],
packages = ['mgrs'],
install_requires = ['setuptools'],
install_requires = ['setuptools', 'wheel'],
test_suite = 'tests.test_suite',
# data_files = data_files,
zip_safe = False,
classifiers = [
'Development Status :: 4 - Beta',
Expand Down

0 comments on commit 759b3ab

Please sign in to comment.