From 2be493a143a5bdc81121f8c5003e9a3b857a9027 Mon Sep 17 00:00:00 2001 From: "Miguel Xochicale, PhD" Date: Fri, 18 Aug 2023 13:31:40 +0100 Subject: [PATCH] 110 - building package workflow (#130) Solves #110 Hi all, this PR includes adds local build of the package and few other changes to improve workflow. Let me know if you have any feedback. Thanks, -- Miguel --------- Co-authored-by: Paddy Roddy --- .gitignore | 4 ++ README.md | 60 +++++++++++++++++--- {{cookiecutter.project_slug}}/pyproject.toml | 1 + 3 files changed, 56 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 66dbf51b..58dd3591 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ *.egg-info *.pyc +*.idea + +#default project path +python-template diff --git a/README.md b/README.md index 851ff147..b7fc25c9 100644 --- a/README.md +++ b/README.md @@ -19,10 +19,14 @@ We've turned on [discussions](https://github.com/UCL-ARC/python-tooling/discussi ## Using this template -1. Install [cookieninja] - ``` - pip install cookieninja - ``` +1. Install [cookieninja](https://libraries.io/pypi/cookieninja) in a `conda`, `mamba` or `venv` environment (commented lines for conda example). + +``` +# conda create -n ptoolingVE pip -c conda-forge +# conda activate ptoolingVE +pip install cookieninja +``` + 2. Run cookieninja in the desired directory ``` cookieninja gh:ucl-arc/python-tooling @@ -82,13 +86,14 @@ We've turned on [discussions](https://github.com/UCL-ARC/python-tooling/discussi ``` 5. To work on your project, initialise a git repository and _install_ it in editable mode. - (If you want to develop in a `venv` or `conda` environment, now is a good time to set that up) ``` cd PROJECT_SLUG git init - # conda create -n PROJECT_SLUG-dev python=3.11 - # conda activate PROJECT_SLUG-dev - python -m pip install -e . + python -m pip install -e ".[dev]" + ``` +6. Build your package + ``` + python -m build ``` ## Notes for developers @@ -113,6 +118,36 @@ To contribute: ### Development +- Clone repository + + - (Optional) Generate your SSH keys as suggested [here](https://docs.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent) + - (Optional) GitHub CLI as suggested [here](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account?tool=cli) + - Clone the repository by typing (or copying) the following line in a terminal at your selected path in your machine: + + ``` + git clone git@github.com:UCL-ARC/python-tooling.git + cd python-tooling + ``` + +- To create and remove your virtual environment + + ``` + conda create -n ptoolingVE pip -c conda-forge + conda activate ptoolingVE + conda deactivate ptoolingVE + conda remove -n ptoolingVE --all + ``` + +- To run template in the same path of this repo. + We do a test cookiecut of a dummy package and install it to ensure the template setup works. + + ``` + cookieninja . + cd python-template + git init + python -m pip install -e ".[dev]" + ``` + - To run cookieninja using a specific branch of the template: ``` @@ -125,7 +160,14 @@ To contribute: pytest -s ``` - We do a test cookiecut of a dummy package and install it to ensure the template setup works. +- To commit changes + + ``` + pre-commit run -a + git add . + git commmit -m 'message issue number (#NN)' + git push origin NN-future-branch + ``` - To build the docs locally diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index cb25e232..ab42390a 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -35,6 +35,7 @@ optional-dependencies = {dev = [ "build", "mypy", "pre-commit", + "pytest", "ruff", "tox>=4", "twine",