Skip to content

Commit 827203a

Browse files
authored
Document python package development process (#24)
* Document ability to override error handling of R CMD check * Document development process * Document development process
1 parent 6a1aa62 commit 827203a

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

.github/workflows/R-reusable.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,5 @@ jobs:
6969
working-directory: R/bican.mccarroll.${{ inputs.package_name }}
7070
upload-snapshots: true
7171
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
72+
# for some reason this needs to be quoted lest it gets passed as (error)
7273
error-on: ${{ format('"{0}"', inputs.error-on) }}

R/README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ How to create an R package for the bican-mccarroll-manuscript1 repository.
33

44
## Creating a package using RStudio
55

6-
1. Get started with github and create a branch using the [basic github workflow](https://docs.google.com/document/d/1A5T8ZVhNxP0GCQmmo1R8qaPPXah9cvSLI96U3TZdYos/edit?tab=t.0)
6+
1. Get started with github by cloning the broadinstitute/bican-mccarroll-manuscript1 repository and creating a branch using the [basic github workflow](https://docs.google.com/document/d/1A5T8ZVhNxP0GCQmmo1R8qaPPXah9cvSLI96U3TZdYos/edit?tab=t.0)
77
1. In RStudio, go to `File` -> `New Project...`
88
1. Pick `New Directory`
99
1. Pick `R Package`
@@ -14,13 +14,27 @@ How to create an R package for the bican-mccarroll-manuscript1 repository.
1414
- `cp .github/workflow-templates/roxygen.yml .github/workflows/roxygen-frob.yml`
1515
1. Edit these two files and replace `<package_name>` with your package name
1616
1. Do your package development as usual, including adding documentation using roxygen2.
17+
1. Create a `README.md` file in the root of your package. You can copy the one in R/bican.mccarroll.helloworld/ and modify it as appropriate.
1718
1. When you are ready to commit your changes, use the [basic github workflow](https://docs.google.com/document/d/1A5T8ZVhNxP0GCQmmo1R8qaPPXah9cvSLI96U3TZdYos/edit?tab=t.0) to commit and push your changes.
1819

1920
Note that for now we are requiring review before PRs. We can change if this is cumbersome.
2021

2122
Note also that the github actions are not active until they are merged into the main branch, so they won't run
2223
until they have been merged. Subsequent PRs will trigger the R cmd check action.
2324

25+
## Handling less-than-perfect R CMD check results in continuous integration
26+
Ideally your package will pass R CMD check with no errors or warnings, but if that is not possible,
27+
you can set the `error_on` parameter of rcmdcheck in R-frob.yml like this:
28+
```yaml
29+
jobs:
30+
call-R-reusable:
31+
uses: ./.github/workflows/R-reusable.yml
32+
with:
33+
package_name: helloworld
34+
error-on: 'error' # don't fail if warnings or notes are present
35+
secrets: inherit
36+
```
37+
2438
## Generating documentation via github actions
2539
You can cause roxygen2 to run via github action by creating a PR, and then commenting on the PR
2640
with `/document.<package_name>`, e.g. `/document.frob`. This will trigger the roxygen action, which will generate the

python/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Creating a Python package
2+
How to create a Python package for the bican-mccarroll-manuscript1 repository.
3+
## Creating a package using PyCharm
4+
1. Get started with GitHub by cloning the broadinstitute/bican-mccarroll-manuscript1 repository and creating a branch using the [basic GitHub workflow](https://docs.google.com/document/d/1A5T8ZVhNxP0GCQmmo1R8qaPPXah9cvSLI96U3TZdYos/edit?tab=t.0).
5+
1. In PyCharm, go to `File` -> `New Project...`.
6+
1. Set the location of the project to `<your-git-sandbox>/bican-mccarroll-manuscript1/python/bican_mccarroll_<your-package-name>`, where `<your-package-name>` is the name of your package.
7+
1. I picked the following settings, which I'm not sure are the best:
8+
- Interpreter type: `Custom environment`
9+
- Environment: `Generate new`
10+
- Type: `Virtualenv`
11+
- Base python: `Python 3.9.6`
12+
1. Click `Create`.
13+
1. In the project view, create directories `src` and `tests` under the project root.
14+
1. Right-click the `src` directory and select `New` -> `Python Package`. Name it `bican_mccarroll_<your_package_name>`.
15+
1. Go to Settings -> Project -> Project Structure, and label 'src' and 'tests' as Sources and Tests, respectively.
16+
1. Develop your package as usual, including unit tests as appropriate.
17+
1. Put a `LICENSE` file in the root of your package, and a `README.md` file in the root of your package. You can copy the ones in python/bican_mccarroll_helloworld/ and modify the README.md as appropriate.
18+
1. Create a `pyproject.toml` file in the root of your package. You can copy the one in python/bican_mccarroll_helloworld/ and modify it as appropriate.
19+
1. When you are ready to commit your changes, use the [basic github workflow](https://docs.google.com/document/d/1A5T8ZVhNxP0GCQmmo1R8qaPPXah9cvSLI96U3TZdYos/edit?tab=t.0) to commit and push your changes.

0 commit comments

Comments
 (0)