Skip to content

Conversation

engnadeau
Copy link
Contributor

Affected Issues

Proposed Changes

  • Added function get_local_node_and_timestamp(version, fmt='%Y%m%d%H%M%S')
  • This function is callable as is (e.g., get_version(local_scheme=get_local_node_and_timestamp)) or as an entry point (e.g., get_version(local_scheme='node-and-timestamp'))
  • Wrappers can be built around this function to provide custom timestamps, see examples below:

Example Usage

Using Entry Point

v = setuptools_scm.get_version(root='..', relative_to=__file__,
                               local_scheme='node-and-timestamp')
print(v)

Using Callable

v = setuptools_scm.get_version(root='..', relative_to=__file__,
                               local_scheme=get_local_node_and_timestamp)
print(v)

Using a Format Wrapper

def min_timestamp(version):
    return get_local_node_and_timestamp(version, fmt='%Y%m%d%H%M')


v = setuptools_scm.get_version(root='..', relative_to=__file__,
                               local_scheme=min_timestamp)
print(v)
def micro_timestamp(version):
    return get_local_node_and_timestamp(version, fmt='%Y%m%d%H%M%S%f')


v = setuptools_scm.get_version(root='..', relative_to=__file__,
                               local_scheme=micro_timestamp)
print(v)

if version.exact or version.node is None:
return version.format_choice("",
"+d{time:"
+ "{fmt}".format(fmt=fmt)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should use nested replacements as per https://www.python.org/dev/peps/pep-3101/#format-specifiers

this needs an api addition however

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a follow-up issue was created

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