hobuinc / mgrs

Python MGRS library
https://pypi.python.org/pypi/mgrs
MIT License
111 stars 36 forks source link

Create dummy symbol for module initialization for setuptools' Extension class on Windows #11

Closed nhatbui closed 8 years ago

nhatbui commented 8 years ago

On Windows, setuptools' Extension class must export the symbol "initlibmgrs" when building the DLL (no way around it). We place dummy functions in the source to satisfy this. Code has been updated to look for the DLL (or .pyd in this case), satisfying this for Python 2 and 3.

nhatbui commented 8 years ago

Tested on Windows, OS X, and CentOS.

I used the 'six' package since it's the Pythonic way to check versions. We could've easily done a try-except.

We should discuss the technical debt building up. I know we only want to use a subset of the GeoTrans C library but we're doing a lot of workarounds to avoid having to make all the GeoTrans C code into a package.

Also, when we look for the .pyd on Python 3: I feel like there's going to be specific strings for different minor versions of Python. Shall we officially proclaim support for 2.7 and 3.5?

hobu commented 8 years ago

Please remove the six dependency.

We should discuss the technical debt building up. I know we only want to use a subset of the GeoTrans C library but we're doing a lot of workarounds to avoid having to make all the GeoTrans C code into a package.

I'm not sure what you mean by technical debt. This library has been around for 5 years, and it only does one thing. A full wrap of GeoTrans, while it might be nice, would be a lot of work. That library's arrangement isn't very convenient to do it either.

nhatbui commented 8 years ago

Removed 'six' package dependency.

Regarding my comment on technical debt: sorry if I sounded dramatic. I just wanted to say there may be special cases that break the package like some environments naming our .pyd file differently or saving the .pyd elsewhere. "Finding the .pyd" I'm not so worried about: using sys.path to locate the .pyd is an improvement. Being able to import libmgrs would be the bullet-proof solution but yes, that's a lot of work and not the aim of this package.

hobu commented 8 years ago

I just wanted to say there may be special cases that break the package like some environments naming our .pyd file differently or saving the .pyd elsewhere. "Finding the .pyd" I'm not so worried about: using sys.path to locate the .pyd is an improvement.

That code was stolen from Shapely from six years ago. I'm happy to merge anything that fixes it up.

nhatbui commented 8 years ago

Sounds good. Well, that's my windows fix. Works on Windows 7/8 and 10.