Skip to content

Commit

Permalink
implement setuptools-scm
Browse files Browse the repository at this point in the history
  • Loading branch information
stevebachmeier committed Oct 25, 2023
1 parent 7070272 commit 1a9d671
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,6 @@ notebooks/

# Mac OS stuff
.DS_Store

# Version
src/pseudopeople/_version.py
6 changes: 2 additions & 4 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@
copyright = f'2023, {about["__author__"]}'
author = about["__author__"]

# The short X.Y version.
version = about["__version__"]
# The full version, including alpha/beta/rc tags.
release = about["__version__"]
version = pseudopeople.__version__
release = pseudopeople.__version__


# -- General configuration ------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[build-system]
requires = ["packaging", "setuptools"]

[tool.black]
line_length = 94

Expand Down
25 changes: 18 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import sys
from pathlib import Path

from packaging.version import parse
from setuptools import find_packages, setup

min_version, max_version = ((3, 9), "3.9"), ((3, 11), "3.11")
min_version, max_version = ("3.9", "3.11")

if not (min_version[0] <= sys.version_info[:2] <= max_version[0]):
min_version = parse(min_version)
max_version = parse(max_version)

if not (
min_version <= parse(".".join([str(v) for v in sys.version_info[:2]])) <= max_version
):
# Python 3.5 does not support f-strings
py_version = ".".join([str(v) for v in sys.version_info[:3]])
error = (
"\n----------------------------------------\n"
"Error: Pseudopeople runs under python {min_version}-{max_version}.\n"
"You are running python {py_version}".format(
min_version=min_version[1], max_version=max_version[1], py_version=py_version
)
f"Error: Pseudopeople runs under python {min_version.base_version}-{max_version.base_version}.\n"
f"You are running python {py_version}"
)
print(error, file=sys.stderr)
sys.exit(1)
Expand All @@ -38,6 +42,8 @@
"tqdm",
]

setup_requires = ["setuptools_scm"]

interactive_requirements = [
"IPython",
"ipywidgets",
Expand All @@ -59,7 +65,6 @@

setup(
name=about["__title__"],
version=about["__version__"],
description=about["__summary__"],
long_description=long_description,
license=about["__license__"],
Expand Down Expand Up @@ -101,4 +106,10 @@
# simulate=pseudopeople.interface.cli:simulate
# """,
zip_safe=False,
use_scm_version={
"write_to": "src/pseudopeople/_version.py",
"write_to_template": '__version__ = "{version}"\n',
"tag_regex": r"^(?P<prefix>v)?(?P<version>[^\+]+)(?P<suffix>.*)?$",
},
setup_requires=setup_requires,
)
3 changes: 0 additions & 3 deletions src/pseudopeople/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"__title__",
"__summary__",
"__uri__",
"__version__",
"__author__",
"__email__",
"__license__",
Expand All @@ -13,8 +12,6 @@
__summary__ = "pseudopeople is package which adds noise to simulated census-scale data using standard scientific Python tools."
__uri__ = "https://github.com/ihmeuw/pseudopeople"

__version__ = "0.8.0"

__author__ = "The pseudopeople developers"
__email__ = "[email protected]"

Expand Down
2 changes: 1 addition & 1 deletion src/pseudopeople/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
__summary__,
__title__,
__uri__,
__version__,
)
from pseudopeople._version import __version__
from pseudopeople.configuration.entities import NO_NOISE
from pseudopeople.configuration.interface import get_config
from pseudopeople.interface import (
Expand Down

0 comments on commit 1a9d671

Please sign in to comment.