export pyclipper.__version__ as conventional in python packaging#40
Merged
anthrotype merged 3 commits intomasterfrom Jun 25, 2021
Merged
export pyclipper.__version__ as conventional in python packaging#40anthrotype merged 3 commits intomasterfrom
anthrotype merged 3 commits intomasterfrom
Conversation
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.
madig
approved these changes
Jun 25, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.pyfile, that we can import to re-export the conventional__version__string, like many python modules do.Until now, pyclipper was a single
.pyxextension module; after this PR, it becomes a package directory with the same name, containing a_pyclipperextension module, plus the generated_version.py.The public API of the top-level
pyclippermodule continues to work just like before (all symbols frompyclipper._pyclipperare star-imported by the parent module), the fact that the compiled part is moved to a private_pyclippermodule is just an implementation detail.A few tests that were checking that a DeprecationWarning was being raised when the deprecated
pyclipper.SCALING_FACTORglobal was modified by the user were failing after this change (because the global had been moved topyclipper._pyclipper.SCALING_FACTOR, thus modifyingpyclipper.SCALING_FACTORmade 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.