diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index aca7f3a..c90ba1c 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.12"] + python-version: ["3.10"] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index f60847f..86a6abf 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -20,10 +20,10 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Python 3.12 + - name: Set up Python 3.8 uses: actions/setup-python@v3 with: - python-version: "3.12" + python-version: "3.10" - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index f81e1f0..1f1bcd9 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -24,7 +24,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v3 with: - python-version: '3.x' + python-version: '3.10' - name: Install dependencies run: | python -m pip install --upgrade pip @@ -35,7 +35,6 @@ jobs: # Note: the following account information will not work on GHES git config user.name "github-actions[bot]" git config user.email "" - python increment_version.py git add . git commit -m "generated" git push origin HEAD:main diff --git a/.github/workflows/zenodo-sandbox.yml b/.github/workflows/zenodo-sandbox.yml index 138c5b9..fc1c26d 100644 --- a/.github/workflows/zenodo-sandbox.yml +++ b/.github/workflows/zenodo-sandbox.yml @@ -22,7 +22,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-python@v4 with: - python-version: '3.12' + python-version: '3.10' - run: pip install . - run: git archive --format zip HEAD src > hermes-plugin-python.zip - run: hermes harvest diff --git a/increment_version.py b/increment_version.py deleted file mode 100644 index 2dba102..0000000 --- a/increment_version.py +++ /dev/null @@ -1,47 +0,0 @@ -import toml -import os - -def main(): - try: - os.rename("pyproject.toml", "pyproject.txt") - with open("pyproject.txt", 'r+') as f: - comment = [] - while True: - line = f.readline() - if line[0] == "#": - comment = [line] + comment - else: - break - os.rename("pyproject.txt", "pyproject.toml") - with open("pyproject.toml", 'r+') as f: - data = toml.load(f) - project = data.get("project") - if not project is None: - version = project.get("version") - if not version is None: - a,b,c = map(int, version.split(".")) - if c < 99: - c += 1 - elif b < 99: - c = 0 - b += 1 - else: - c = 0 - b = 0 - a += 1 - data["project"]["version"] = str(a) + "." + str(b) + "." + str(c) - if not data == {}: - with open("pyproject.toml", 'w') as f: - toml.dump(data, f) - os.rename("pyproject.toml", "pyproject.txt") - with open("pyproject.txt", 'r+') as f: - content = f.readlines() - content = comment + content - with open("pyproject.txt", 'w') as f: - for line in content: - f.write(line) - os.rename("pyproject.txt", "pyproject.toml") - except (FileNotFoundError): - pass - -main() diff --git a/pyproject.toml b/pyproject.toml index 39aa994..c4024c2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,7 @@ version = "0.1.8" readme = "README.md" description = "HERMES plugin for .toml files" keywords = [ "publishing", "metadata", "automation",] -requires-python = ">= 3.12.4" +requires-python = ">= 3.8" classifiers = [ "Development Status :: 2 - Pre-Alpha", "Environment :: Plugins", "Programming Language :: Python :: 3", "Operating System :: OS Independent",] dependencies = [ "hermes>=0.8.0",] [[project.authors]] diff --git a/src/hermes_toml/harvest.py b/src/hermes_toml/harvest.py index 8f0b700..bababb1 100644 --- a/src/hermes_toml/harvest.py +++ b/src/hermes_toml/harvest.py @@ -7,7 +7,7 @@ """A hermes harvest plugin that harvests the .toml file of the project""" -from contextlib import chdir +from os import chdir, getcwd from email.utils import getaddresses import toml @@ -28,7 +28,7 @@ class TomlHarvestPlugin(HermesHarvestPlugin): "project": [ ("name", "name"), ("version", "version"), ("description", "description"), ("runtimePlatform", "requires-python"), ("author", "authors"), - ("maintainer", "maintainers"), ("keywords", "keywords") + ("maintainer", "maintainers"), ("keywords", "keywords"), ("license", "license") ], "poetry": [ ("name", "name"), ("version", "version"), ("description", "description"), @@ -42,9 +42,13 @@ def __call__(self, command: HermesHarvestCommand): """start of the process of harvesting the .toml file""" #set the working directory temporary to the correct location - with chdir(command.args.path): - #harvesting the data from the .toml file specified in the Settings class - data = self.read_from_toml(command.settings.toml.filename) + old_dir = getcwd() + chdir(command.args.path) + + #harvesting the data from the .toml file specified in the Settings class + data = self.read_from_toml(command.settings.toml.filename) + + chdir(old_dir) #returning the harvested data and some metadata return data, {"filename": command.settings.toml.filename} @@ -107,6 +111,8 @@ def read_from_one_table(cls, table, mapping): if not persons is None: ret_data[field1] = persons + elif field1 == "license": + ret_data[field1] = table[field2].get("text", None) else: #add the data of a field that needs no processing ret_data[field1] = table[field2]