fonttools / pyclipper

Cython wrapper for the C++ translation of the Angus Johnson's Clipper library (ver. 6.4.2)
MIT License
233 stars 42 forks source link

export pyclipper.__version__ as conventional in python packaging #40

Closed anthrotype closed 3 years ago

anthrotype commented 3 years ago

Sometimes one needs to retrieve the version of pyclipper installed, but can't rely on mechanisms such as importlib.metadata because the metadata may not be there (e.g. pyclipper is embedded in a native application). Setuptools_scm allows to generate a _version.py file, that we can import to re-export the conventional __version__ string, like many python modules do. Until now, pyclipper was a single .pyx extension module; after this PR, it becomes a package directory with the same name, containing a _pyclipper extension module, plus the generated _version.py. The public API of the top-level pyclipper module continues to work just like before (all symbols from pyclipper._pyclipper are star-imported by the parent module), the fact that the compiled part is moved to a private _pyclipper module is just an implementation detail.

A few tests that were checking that a DeprecationWarning was being raised when the deprecated pyclipper.SCALING_FACTOR global was modified by the user were failing after this change (because the global had been moved to pyclipper._pyclipper.SCALING_FACTOR, thus modifying pyclipper.SCALING_FACTOR made no change). Since this feature was already no-op and had long been deprecated, I have just removed all references to it, so one won't get any deprecation warning.