Skip to content

Commit

Permalink
First commit of new files
Browse files Browse the repository at this point in the history
  • Loading branch information
sosey committed Nov 25, 2024
1 parent 841c62b commit 75da634
Show file tree
Hide file tree
Showing 71 changed files with 3,315 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# automatically requests pull request reviews for files matching the given pattern; the last match takes precendence

* @Roman-Supernova-PIT/Software\ Admins @sosey
28 changes: 28 additions & 0 deletions .github/workflows/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: 2
updates:

# maintain dependencies for pip
- package-ecosystem: pip
directory: "/"
target-branch: "main"
schedule:
interval: weekly
open-pull-requests-limit: 10
reviewers:
- "sosey"
allow:
- dependency-type: direct
- dependency-type: indirect
commit-message:
prefix: "fix: "

# maintain dependencies for github-actions
- package-ecosystem: "github-actions"
directory: "/"
target-branch: "main"
reviewers:
- "sosey"
schedule:
interval: weekly
commit-message:
prefix: "fix: "
25 changes: 25 additions & 0 deletions .github/workflows/sphinx-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: "Deploy Sphinx documentation to Pages"

on:
push:
branches: [gh-pages] # branch to trigger deployment

# Cancel any in-progress job or run
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true


jobs:
pages:
runs-on: ubuntu-20.04
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
permissions:
pages: write
id-token: write
steps:
- id: deployment
uses: sphinx-notes/pages@a7b173ecba074b270b37c64007c1edfd8465892 # v3.1
21 changes: 21 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "Run template tests"

on:
push:
branches:
- main
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@v1
with:
envs: |
- linux: py311-test
- linux: py312-test
- linux: py313-test
- linux: build_docs
145 changes: 145 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
_build
.vscode
.tmp
.tox

# Python
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Pycharm project settings
.idea

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# Vscode plugin
.history

# Just in case you want to test out the defaults in the repo
packagename
None/
9 changes: 9 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: 2

build:
os: ubuntu-22.04
tools:
python: mambaforge-4.10

conda:
environment: docs/rtd_environment.yaml
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Roman Supernova PIT Packaging Guide
===================================

The `Roman Supernova PIT Python Packaging Guide <https://Roman-Supernova-PIT.github.io/package-template/>`__ is based on the OpenAstronomy package and contains an embedded `cookiecutter <https://cookiecutter.readthedocs.io/>`__ template.
Empty file added codespell-ignore.txt
Empty file.
32 changes: 32 additions & 0 deletions cookiecutter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"package_name": "packagename",
"module_name": "{{ cookiecutter.package_name|lower()|replace(' ', '_')|replace('-', '_') }}",
"short_description": "Developed by the Roman Supernova PIT",
"author_name": "Roman Supernova PIT",
"author_email": "[email protected]",
"github_username": "sosey",
"pit_name": "Roman-Supernov-PIT",
"project_url": "https://github.com/Roman-Supernova-PIT",
"license": [
"BSD 3-Clause"
],
"minimum_python_version": [
"3.10",
"3.11",
"3.12",
"3.13"
],
"use_compiled_extensions": "n",
"enable_dynamic_dev_versions": "n",
"include_example_code": "n",
"include_github_workflows": "y",
"_sphinx_theme": "alabaster",
"_parent_project": "",
"_install_requires": "",
"_copy_without_render": [
"docs/_templates",
"docs/_static",
".github/workflows",
".github/"
]
}
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?= -W
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
11 changes: 11 additions & 0 deletions docs/advanced/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Advanced Topics
===============

This section of the guide goes into more details on specific topics, or choices
the guide has made. You shouldn't need to read or understand anything in this
section to get up and running with a package, but you may want to refer to it if
you have questions.


.. toctree::
versioning
72 changes: 72 additions & 0 deletions docs/advanced/versioning.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
.. _versions:

Specifying the Version of your Package
======================================

Synchronising the version information about your package between, the git
repository, the python source code and the python package metadata can be
complex.

We strongly recommend using `setuptools_scm <https://github.com/pypa/setuptools_scm>`__ to do this.
With a little effort and understanding it is possible to make the git history
the single source of truth for all your version information, for your releases
and any development installs.

.. _setuptools-scm:

``setuptools_scm``
------------------

``setuptools_scm`` is an extension to the ``setuptools`` package, which performs two functions:

* It calculates the version number from the git history.
* It uses the git repository to get a list of all files to include in the package.

This section is focusing on the first one, the second is discussed in :ref:`data`.

``setuptools_scm`` works by calling ``$ git describe`` which returns information
about the current version of the repository, based on distance away from the
last tag **on the current branch**.

This means that with a little parsing, this information can be used to determine
the version of the package at the point where you build packages to release them on
PyPI (as described in :ref:`releasing`) or when someone accesses
``my_package.__version__``.

When just considering these built packages ``setuptools_scm`` works by running
``git describe`` at the time you build the package and then saving the output
into the code (if configured) and metadata of the package. If you use the
default configuration of the template included with this guide, after installing
the package the contents of the ``my_package/_version.py`` file would be::

# coding: utf-8
# file generated by setuptools_scm
# don't change, don't track in version control
__version__ = version = '0.1.dev0'
__version_tuple__ = version_tuple = (0, 1, 'dev0')

This file is used to provide the ``__version__`` attribute of ``my_package``.

.. _dev-versions:

Dynamic Development Versions
----------------------------

The final piece of this puzzle is versions for packages installed in "editable"
mode from a git repository. By default when using ``setuptools_scm`` when you
run ``pip install -e ./`` in your git checkout, it will run ``git describe`` and
encode the current version into the ``_version.py`` file described above. The
problem with this approach is that the version number in ``_version.py`` will
not change, as you make new commits or even add new tags.

The solution to this is to dynamically calculate the version on access of
``__version__`` with ``setuptools_scm``, however, you don't want to do this for
non-development installations as it's slow and requires ``setuptools_scm`` to
be installed.

The solution to this implemented in the template (behind an opt-in option) is to
make a subpackage called `_dev` which is not included in the dists (it is
excluded in ``MANIFEST.in``) which invokes setuptools. This ``_dev`` package is
then invoked by the ``my_pacakge/version.py`` file, which will fall back to
reading the static version from ``my_package/_version.py`` file if it can't
access ``_dev`` (in the case where it's not a dev install).
Loading

0 comments on commit 75da634

Please sign in to comment.