Metadata-Version: 2.1
Name: liberator
Version: 0.1.1
Summary: static code extractor for Python
Home-page: https://gitlab.kitware.com/python/liberator
Author: joncrall
Author-email: jon.crall@kitware.com
License: Apache 2
Classifier: Development Status :: 1 - Planning
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Utilities
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.8
Description-Content-Type: text/x-rst
License-File: LICENSE
Requires-Dist: astunparse >=1.6.3
Requires-Dist: ubelt >=1.3.3
Requires-Dist: pyflakes >=2.2.0
Requires-Dist: pygtrie >=2.3.3
Provides-Extra: all
Requires-Dist: astunparse >=1.6.3 ; extra == 'all'
Requires-Dist: ubelt >=1.3.3 ; extra == 'all'
Requires-Dist: pyflakes >=2.2.0 ; extra == 'all'
Requires-Dist: pygtrie >=2.3.3 ; extra == 'all'
Requires-Dist: xdoctest >=1.1.1 ; extra == 'all'
Provides-Extra: all-strict
Requires-Dist: astunparse ==1.6.3 ; extra == 'all-strict'
Requires-Dist: ubelt ==1.3.3 ; extra == 'all-strict'
Requires-Dist: pyflakes ==2.2.0 ; extra == 'all-strict'
Requires-Dist: pygtrie ==2.3.3 ; extra == 'all-strict'
Requires-Dist: xdoctest ==1.1.1 ; extra == 'all-strict'
Requires-Dist: coverage ==4.5 ; (python_version < "2.7" and python_version >= "2.6") and extra == 'all-strict'
Requires-Dist: pytest <=4.6.11,==4.6.0 ; (python_version < "2.8.0" and python_version >= "2.7.0") and extra == 'all-strict'
Requires-Dist: pytest-cov ==2.8.1 ; (python_version < "2.8.0" and python_version >= "2.7.0") and extra == 'all-strict'
Requires-Dist: coverage ==5.3.1 ; (python_version < "3.10" and python_version >= "3.9") and extra == 'all-strict'
Requires-Dist: pytest ==4.6.0 ; (python_version < "3.10.0" and python_version >= "3.7.0") and extra == 'all-strict'
Requires-Dist: coverage ==5.3.1 ; (python_version < "3.4" and python_version >= "2.7") and extra == 'all-strict'
Requires-Dist: coverage ==4.3.4 ; (python_version < "3.5" and python_version >= "3.4") and extra == 'all-strict'
Requires-Dist: pytest <=4.6.11,==4.6.0 ; (python_version < "3.5.0" and python_version >= "3.4.0") and extra == 'all-strict'
Requires-Dist: pytest-cov ==2.8.1 ; (python_version < "3.5.0" and python_version >= "3.4.0") and extra == 'all-strict'
Requires-Dist: coverage ==5.3.1 ; (python_version < "3.6" and python_version >= "3.5") and extra == 'all-strict'
Requires-Dist: pytest <=6.1.2,==4.6.0 ; (python_version < "3.6.0" and python_version >= "3.5.0") and extra == 'all-strict'
Requires-Dist: pytest-cov ==2.9.0 ; (python_version < "3.6.0" and python_version >= "3.5.0") and extra == 'all-strict'
Requires-Dist: coverage ==6.1.1 ; (python_version < "3.7" and python_version >= "3.6") and extra == 'all-strict'
Requires-Dist: pytest ==4.6.0 ; (python_version < "3.7.0" and python_version >= "3.6.0") and extra == 'all-strict'
Requires-Dist: coverage ==6.1.1 ; (python_version < "3.8" and python_version >= "3.7") and extra == 'all-strict'
Requires-Dist: coverage ==6.1.1 ; (python_version < "3.9" and python_version >= "3.8") and extra == 'all-strict'
Requires-Dist: coverage ==6.1.1 ; (python_version >= "3.10") and extra == 'all-strict'
Requires-Dist: pytest ==6.2.5 ; (python_version >= "3.10.0") and extra == 'all-strict'
Requires-Dist: pytest-cov ==3.0.0 ; (python_version >= "3.6.0") and extra == 'all-strict'
Requires-Dist: coverage >=4.5 ; (python_version < "2.7" and python_version >= "2.6") and extra == 'all'
Requires-Dist: pytest <=4.6.11,>=4.6.0 ; (python_version < "2.8.0" and python_version >= "2.7.0") and extra == 'all'
Requires-Dist: pytest-cov >=2.8.1 ; (python_version < "2.8.0" and python_version >= "2.7.0") and extra == 'all'
Requires-Dist: coverage >=5.3.1 ; (python_version < "3.10" and python_version >= "3.9") and extra == 'all'
Requires-Dist: pytest >=4.6.0 ; (python_version < "3.10.0" and python_version >= "3.7.0") and extra == 'all'
Requires-Dist: coverage >=5.3.1 ; (python_version < "3.4" and python_version >= "2.7") and extra == 'all'
Requires-Dist: coverage >=4.3.4 ; (python_version < "3.5" and python_version >= "3.4") and extra == 'all'
Requires-Dist: pytest <=4.6.11,>=4.6.0 ; (python_version < "3.5.0" and python_version >= "3.4.0") and extra == 'all'
Requires-Dist: pytest-cov >=2.8.1 ; (python_version < "3.5.0" and python_version >= "3.4.0") and extra == 'all'
Requires-Dist: coverage >=5.3.1 ; (python_version < "3.6" and python_version >= "3.5") and extra == 'all'
Requires-Dist: pytest <=6.1.2,>=4.6.0 ; (python_version < "3.6.0" and python_version >= "3.5.0") and extra == 'all'
Requires-Dist: pytest-cov >=2.9.0 ; (python_version < "3.6.0" and python_version >= "3.5.0") and extra == 'all'
Requires-Dist: coverage >=6.1.1 ; (python_version < "3.7" and python_version >= "3.6") and extra == 'all'
Requires-Dist: pytest >=4.6.0 ; (python_version < "3.7.0" and python_version >= "3.6.0") and extra == 'all'
Requires-Dist: coverage >=6.1.1 ; (python_version < "3.8" and python_version >= "3.7") and extra == 'all'
Requires-Dist: coverage >=6.1.1 ; (python_version < "3.9" and python_version >= "3.8") and extra == 'all'
Requires-Dist: coverage >=6.1.1 ; (python_version >= "3.10") and extra == 'all'
Requires-Dist: pytest >=6.2.5 ; (python_version >= "3.10.0") and extra == 'all'
Requires-Dist: pytest-cov >=3.0.0 ; (python_version >= "3.6.0") and extra == 'all'
Provides-Extra: docs
Requires-Dist: sphinx >=5.0.1 ; extra == 'docs'
Requires-Dist: sphinx-autobuild >=2021.3.14 ; extra == 'docs'
Requires-Dist: sphinx-rtd-theme >=1.0.0 ; extra == 'docs'
Requires-Dist: sphinxcontrib-napoleon >=0.7 ; extra == 'docs'
Requires-Dist: sphinx-autoapi >=1.8.4 ; extra == 'docs'
Requires-Dist: Pygments >=2.9.0 ; extra == 'docs'
Requires-Dist: myst-parser >=0.18.0 ; extra == 'docs'
Requires-Dist: sphinx-reredirects >=0.0.1 ; extra == 'docs'
Provides-Extra: docs-strict
Requires-Dist: sphinx ==5.0.1 ; extra == 'docs-strict'
Requires-Dist: sphinx-autobuild ==2021.3.14 ; extra == 'docs-strict'
Requires-Dist: sphinx-rtd-theme ==1.0.0 ; extra == 'docs-strict'
Requires-Dist: sphinxcontrib-napoleon ==0.7 ; extra == 'docs-strict'
Requires-Dist: sphinx-autoapi ==1.8.4 ; extra == 'docs-strict'
Requires-Dist: Pygments ==2.9.0 ; extra == 'docs-strict'
Requires-Dist: myst-parser ==0.18.0 ; extra == 'docs-strict'
Requires-Dist: sphinx-reredirects ==0.0.1 ; extra == 'docs-strict'
Provides-Extra: linting
Requires-Dist: flake8 >=5.0.0 ; extra == 'linting'
Provides-Extra: linting-strict
Requires-Dist: flake8 ==5.0.0 ; extra == 'linting-strict'
Provides-Extra: optional
Provides-Extra: optional-strict
Provides-Extra: runtime
Requires-Dist: astunparse >=1.6.3 ; extra == 'runtime'
Requires-Dist: ubelt >=1.3.3 ; extra == 'runtime'
Requires-Dist: pyflakes >=2.2.0 ; extra == 'runtime'
Requires-Dist: pygtrie >=2.3.3 ; extra == 'runtime'
Provides-Extra: runtime-strict
Requires-Dist: astunparse ==1.6.3 ; extra == 'runtime-strict'
Requires-Dist: ubelt ==1.3.3 ; extra == 'runtime-strict'
Requires-Dist: pyflakes ==2.2.0 ; extra == 'runtime-strict'
Requires-Dist: pygtrie ==2.3.3 ; extra == 'runtime-strict'
Provides-Extra: tests
Requires-Dist: xdoctest >=1.1.1 ; extra == 'tests'
Provides-Extra: tests-strict
Requires-Dist: xdoctest ==1.1.1 ; extra == 'tests-strict'
Requires-Dist: coverage ==4.5 ; (python_version < "2.7" and python_version >= "2.6") and extra == 'tests-strict'
Requires-Dist: pytest <=4.6.11,==4.6.0 ; (python_version < "2.8.0" and python_version >= "2.7.0") and extra == 'tests-strict'
Requires-Dist: pytest-cov ==2.8.1 ; (python_version < "2.8.0" and python_version >= "2.7.0") and extra == 'tests-strict'
Requires-Dist: coverage ==5.3.1 ; (python_version < "3.10" and python_version >= "3.9") and extra == 'tests-strict'
Requires-Dist: pytest ==4.6.0 ; (python_version < "3.10.0" and python_version >= "3.7.0") and extra == 'tests-strict'
Requires-Dist: coverage ==5.3.1 ; (python_version < "3.4" and python_version >= "2.7") and extra == 'tests-strict'
Requires-Dist: coverage ==4.3.4 ; (python_version < "3.5" and python_version >= "3.4") and extra == 'tests-strict'
Requires-Dist: pytest <=4.6.11,==4.6.0 ; (python_version < "3.5.0" and python_version >= "3.4.0") and extra == 'tests-strict'
Requires-Dist: pytest-cov ==2.8.1 ; (python_version < "3.5.0" and python_version >= "3.4.0") and extra == 'tests-strict'
Requires-Dist: coverage ==5.3.1 ; (python_version < "3.6" and python_version >= "3.5") and extra == 'tests-strict'
Requires-Dist: pytest <=6.1.2,==4.6.0 ; (python_version < "3.6.0" and python_version >= "3.5.0") and extra == 'tests-strict'
Requires-Dist: pytest-cov ==2.9.0 ; (python_version < "3.6.0" and python_version >= "3.5.0") and extra == 'tests-strict'
Requires-Dist: coverage ==6.1.1 ; (python_version < "3.7" and python_version >= "3.6") and extra == 'tests-strict'
Requires-Dist: pytest ==4.6.0 ; (python_version < "3.7.0" and python_version >= "3.6.0") and extra == 'tests-strict'
Requires-Dist: coverage ==6.1.1 ; (python_version < "3.8" and python_version >= "3.7") and extra == 'tests-strict'
Requires-Dist: coverage ==6.1.1 ; (python_version < "3.9" and python_version >= "3.8") and extra == 'tests-strict'
Requires-Dist: coverage ==6.1.1 ; (python_version >= "3.10") and extra == 'tests-strict'
Requires-Dist: pytest ==6.2.5 ; (python_version >= "3.10.0") and extra == 'tests-strict'
Requires-Dist: pytest-cov ==3.0.0 ; (python_version >= "3.6.0") and extra == 'tests-strict'
Requires-Dist: coverage >=4.5 ; (python_version < "2.7" and python_version >= "2.6") and extra == 'tests'
Requires-Dist: pytest <=4.6.11,>=4.6.0 ; (python_version < "2.8.0" and python_version >= "2.7.0") and extra == 'tests'
Requires-Dist: pytest-cov >=2.8.1 ; (python_version < "2.8.0" and python_version >= "2.7.0") and extra == 'tests'
Requires-Dist: coverage >=5.3.1 ; (python_version < "3.10" and python_version >= "3.9") and extra == 'tests'
Requires-Dist: pytest >=4.6.0 ; (python_version < "3.10.0" and python_version >= "3.7.0") and extra == 'tests'
Requires-Dist: coverage >=5.3.1 ; (python_version < "3.4" and python_version >= "2.7") and extra == 'tests'
Requires-Dist: coverage >=4.3.4 ; (python_version < "3.5" and python_version >= "3.4") and extra == 'tests'
Requires-Dist: pytest <=4.6.11,>=4.6.0 ; (python_version < "3.5.0" and python_version >= "3.4.0") and extra == 'tests'
Requires-Dist: pytest-cov >=2.8.1 ; (python_version < "3.5.0" and python_version >= "3.4.0") and extra == 'tests'
Requires-Dist: coverage >=5.3.1 ; (python_version < "3.6" and python_version >= "3.5") and extra == 'tests'
Requires-Dist: pytest <=6.1.2,>=4.6.0 ; (python_version < "3.6.0" and python_version >= "3.5.0") and extra == 'tests'
Requires-Dist: pytest-cov >=2.9.0 ; (python_version < "3.6.0" and python_version >= "3.5.0") and extra == 'tests'
Requires-Dist: coverage >=6.1.1 ; (python_version < "3.7" and python_version >= "3.6") and extra == 'tests'
Requires-Dist: pytest >=4.6.0 ; (python_version < "3.7.0" and python_version >= "3.6.0") and extra == 'tests'
Requires-Dist: coverage >=6.1.1 ; (python_version < "3.8" and python_version >= "3.7") and extra == 'tests'
Requires-Dist: coverage >=6.1.1 ; (python_version < "3.9" and python_version >= "3.8") and extra == 'tests'
Requires-Dist: coverage >=6.1.1 ; (python_version >= "3.10") and extra == 'tests'
Requires-Dist: pytest >=6.2.5 ; (python_version >= "3.10.0") and extra == 'tests'
Requires-Dist: pytest-cov >=3.0.0 ; (python_version >= "3.6.0") and extra == 'tests'

