Skip to content

Conversation

flying-sheep
Copy link
Contributor

I currently rely on a hack to enable flit to get the version of a module with no dependencies installed.

This patch would allow me to just use if not os.environ.get('FLIT_GETTING_VERSION'): ...

pkg/_metadata.py

import traceback
from get_version import get_version
__version__ = get_version(__file__.replace('_metadata', '__init__'))

def within_flit():
    import traceback
    for frame in traceback.extract_stack():
        if frame.name == 'get_docstring_and_version_via_import':
            return True
    return False

pkg/__init__.py:

"""Your package docstring"""
	   
from ._metadata import __version__, within_flit
	   
if not within_flit():
    from .subpackage import thing

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.

1 participant