Skip to content

export pyclipper.__version__ as conventional in python packaging#40

Merged
anthrotype merged 3 commits intomasterfrom
export-version-string
Jun 25, 2021
Merged

export pyclipper.__version__ as conventional in python packaging#40
anthrotype merged 3 commits intomasterfrom
export-version-string

Conversation

@anthrotype
Copy link
Copy Markdown
Member

@anthrotype anthrotype commented Jun 25, 2021

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.

the _version.py file is autogenerated at build time from git tag using setuptools_scm; the pyclipper.__version__ variable exports that, as it's common in python packaging. This allows clients to import pyclipper and check its __version__ without needing to query the package metadata (which may be missing when pyclipper is embedded in native applications).
since we moved the extension module to an internal pyclipper._pyclipper submodule, setting SCALING_FACTOR on the parent pyclipper package won't work any more. We may as well remove the deprecation warnings altogether since they have been there for long time now.
@anthrotype anthrotype requested a review from madig June 25, 2021 16:26
@anthrotype anthrotype merged commit 5e10a2e into master Jun 25, 2021
@anthrotype anthrotype deleted the export-version-string branch June 25, 2021 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants