Skip to content

Commit

Permalink
Review setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
RKrahl committed Jul 4, 2023
1 parent 0771fe4 commit 529ec29
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# This setup.py file serves the only purpose to dynamically create a
# _meta.py file which then is imported from conf.py.

import setuptools
from setuptools import setup
import setuptools.command.install
from distutils import log
import datetime
import distutils.core
import os
from pathlib import Path
import subprocess
from setuptools import setup
import setuptools.command.install


class GitProps:
Expand Down Expand Up @@ -38,9 +39,9 @@ def get_date(self):
return datetime.date.fromtimestamp(ts)


class meta(distutils.core.Command):
class meta(setuptools.Command):

description = "generate a _meta.py file"
description = "generate meta files"
user_options = []
meta_template = '''
__version__ = "%(version)s"
Expand All @@ -55,11 +56,13 @@ def finalize_options(self):

def run(self):
git = GitProps()
version = self.distribution.get_version()
log.info("version: %s", version)
values = {
'version': self.distribution.get_version(),
'version': version,
'date': git.get_date().strftime("%e %B %Y").strip(),
}
with open("_meta.py", "wt") as f:
with Path("_meta.py").open("wt") as f:
print(self.meta_template % values, file=f)


Expand Down

0 comments on commit 529ec29

Please sign in to comment.