File tree Expand file tree Collapse file tree 6 files changed +33
-14
lines changed Expand file tree Collapse file tree 6 files changed +33
-14
lines changed Original file line number Diff line number Diff line change 1+ from policyengine_core .__version__ import __version__
2+
3+
4+ def fetch_version ():
5+ try :
6+ return __version__
7+ except Exception as e :
8+ print (f"Error fetching version: { e } " )
9+ return None
10+
11+
12+ if __name__ == "__main__" :
13+ print (fetch_version ())
Original file line number Diff line number Diff line change 1212 exit 0
1313fi
1414
15- current_version=` python setup.py --version `
15+ current_version=` python .github/fetch_version.py `
1616
1717if git rev-parse --verify --quiet $current_version
1818then
Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22
3- git tag ` python setup.py --version `
3+ git tag ` python .github/fetch_version.py `
44git push --tags || true # update the repository version
Original file line number Diff line number Diff line change @@ -21,11 +21,11 @@ test: test-country-template
2121 coverage xml -i
2222
2323build :
24- python setup.py sdist bdist_wheel
24+ python -m build
2525
2626changelog :
2727 build-changelog changelog.yaml --output changelog.yaml --update-last-date --start-from 0.1.0 --append-file changelog_entry.yaml
2828 build-changelog changelog.yaml --org PolicyEngine --repo policyengine-core --output CHANGELOG.md --template .github/changelog_template.md
29- bump-version changelog.yaml setup.py
29+ bump-version changelog.yaml pyproject.toml
3030 rm changelog_entry.yaml || true
3131 touch changelog_entry.yaml
Original file line number Diff line number Diff line change 1+ import importlib .metadata
2+ import tomli
3+
4+ try :
5+ with open ("pyproject.toml" , "rb" ) as f :
6+ pyproject = tomli .load (f )
7+ __version__ = pyproject ["project" ]["version" ]
8+ except Exception as e :
9+ __version__ = importlib .metadata .version ("policyengine_core" )
Original file line number Diff line number Diff line change 1- import os
2- import subprocess
1+ from pathlib import Path
32import tomli
43import pytest
54
65
76@pytest .fixture (scope = "module" )
87def toml_data ():
9- file_path = "../.. /pyproject.toml"
10- if not os . path . exists (file_path ):
11- pytest .fail ("pyproject.toml not found in the current directory." )
8+ file_path = Path ( "/policyengine-core /pyproject.toml")
9+ if not file_path . exists ():
10+ pytest .fail (f "pyproject.toml not found in the current directory." )
1211 with open (file_path , "rb" ) as f :
1312 return tomli .load (f )
1413
1514
16- def test_toml_syntax ():
17- file_path = "../../pyproject.toml"
15+ def test_toml_syntax (toml_data ):
1816 try :
19- with open (file_path , "rb" ) as f :
20- tomli .load (f )
17+ toml_data
2118 except tomli .TOMLDecodeError as e :
2219 pytest .fail (f"TOML syntax error: { e } " )
2320
2421
2522def test_required_fields (toml_data ):
26- required_fields = ["name" , "version" , "description " ]
23+ required_fields = ["name" , "version" , "dependencies " ]
2724 for field in required_fields :
2825 assert field in toml_data .get (
2926 "project" , {}
You can’t perform that action at this time.
0 commit comments