Skip to content

Commit

Permalink
update setup to latest cookiecutter (versiongit and pyproject)
Browse files Browse the repository at this point in the history
  • Loading branch information
luigibonati committed Nov 15, 2022
1 parent e26ff07 commit 77f514d
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 1,861 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mlcvs/_version.py export-subst
48 changes: 18 additions & 30 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,18 @@ name: CI

on:
# GitHub has started calling new repo's first branch "main" https://github.com/github/renaming
# Existing codes likely still have "master" as the primary branch
# Both are tracked here to keep legacy and new codes working
# The cookiecutter uses the "--initial-branch" flag when it runs git-init
push:
branches:
- "master"
- "main"
pull_request:
branches:
- "master"
- "main"
schedule:
# Nightly tests run on master by default:
# Weekly tests run on main by default:
# Scheduled workflows run on the latest commit on the default or base branch.
# (from https://help.github.com/en/actions/reference/events-that-trigger-workflows#scheduled-events-schedule)
- cron: "0 0 * * *"
- cron: "0 0 * * 0"

jobs:
test:
Expand All @@ -28,7 +25,7 @@ jobs:
python-version: [3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3

- name: Additional info about the build
shell: bash
Expand All @@ -37,34 +34,25 @@ jobs:
df -h
ulimit -a
# More info on options: https://github.com/marketplace/actions/provision-with-micromamba
- uses: mamba-org/provision-with-micromamba@main
with:
environment-file: devtools/conda-envs/test_env.yaml
environment-name: test
channels: conda-forge,defaults
extra-specs: |
python=${{ matrix.python-version }}
# More info on options: https://github.com/conda-incubator/setup-miniconda
- uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.python-version }}
environment-file: devtools/conda-envs/test_env.yaml

channels: conda-forge,defaults

activate-environment: test
auto-update-conda: false
auto-activate-base: false
show-channel-urls: true

- name: Install package

# conda setup requires this special shell
shell: bash -l {0}
run: |
python -m pip install . --no-deps
conda list
- name: Install package
# conda setup requires this special shell
shell: bash -l {0}
run: |
python -m pip install . --no-deps
micromamba list
- name: Run tests

# conda setup requires this special shell
shell: bash -l {0}

run: |
pytest -v --cov=mlcvs --cov-report=xml --color=yes mlcvs/tests/
Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
include LICENSE
include MANIFEST.in
include CODE_OF_CONDUCT.md
include versioneer.py

graft mlcvs
global-exclude *.py[cod] __pycache__ *.so
1 change: 1 addition & 0 deletions mlcvs/py.typed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# PEP 561 marker file. See https://peps.python.org/pep-0561/
85 changes: 85 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
[build-system]
requires = ["setuptools>=61.0", "versioningit~=2.0"]
build-backend = "setuptools.build_meta"

# Self-descriptive entries which should always be present
# https://packaging.python.org/en/latest/specifications/declaring-project-metadata/
[project]
name = "mlcvs"
description = "Machine learning collective variables for enhanced sampling"
dynamic = ["version"]
readme = "README.md"
authors = [
{ name = "Luigi Bonati", email = "[email protected]" }
]
license = { text = "BSD-3-Clause" }
# See https://pypi.org/classifiers/
classifiers = [
"License :: OSI Approved :: BSD License",
"Programming Language :: Python :: 3",
]
requires-python = ">=3.7"
# Declare any run-time dependencies that should be installed with the package.
#dependencies = [
# "importlib-resources;python_version<'3.10'",
#]

# Update the urls once the hosting is set up.
[project.urls]
"Source" = "https://github.com/luigibonati/mlcvs/"
"Documentation" = "https://mlcvs.readthedocs.io/"

[project.optional-dependencies]
test = [
"pytest>=6.1.2",
"pytest-runner"
]

[tool.setuptools]
# This subkey is a beta stage development and keys may change in the future, see https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html for more details
#
# As of version 0.971, mypy does not support type checking of installed zipped
# packages (because it does not actually import the Python packages).
# We declare the package not-zip-safe so that our type hints are also available
# when checking client code that uses our (installed) package.
# Ref:
# https://mypy.readthedocs.io/en/stable/installed_packages.html?highlight=zip#using-installed-packages-with-mypy-pep-561
zip-safe = false
# Let setuptools discover the package in the current directory,
# but be explicit about non-Python files.
# See also:
# https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html#setuptools-specific-configuration
# Note that behavior is currently evolving with respect to how to interpret the
# "data" and "tests" subdirectories. As of setuptools 63, both are automatically
# included if namespaces is true (default), even if the package is named explicitly
# (instead of using 'find'). With 'find', the 'tests' subpackage is discovered
# recursively because of its __init__.py file, but the data subdirectory is excluded
# with include-package-data = false and namespaces = false.
include-package-data = false
[tool.setuptools.packages.find]
namespaces = false
where = ["."]

# Ref https://setuptools.pypa.io/en/latest/userguide/datafiles.html#package-data
[tool.setuptools.package-data]
mlcvs = [
"py.typed"
]

[tool.versioningit]
default-version = "1+unknown"

[tool.versioningit.format]
distance = "{base_version}+{distance}.{vcs}{rev}"
dirty = "{base_version}+{distance}.{vcs}{rev}.dirty"
distance-dirty = "{base_version}+{distance}.{vcs}{rev}.dirty"

[tool.versioningit.vcs]
# The method key:
method = "git" # <- The method name
# Parameters to pass to the method:
match = ["*"]
default-tag = "1.0.0"

[tool.versioningit.write]
file = "mlcvs/_version.py"
8 changes: 0 additions & 8 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,5 @@ USE_TABS = False
# Flake8, PyFlakes, etc
max-line-length = 119

[versioneer]
# Automatic version numbering scheme
VCS = git
style = pep440
versionfile_source = mlcvs/_version.py
versionfile_build = mlcvs/_version.py
tag_prefix = ''

[aliases]
test = pytest
Loading

0 comments on commit 77f514d

Please sign in to comment.