From 4f0c888d8dc24fe625103d6042bc9a9fdc8cbdeb Mon Sep 17 00:00:00 2001 From: Roland Kaminski Date: Wed, 21 Feb 2024 17:22:58 +0100 Subject: [PATCH 01/10] merge setup.cfg into pyproject.toml --- pyproject.toml | 32 ++++++++++++++++++++++++++++++++ setup.cfg | 45 --------------------------------------------- 2 files changed, 32 insertions(+), 45 deletions(-) delete mode 100644 setup.cfg diff --git a/pyproject.toml b/pyproject.toml index 74e9cab..5b1832f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,6 +5,38 @@ requires = [ ] build-backend = "setuptools.build_meta" +[project] +name = "fillname" +authors = [ + { name = "", email = "" } +] +description = "A template project." +requires-python = ">=3.9" +license = {file = "LICENSE"} +dynamic = [ "version" ] +readme = "README.md" + +[project.urls] +Hompage = "https://potassco.org/" + +[project.optional-dependencies] +format = [ "black", "isort", "autoflake" ] +lint_pylint = [ "pylint" ] +typecheck = [ "types-setuptools", "mypy" ] +test = [ "coverage[toml]" ] +doc = [ "sphinx", "furo", "nbsphinx", "sphinx_copybutton", "myst-parser" ] +dev = [ "fillname[test,typecheck,lint_pylint]" ] + +[project.scripts] +fillname = "fillname.__main__:main" + +[tool.setuptools.packages.find] +where = ["src"] + +[tool.setuptools_scm] +version_scheme = "python-simplified-semver" +local_scheme = "no-local-version" + [tool.isort] profile = "black" line_length = 120 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 3ce96ca..0000000 --- a/setup.cfg +++ /dev/null @@ -1,45 +0,0 @@ -[metadata] -name = fillname -version = 1.0.0 -author = -author_email = -description = A template project. -long_description = file: README.md -long_description_content_type = text/markdown -license = MIT -url = https://potassco.org/ - -[options] -packages = find: -package_dir = - =src -python_requires = >=3.9 -include_package_data = True - -[options.packages.find] -where = src - -[options.extras_require] -format = - black - isort - autoflake -lint_pylint = - pylint -typecheck = - types-setuptools - mypy -test = - coverage[toml] -doc = - sphinx - furo - nbsphinx - sphinx_copybutton - myst-parser -dev = - fillname[format,lint_pylint,typecheck,test] - -[options.entry_points] -console_scripts = - fillname = fillname.__main__:main From 794b6f9b9dc0f5d1fe7acd5631424b4d3c2d6af4 Mon Sep 17 00:00:00 2001 From: Roland Kaminski Date: Wed, 21 Feb 2024 17:24:25 +0100 Subject: [PATCH 02/10] remove config leftovers --- .flake8 | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 .flake8 diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 31b8987..0000000 --- a/.flake8 +++ /dev/null @@ -1,6 +0,0 @@ -[flake8] -max-line-length = 120 -exclude = - .git - .github -ignore = E741 From 914ffd5c734bcf6c887e846417e073a1ae8fd07f Mon Sep 17 00:00:00 2001 From: Roland Kaminski Date: Wed, 21 Feb 2024 17:29:31 +0100 Subject: [PATCH 03/10] add refined deployment workflow --- .github/workflows/deploy.yml | 44 +++++++++++++++++++++ .github/workflows/{ci-test.yml => test.yml} | 21 ++++------ 2 files changed, 51 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/deploy.yml rename .github/workflows/{ci-test.yml => test.yml} (50%) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..2a5bc46 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,44 @@ +name: deploy to pypi + +on: + workflow_dispatch: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + +jobs: + deploy: + name: deploy + permissions: + id-token: write + environment: release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.11 + + - name: install build dependencies + run: python3 -m pip install build + + - name: build package + run: python3 -m build --sdist --wheel --outdir dist/ + + - name: upload package + uses: actions/upload-artifact@v4 + with: + name: package + path: dist/ + + - name: publish package (pypi) + if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }} + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: "https://pypi.org/legacy/" + + - name: publish package (test.pypi) + if: ${{ github.event_name == 'workflow_dispatch' }} + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: "https://test.pypi.org/legacy/" diff --git a/.github/workflows/ci-test.yml b/.github/workflows/test.yml similarity index 50% rename from .github/workflows/ci-test.yml rename to .github/workflows/test.yml index 7442528..f1a96c0 100644 --- a/.github/workflows/ci-test.yml +++ b/.github/workflows/test.yml @@ -1,10 +1,8 @@ -name: Run CI tests +name: run CI test on: push: - branches: - - main - - master + branches: [devel, main, master, wip] pull_request: env: @@ -17,23 +15,18 @@ jobs: strategy: fail-fast: false matrix: - os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] + os: [ubuntu-latest, macos-latest, windows-latest] steps: - - name: "checkout repository" - uses: actions/checkout@v3 - - - name: "setup python 3.9" - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: 3.9 - - - name: "setup python 3.11" - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: 3.11 - - name: install nox + - name: install requirements run: python -m pip install nox - name: run tests From 83ec75db8282f81211248e5220eb744753705f22 Mon Sep 17 00:00:00 2001 From: Roland Kaminski Date: Wed, 21 Feb 2024 17:38:08 +0100 Subject: [PATCH 04/10] make sure that the tests run --- init.py | 4 ++-- pyproject.toml | 2 +- setup.py | 6 ------ 3 files changed, 3 insertions(+), 9 deletions(-) delete mode 100644 setup.py diff --git a/init.py b/init.py index cdcd0bb..ed4e4ae 100755 --- a/init.py +++ b/init.py @@ -31,8 +31,8 @@ def main(): replacements = { "fillname": project, - "": email, - "": author, + "author@fillname.com": email, + "Mister Fillname": author, } def replace(filepath): diff --git a/pyproject.toml b/pyproject.toml index 5b1832f..0207c33 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ build-backend = "setuptools.build_meta" [project] name = "fillname" authors = [ - { name = "", email = "" } + { name = "Mister Fillname", email = "author@fillname.com" } ] description = "A template project." requires-python = ">=3.9" diff --git a/setup.py b/setup.py deleted file mode 100644 index 9ab6a32..0000000 --- a/setup.py +++ /dev/null @@ -1,6 +0,0 @@ -""" -This is provided for compatibility. -""" -from setuptools import setup - -setup() From e2d4c1c2eda3de5feb0a15561fe173d0111638b2 Mon Sep 17 00:00:00 2001 From: Roland Kaminski Date: Wed, 21 Feb 2024 17:39:57 +0100 Subject: [PATCH 05/10] add deployment info --- DEPLOYMENT.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 DEPLOYMENT.md diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md new file mode 100644 index 0000000..3251a0a --- /dev/null +++ b/DEPLOYMENT.md @@ -0,0 +1,21 @@ +## Deployment + +To release this project on (test.)pypi.org please follow these instructions: + +Long version: +https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ +TL;DR + - create a github environmnent (Github->Your Project->Settings->Environments) with the safety regulations you prefer, e.g. restriction + to a fixed set of branches like "test_release" or manual confirmation + This step is important to prevent other people from releasing new versions on accident + - create a [test.]pypi.org account (enable 2fa) + - create a project with the same name + - add the formerly created github environment + - run the respective CI scripts either manually (test.pypi.org) or by tagging a release version (pypi.org) + +[nox]: https://nox.thea.codes/en/stable/index.html +[pipx]: https://pypa.github.io/pipx/ +[pre]: https://pre-commit.com/ +[editable]: https://setuptools.pypa.io/en/latest/userguide/development_mode.html + + From b3b002e8d4b112942317b50c769620e553f349ae Mon Sep 17 00:00:00 2001 From: Roland Kaminski Date: Wed, 21 Feb 2024 18:05:42 +0100 Subject: [PATCH 06/10] remove empty folders --- examples/.gitkeep | 0 src/encodings/.gitkeep | 0 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 examples/.gitkeep delete mode 100644 src/encodings/.gitkeep diff --git a/examples/.gitkeep b/examples/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/src/encodings/.gitkeep b/src/encodings/.gitkeep deleted file mode 100644 index e69de29..0000000 From b3122e6a527db0ac006a3b18d2fad7a593638271 Mon Sep 17 00:00:00 2001 From: Roland Kaminski Date: Wed, 21 Feb 2024 20:38:37 +0100 Subject: [PATCH 07/10] update DEPLOYMENT.md --- DEPLOYMENT.md | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md index 3251a0a..384e18c 100644 --- a/DEPLOYMENT.md +++ b/DEPLOYMENT.md @@ -1,21 +1,15 @@ ## Deployment -To release this project on (test.)pypi.org please follow these instructions: - -Long version: -https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ -TL;DR - - create a github environmnent (Github->Your Project->Settings->Environments) with the safety regulations you prefer, e.g. restriction - to a fixed set of branches like "test_release" or manual confirmation - This step is important to prevent other people from releasing new versions on accident - - create a [test.]pypi.org account (enable 2fa) - - create a project with the same name - - add the formerly created github environment - - run the respective CI scripts either manually (test.pypi.org) or by tagging a release version (pypi.org) - -[nox]: https://nox.thea.codes/en/stable/index.html -[pipx]: https://pypa.github.io/pipx/ -[pre]: https://pre-commit.com/ -[editable]: https://setuptools.pypa.io/en/latest/userguide/development_mode.html - - +Releases are deployed on [pypi] whenever a tag of form `vMajor.Minor.Revision` +is pushed. Furthemore, the deployment workflow can be triggered manually to +deploy test releases on [test.pypi]. + +For this to work, the workflow has to be granted permission to deploy on the +two services. Please follow this packaging [guide] to setup your accounts +accordingly. We also recommend to setup a github [environment] to restrict which +contributers can deploy packages. + +[pypi]: https://pypi.org/ +[test.pypi]: https://test.pypi.org/ +[guide]: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ +[environment]: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment/ From 3ccd4202b9477575ba3f83bf589304b52351a53a Mon Sep 17 00:00:00 2001 From: Roland Kaminski Date: Wed, 21 Feb 2024 20:50:22 +0100 Subject: [PATCH 08/10] run tests before deployment --- .github/workflows/deploy.yml | 4 ++++ .github/workflows/test.yml | 1 + 2 files changed, 5 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2a5bc46..ee0bd6e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -7,8 +7,12 @@ on: - 'v[0-9]+.[0-9]+.[0-9]+' jobs: + test: + uses: ./.github/workflows/test.yml + deploy: name: deploy + needs: test permissions: id-token: write environment: release diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f1a96c0..dde6a57 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,6 +4,7 @@ on: push: branches: [devel, main, master, wip] pull_request: + workflow_call: env: FORCE_COLOR: "3" From 6d6c0935c3f25e8296fc10de77d7a580e92bf4da Mon Sep 17 00:00:00 2001 From: Roland Kaminski Date: Wed, 21 Feb 2024 21:30:27 +0100 Subject: [PATCH 09/10] adjust renaming script --- CONTRIBUTING.md | 16 +++++++------- LICENSE | 2 +- doc/content/installation.md | 6 +++--- init.py | 43 +++++++++++++++++++++++++++++++------ pyproject.toml | 2 +- 5 files changed, 50 insertions(+), 19 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 70d35d6..1a328a6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -22,13 +22,13 @@ All types of contributions are encouraged and valued. See the [Table of Contents ## Asking Questions -> If you want to ask a question, we assume that you have read the available [Documentation](https://potassco.org/fillname/). +> If you want to ask a question, we assume that you have read the available [Documentation](https://fillname.org/). -Before you ask a question, it is best to search for existing [issues](https://github.com/potassco/fillname/issues) or [messages](https://sourceforge.net/p/potassco/mailman/potassco-users/) in the archive of our mailing list. +Before you ask a question, it is best to search for existing [issues](https://fillname.org/issues) or [messages](https://sourceforge.net/p/potassco/mailman/potassco-users/) in the archive of our mailing list. If you then still feel the need to ask a question and need clarification, we recommend the following: -- [Subscribe](https://sourceforge.net/projects/potassco/lists/potassco-users) to our mailing list on SourceForge or open an [issue](https://github.com/potassco/fillname/issues/new) on GitHub. +- [Subscribe](https://sourceforge.net/projects/potassco/lists/potassco-users) to our mailing list on SourceForge or open an [issue](https://fillname.org/issues/new) on GitHub. - Provide as much context as you can about what you're running into. - We can best help you if you provide executable code showcasing your problem. @@ -53,7 +53,7 @@ A good bug report shouldn't leave others needing to chase you up for more inform - Make sure that you are using the latest version. - Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment components/versions. If you are looking for support, you might want to check [this section](#i-have-a-question)). -- To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [bug tracker](https://github.com/potassco/fillname/issues?q=label%3Abug). +- To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [bug tracker](https://fillname.org/issues?q=label%3Abug). - Collect information about the bug - Python Version - Possibly your input and the output @@ -65,7 +65,7 @@ A good bug report shouldn't leave others needing to chase you up for more inform We use GitHub issues to track bugs and errors. If you run into an issue with the project: -- Open an [Issue](https://github.com/potassco/fillname/issues/new). +- Open an [Issue](https://fillname.org/issues/new). - Explain the behavior you would expect and the actual behavior. - Please provide as much context as possible and describe the *reproduction steps* that someone else can follow to recreate the issue on their own. This usually includes your code. For good bug reports you should isolate the problem and create a reduced test case. - Provide the information you collected in the previous section. @@ -84,14 +84,14 @@ This section guides you through submitting an enhancement suggestion for fillnam #### Before Submitting an Enhancement - Make sure that you are using the latest version. -- Read the [documentation](https://potassco.org/fillname/) carefully and find out if the functionality is already covered, maybe by an individual configuration. -- Perform a [search](https://github.com/potassco/fillname/issues) to see if the enhancement has already been suggested. If it has, add a comment to an existing issue instead of opening a new one. +- Read the [documentation](https://fillname.org/) carefully and find out if the functionality is already covered, maybe by an individual configuration. +- Perform a [search](https://fillname.org/issues) to see if the enhancement has already been suggested. If it has, add a comment to an existing issue instead of opening a new one. - Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Keep in mind that we want features that will be useful to the majority of our users and not just a small subset. If you're just targeting a minority of users, consider writing an add-on/plugin library. #### How Do I Submit a Good Enhancement Suggestion? -Enhancement suggestions are tracked as [GitHub issues](https://github.com/potassco/fillname/issues). +Enhancement suggestions are tracked as [GitHub issues](https://fillname.org/issues). - Use a **clear and descriptive title** for the issue to identify the suggestion. - Provide a **step-by-step description of the suggested enhancement** in as many details as possible. diff --git a/LICENSE b/LICENSE index 6357844..3759b39 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2024 +Copyright (c) 2024 Mister Fillname Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/doc/content/installation.md b/doc/content/installation.md index d5cb677..d0a73f0 100644 --- a/doc/content/installation.md +++ b/doc/content/installation.md @@ -11,7 +11,7 @@ $ fillname -h ## Installing with pip -The python fillname package can be found [here](https://pypi.org/project/fillname/). +The python fillname package can be found [here](https://fillname.org/). ```console $ pip install fillname @@ -21,7 +21,7 @@ $ pip install fillname ### Installing from source -The project is hosted on [github](https://github.com/potassco/fillname) and can +The project is hosted on [github](https://fillname.org/) and can also be installed from source. ```{warning} @@ -35,7 +35,7 @@ The `setuptools` package is required to run the commands below. Execute the following command in the top level fillname directory: ```console -$ git clone https://github.com/potassco/fillname +$ git clone https://fillname.org/ $ cd fillname $ pip install -e .[all] ``` diff --git a/init.py b/init.py index ed4e4ae..1e0aa1e 100755 --- a/init.py +++ b/init.py @@ -5,34 +5,65 @@ import os import re +import subprocess -def read(prompt, regex): +def read(prompt, regex, default): """ Read a string from command line. The string has to match the given regular expression. """ + if default: + prompt += f" [{default}]" + prompt += ": " + while True: ret = input(prompt) + if not ret and default: + ret = default match = re.match(regex, ret) if match is not None: return ret print(f"the project name has to match the regular expression: {regex}") +def git_config_get(attr): + """ + Get a git config value. + """ + try: + return subprocess.check_output(["git", "config", "--get", attr]).decode().strip() + except subprocess.CalledProcessError: + return None + def main(): """ Rename the project. """ - project = read("project name: ", r"^[a-z][a-z0-9_]*$") - author = read("author: ", r".+") - email = read("email: ", r".+") + + author = git_config_get("user.name") + email = git_config_get("user.email") + origin = git_config_get("remote.origin.url") + url, project = None, None + + if origin is not None: + match = re.match(r"^.*[:/]([^:/]*)/([^/]*)(\.git)?$", origin) + if match is not None: + org, project = match.group(1), match.group(2) + url = f"https://github.com/{org}/{project}/" + project = project.replace("-", "_") + + project = read("project name", r"^[a-z][a-z0-9_]*$", project) + author = read("author", r".+", author) + email = read("email", r".+", email) + url = read("url", r".+", url) replacements = { - "fillname": project, "author@fillname.com": email, "Mister Fillname": author, + "https://fillname.org/": url, + "fillname": project, } def replace(filepath): @@ -48,8 +79,8 @@ def replace(filepath): ".pre-commit-config.yaml", "noxfile.py", "pyproject.toml", - "setup.cfg", "CONTRIBUTING.md", + "DEPLOYMENT.md", "DEVELOPMENT.md", "LICENSE", "README.md", diff --git a/pyproject.toml b/pyproject.toml index 0207c33..33ccba6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,7 @@ dynamic = [ "version" ] readme = "README.md" [project.urls] -Hompage = "https://potassco.org/" +Hompage = "https://fillname.org/" [project.optional-dependencies] format = [ "black", "isort", "autoflake" ] From 9c0e059c85c71f7d2a4bee1341eb2ba9645604d0 Mon Sep 17 00:00:00 2001 From: Roland Kaminski Date: Thu, 22 Feb 2024 09:03:14 +0100 Subject: [PATCH 10/10] lower version (closes #34) --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 374b423..d1b77f8 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,5 @@ # Changes -## v1.0.0 +## v0.1.0 - create project