Liberator - static code extractor for Python
--------------------------------------------

|GitlabCIPipeline| |GitlabCICoverage| |ReadTheDocs| |Pypi| |Downloads|

+---------------+---------------------------------------------+
| Github        | https://gitlab.kitware.com/python/liberator |
+---------------+---------------------------------------------+
| Pypi          | https://pypi.org/project/liberator          |
+---------------+---------------------------------------------+
| ReadTheDocs   | https://liberator.readthedocs.io/en/latest/ |
+---------------+---------------------------------------------+

Liberator is a Python library that "liberates" (i.e. statically extracts) class
/ function source code from an existing python library into a single standalone
module.

It works by statically parsing the code for the class / function definition and
then recursively parsing and extracting all missing dependencies.

Here is an example. Say that you want to use the ``find_exe`` function from
``ubelt``, but you don't want to depend on ubelt itself, you can extract the
minimal code necessary to define the ``find_exe`` function in a new standalone
module via:


.. code:: python

    # Create a Liberator instance to manage construction of
    # the new standalone code.
    from liberator.core import Liberator
    lib = Liberator()

    # Pass the liberator object the function you want to expose
    # You can add more than one function this way.
    import ubelt as ub
    lib.add_dynamic(ub.find_exe)

    # Tell liberator about the library that you dont want to depend on,
    # any (statically findable) external references to that library will be
    # vendored into the new liberated code.
    lib.expand(['ubelt'])

    # Finally access the "current source code" which will
    # have the self-contained version of the "liberated" utility.
    print(lib.current_sourcecode())


