Get the custom setuptools subclasses used by Versioneer. If the package uses a different cmdclass (e.g. one from numpy), it should be provide as an argument.
(cmdclass=None)
| 1751 | |
| 1752 | |
| 1753 | def get_cmdclass(cmdclass=None): |
| 1754 | """Get the custom setuptools subclasses used by Versioneer. |
| 1755 | |
| 1756 | If the package uses a different cmdclass (e.g. one from numpy), it |
| 1757 | should be provide as an argument. |
| 1758 | """ |
| 1759 | if "versioneer" in sys.modules: |
| 1760 | del sys.modules["versioneer"] |
| 1761 | # this fixes the "python setup.py develop" case (also 'install' and |
| 1762 | # 'easy_install .'), in which subdependencies of the main project are |
| 1763 | # built (using setup.py bdist_egg) in the same python process. Assume |
| 1764 | # a main project A and a dependency B, which use different versions |
| 1765 | # of Versioneer. A's setup.py imports A's Versioneer, leaving it in |
| 1766 | # sys.modules by the time B's setup.py is executed, causing B to run |
| 1767 | # with the wrong versioneer. Setuptools wraps the sub-dep builds in a |
| 1768 | # sandbox that restores sys.modules to it's pre-build state, so the |
| 1769 | # parent is protected against the child's "import versioneer". By |
| 1770 | # removing ourselves from sys.modules here, before the child build |
| 1771 | # happens, we protect the child from the parent's versioneer too. |
| 1772 | # Also see https://github.com/python-versioneer/python-versioneer/issues/52 |
| 1773 | |
| 1774 | cmds = {} if cmdclass is None else cmdclass.copy() |
| 1775 | |
| 1776 | # we add "version" to setuptools |
| 1777 | from setuptools import Command |
| 1778 | |
| 1779 | class cmd_version(Command): |
| 1780 | description = "report generated version string" |
| 1781 | user_options = [] |
| 1782 | boolean_options = [] |
| 1783 | |
| 1784 | def initialize_options(self): |
| 1785 | pass |
| 1786 | |
| 1787 | def finalize_options(self): |
| 1788 | pass |
| 1789 | |
| 1790 | def run(self): |
| 1791 | vers = get_versions(verbose=True) |
| 1792 | print("Version: %s" % vers["version"]) |
| 1793 | print(" full-revisionid: %s" % vers.get("full-revisionid")) |
| 1794 | print(" dirty: %s" % vers.get("dirty")) |
| 1795 | print(" date: %s" % vers.get("date")) |
| 1796 | if vers["error"]: |
| 1797 | print(" error: %s" % vers["error"]) |
| 1798 | cmds["version"] = cmd_version |
| 1799 | |
| 1800 | # we override "build_py" in setuptools |
| 1801 | # |
| 1802 | # most invocation pathways end up running build_py: |
| 1803 | # distutils/build -> build_py |
| 1804 | # distutils/install -> distutils/build ->.. |
| 1805 | # setuptools/bdist_wheel -> distutils/install ->.. |
| 1806 | # setuptools/bdist_egg -> distutils/install_lib -> build_py |
| 1807 | # setuptools/install -> bdist_egg ->.. |
| 1808 | # setuptools/develop -> ? |
| 1809 | # pip install: |
| 1810 | # copies source tree to a tempdir before running egg_info/etc |
nothing calls this directly
no test coverage detected
searching dependent graphs…