Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

67 changes: 64 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
pip list
micromamba list
micromamba remove --force openmmforcefields
python -m pip install .
python -m pip install . --no-deps

- name: Conda Environment Information
run: |
Expand All @@ -68,7 +68,7 @@ jobs:
- name: Test Installed Package (With Espaloma)
if: matrix.python-version == '3.12'
env:
COV_ARGS: --cov=openmmforcefields --cov-config=setup.cfg --cov-append --cov-report=xml
COV_ARGS: --cov=openmmforcefields --cov-config=pyproject.toml --cov-append --cov-report=xml
LOGLEVEL: "INFO"
KMP_DUPLICATE_LIB_OK: "True"
MATRIX_OS: ${{ matrix.os }}
Expand All @@ -87,7 +87,7 @@ jobs:
- name: Test Installed Package
if: matrix.python-version != '3.12'
env:
COV_ARGS: --cov=openmmforcefields --cov-config=setup.cfg --cov-append --cov-report=xml
COV_ARGS: --cov=openmmforcefields --cov-config=pyproject.toml --cov-append --cov-report=xml
LOGLEVEL: "INFO"
KMP_DUPLICATE_LIB_OK: "True"
run: |
Expand Down Expand Up @@ -116,3 +116,64 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
fail_ci_if_error: false # I don't want this to cause CI failures when a developer pushes to a fork

wheel:
name: Build and test installed wheel
runs-on: ubuntu-latest

permissions:
contents: read

steps:
- name: Check out repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0 # setuptools-scm needs Git history and tags
persist-credentials: false

- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.12"

- name: Build and validate distributions
run: |
python -m pip install build twine
python -m build --sdist --wheel
python -m twine check dist/*

- name: Install wheel with test dependencies
run: |
wheels=(dist/*.whl)
test "${#wheels[@]}" -eq 1

# Install the actual wheel and resolve dependencies
# from pyproject.toml, including both optional extras.
python -m pip install "${wheels[0]}[test,gaff]"

python -m pip check

- name: Verify installed distribution version
working-directory: /tmp
run: |
python -I - <<'PY'
from importlib.metadata import distribution, version
from pathlib import Path

import openmmforcefields

dist = distribution("OpenMMForceFields")

assert openmmforcefields.__version__ == version("OpenMMForceFields")
print(f"Version: {openmmforcefields.__version__}")
print(f"Imported from: {openmmforcefields.__file__}")
PY

- name: Run tests against installed wheel
working-directory: /tmp
run: |
python -I -m pytest \
--pyargs openmmforcefields.tests \
-n logical \
-vv \
--durations=20
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
include LICENSE
include MANIFEST.in
include versioneer.py

graft openmmforcefields
global-exclude *.py[cod] __pycache__ *.so
20 changes: 10 additions & 10 deletions devtools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ This directory contains the files to setup the Conda environment for testing pur
* `git tag -a X.Y.Z [latest pushed commit] && git push --follow-tags`
- [ ] Get the PR merged in

## Versioneer Auto-version
[Versioneer](https://github.com/warner/python-versioneer) will automatically infer what version
is installed by looking at the `git` tags and how many commits ahead this version is. The format follows
[PEP 440](https://www.python.org/dev/peps/pep-0440/) and has the regular expression of:
```regexp
\d+.\d+.\d+(?\+\d+-[a-z0-9]+)
```
If the version of this commit is the same as a `git` tag, the installed version is the same as the tag,
e.g. `openmmforcefields-0.1.2`, otherwise it will be appended with `+X` where `X` is the number of commits
ahead from the last tag, and then `-YYYYYY` where the `Y`'s are replaced with the `git` commit hash.
## Git-derived versioning

[setuptools-scm](https://setuptools-scm.readthedocs.io/) determines the package
version from Git tags at build time. Builds at a release tag use the tagged
version, e.g. 0.16.0. Commits after a tag use a PEP 440 development version,
such as 0.16.1.dev11+g0edd3bb81; local builds from a dirty checkout can also
include a dirty-tree suffix. The generated openmmforcefields/_version.py is
included in the wheel but is not tracked in Git.

Build requirements and version configuration are declared in pyproject.toml.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
copyright = "2026 Stanford University and the Authors"
author = "Stanford University"

# version specified in ../setup.py
# Version determined by setuptools-scm from Git tags at build time.
version = importlib.metadata.version("openmmforcefields")

repo = git.Repo(search_parent_directories=True)
Expand Down
6 changes: 1 addition & 5 deletions openmmforcefields/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# Add imports here
# Handle versioneer
from openmmforcefields.utils import get_ffxml_path

from . import _version

__version__ = _version.get_versions()["version"]
from ._version import __version__

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably want

from importlib.metadata import version

__version__ = version("openmmforcefields")

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still write out a version file:
(from pyproject.toml)

[tool.setuptools_scm]
version_file = "openmmforcefields/_version.py"

So this is correct, I did that since it works + it would save someone who uses that file downstream, but if you think that isn't worth saving then I can not write out that file + use the method you suggest.

Loading
Loading