Limitations
~~~~~~~~~~~

Liberator has several limitations. It only works if the code is expressed
statically (i.e. no decorators that register methods in a list to be injected
into something later).  It does not do any work to evaluate anything, it just
looks at function definitions and pulls them in verbatim.  It also does no work
to mangle to deconflict different functions with the same names (although it
could and that is an extension I'd lke add).  Lastly, it can only "expand"
packages imported at the top level of the code. Nested imports are not
"liberated". This is another extension that could be implemented, but it
currently isn't.



.. |Pypi| image:: https://img.shields.io/pypi/v/liberator.svg
   :target: https://pypi.python.org/pypi/liberator

.. |Downloads| image:: https://img.shields.io/pypi/dm/liberator.svg
   :target: https://pypistats.org/packages/liberator

.. # See: https://ci.appveyor.com/project/jon.crall/liberator/settings/badges
.. .. |Appveyor| image:: https://ci.appveyor.com/api/projects/status/py3s2d6tyfjc8lm3/branch/main?svg=true
.. :target: https://ci.appveyor.com/project/jon.crall/liberator/branch/main

.. |GitlabCIPipeline| image:: https://gitlab.kitware.com/python/liberator/badges/main/pipeline.svg
   :target: https://gitlab.kitware.com/python/liberator/-/jobs

.. |GitlabCICoverage| image:: https://gitlab.kitware.com/python/liberator/badges/main/coverage.svg?job=coverage
    :target: https://gitlab.kitware.com/python/liberator/commits/main

.. |ReadTheDocs| image:: https://readthedocs.org/projects/liberator/badge/?version=latest
    :target: http://liberator.readthedocs.io/en/latest/
