Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: version management #41

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion hashfields/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
__version__ = "2023.09.1"
from importlib.metadata import version, PackageNotFoundError

try:
__version__ = version("hashfields")
except PackageNotFoundError:
# package is not installed
pass
17 changes: 7 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "hashfields"
dynamic = ["version"]
version = "2023.09.1"
description = "Selectively hash, drop, or keep fields from a flat file (e.g. CSV)."
readme = "README.md"
license = { file = "LICENSE" }
Expand All @@ -10,11 +10,6 @@ dependencies = [
"pandas==2.1.1"
]

[project.urls]
Code = "https://github.com/cal-itp/hashfields"
Documentation = "https://docs.calitp.org/hashfields"
Issues = "https://github.com/cal-itp/hashfields/issues"

[project.optional-dependencies]
dev = [
"black",
Expand All @@ -35,8 +30,13 @@ dist =[
[project.scripts]
hashfields = "hashfields.main:main"

[project.urls]
Code = "https://github.com/cal-itp/hashfields"
Documentation = "https://docs.calitp.org/hashfields"
Issues = "https://github.com/cal-itp/hashfields/issues"

[build-system]
requires = ["setuptools>=65", "setuptools-scm"]
requires = ["setuptools>=65", "wheel"]
build-backend = "setuptools.build_meta"

[tool.black]
Expand All @@ -63,6 +63,3 @@ norecursedirs = [

[tool.setuptools]
packages = ["hashfields"]

[tool.setuptools.dynamic]
version = {attr = "hashfields.__version__"}
10 changes: 8 additions & 2 deletions tests/test_hashfields.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import re
import subprocess

import pytest
Expand All @@ -14,6 +15,13 @@ def hashfields():
return "hashfields"


def test_version():
from hashfields import __version__

assert __version__ is not None
assert re.match(r"\d{4}\.\d{1,2}\.\d+", __version__)


def test_hashfields_default(capfd, hashfields):
subprocess.call([hashfields])
capture = capfd.readouterr()
Expand Down Expand Up @@ -78,7 +86,6 @@ def test_hashfields_file(capfd, hashfields, source_file, expected_file):
assert normalize_output(capture.out) == expected


# skip test on windows because it reads files written for *nix OSes
def test_hashfields_skip_drop(capfd, hashfields):
source_file = "./tests/samples/small.csv"
expected_file = "./tests/samples/small.hashed.skip_sub.drop_type.csv"
Expand All @@ -91,7 +98,6 @@ def test_hashfields_skip_drop(capfd, hashfields):
assert normalize_output(capture.out) == expected


# skip test on windows because it reads files written for *nix OSes
@pytest.mark.parametrize(
("source_file", "expected_file"),
[
Expand Down
Loading