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 ccd9bbc commit 176d2ae
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 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 All @@ -70,8 +73,13 @@ def run(self):


setup(
name = "test-doc-rk",
use_scm_version=True,
python_requires='>= 3.6',
setup_requires=['setuptools_scm'],
url = "https://github.com/RKrahl/test-doc-rk",
author = "Rolf Krahl",
author_email = "rolf.krahl@helmholtz-berlin.de",
license = "Apache-2.0",
python_requires = '>= 3.6',
install_requires = ['setuptools_scm'],
cmdclass = {'meta': meta, 'install': install},
)

0 comments on commit 176d2ae

Please sign in to comment.