Skip to content

Commit

Permalink
Modernize packaging and CI (#81)
Browse files Browse the repository at this point in the history
* Move all setup metadata to pyproject.toml

* Restructure workflow to use uv

* Use pyproject.toml as cache key

* Use setup-uv's own cache handling

* Use strings for Python versions

* Specify that UV uses system python

* Specify specific patch version of 3.6

* Test against 3.7

* Use uv pip install of sync

* Revert back to specifying latest Python without x

* Specify system python in each step

* Revert "Specify system python in each step"

This reverts commit 752a640.

* Revert "Use uv pip install of sync"

This reverts commit 67eb8bf.

* Use UV to install Python

* Specify a requires-python entry

* Test against 3.7

* Test against Python 3.8

* Test against Python 3.9

* Work-around llvm installation issues for numba dependency

* Install openmpi on ubuntu

* Specify dev dependencies

* Set-up mpi to make sure mpi4py can install

* Pin numba instead of llvm

* Reorder dependencies

* Drop support for Python 3.6 and 3.7, add support for 3.11 and 3.12

* Test specifically on Python 3.12

* Add six as optional dependency

* Set up Python while synching

* Make compatible with higher patch versions of 3.12

* Bump numba bound

* Require Python 3.9

* Use importlib to get e3fp version

* Use uv also to build the docs

* Remove conda environment files

* Fix outdated doctest

* Run pytest verbosely

* Set RDMAV_FORK_SAFE

* Update installation instructions

* Build docs from the correct source dir

* Revert "Run pytest verbosely"

This reverts commit 0838e20.

* Explicitly request XML coverage report

* Remove setup.py

* Use UV for building and publishing to PyPI

* Switch from setuptools to flit

* Setup uv the same for both actions
  • Loading branch information
sethaxen authored Nov 17, 2024
1 parent 97aac93 commit 29b662d
Show file tree
Hide file tree
Showing 12 changed files with 160 additions and 197 deletions.
41 changes: 15 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,35 @@ on:
branches: [master]
pull_request:

env:
# Setting RDMAV_FORK_SAFE=1 to avoid libfabric EFA provider issues with
# fork() on Python 3.9 and Ubuntu.
RDMAV_FORK_SAFE: 1

jobs:
test:
name: Python ${{ matrix.python-version }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-latest", "macos-latest"]
python-version: [3.6, 3]
python-version: ['3.9', '3.12']
fail-fast: false
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Cache conda packages
uses: actions/cache@v1
env:
# Increase this value to reset cache if environment.yml has not changed
CACHE_NUMBER: 0
with:
path: ~/conda_pkgs_dir
key: Python${{ matrix.python-version }}-${{ matrix.os }}-${{ hashFiles('environment.yml') }}
- name: Set-up conda and install dependencies
uses: conda-incubator/setup-miniconda@v2
- name: Setup MPI
uses: mpi4py/setup-mpi@v1
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
python-version: ${{ matrix.python-version }}
auto-update-conda: true
environment-file: environment.yml
activate-environment: test_env
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
- name: Build package
shell: bash -l {0}
run: |
python setup.py build_ext --inplace
python setup.py install
version: "0.5.2"
- name: Install the project
run: uv sync --all-extras --dev --python ${{ matrix.python-version }}
- name: Run tests
shell: bash -l {0}
run: |
conda install -c conda-forge pytest pytest-cov mock
pytest --cov=e3fp --cov-report=xml e3fp
run: uv run pytest --cov=e3fp --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: false
39 changes: 15 additions & 24 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,18 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
python -m pip install setuptools wheel
- name: Build wheel
run: |
python setup.py sdist bdist_wheel
- name: Test wheel
run: |
mkdir install_test
cd install_test
python -m pip install ../dist/*.whl
python -c "import e3fp"
cd ..
- name: Upload to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "0.5.2"
- name: Build the project
run: uv build --no-sources
- name: Publish to PyPI
run: uv publish --username __token__ --password ${{ secrets.PYPI_API_TOKEN }}
- name: Test package installation
run: uv run --with e3fp --no-project -- python -c "import e3fp"
16 changes: 12 additions & 4 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
conda:
file: doc/environment.yml
python:
setup_py_install: true
version: 2

build:
os: "ubuntu-22.04"
tools:
python: "3.12"
commands:
- asdf plugin add uv
- asdf install uv latest
- asdf global uv latest
- uv sync --extra docs --frozen
- uv run -m sphinx -T -b html -d docs/_build/doctrees -D language=en doc/source $READTHEDOCS_OUTPUT/html
10 changes: 0 additions & 10 deletions doc/environment.yml

This file was deleted.

3 changes: 2 additions & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import importlib.metadata
import os
import sys

Expand All @@ -24,7 +25,7 @@
if not ON_RTD:
sys.path.insert(0, os.path.abspath('../../'))

from e3fp import __version__ as e3fp_version
e3fp_version = importlib.metadata.version('e3fp')

USE_DEFAULT_THEME = ON_RTD
try:
Expand Down
81 changes: 36 additions & 45 deletions doc/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,89 +38,80 @@ The following packages are required for the specified features:

+ h5py_

- faster fingerprint metric calculations:

+ numba_


Installation
------------

The following installation approaches are listed in order of recommendation.
All but the first of these approaches requires a prior installation of RDKit_.

Option 1: Install with Conda
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

E3FP is on the `Anaconda distribution`_. Conda is a cross-platform package
manager. This approach is highly recommended as it installs *all* required
packages.

1. Install with

.. code:: bash
Option 1: Install with Pip
~~~~~~~~~~~~~~~~~~~~~~~~~~

$ conda create -c conda-forge --name e3fp_env e3fp
$ conda activate e3fp_env
Basic installation:

2. To install the optional Python dependencies, run
.. code:: bash
.. code:: bash
$ pip install e3fp
$ conda install -c conda-forge mpi4py h5py standardiser
With optional dependencies:

To get the latest version of E3FP, follow :ref:`Option 3: Clone the Repository`.
.. code:: bash
Option 2: Install with Pip
~~~~~~~~~~~~~~~~~~~~~~~~~~
$ pip install e3fp[optional]
1. Install with
.. code:: bash
Option 2: Install from conda-forge
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

$ pip install e3fp
E3FP is available on conda-forge.

2. To install the optional Python dependencies, run
.. code:: bash
.. code:: bash
$ conda create -n e3fp_env -c conda-forge e3fp
$ conda activate e3fp_env
$ pip install mpi4py h5py standardiser
To install optional dependencies:

Option 3: Clone the Repository
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code:: bash
1. Download this repository to your machine.
$ conda install -c conda-forge mpi4py h5py standardiser
- Clone this repository to your machine with
Option 3: Install for development
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code:: bash
1. Clone the repository:

$ git clone https://github.com/keiserlab/e3fp.git
$ cd e3fp
.. code:: bash
- OR download an archive by navigating to the repository_ and clicking
"Download ZIP". Extract the archive.
$ git clone https://github.com/keiserlab/e3fp.git
$ cd e3fp
2. Install the optional dependencies and any required ones using pip or conda.
2. Install for development in an already-activated environment.

.. note:: The easiest way to install the dependencies is with
You can do this using pip:

.. code:: bash
.. code:: bash
$ conda env create --name e3fp_env --file environment.yml
$ conda activate e3fp_env
$ pip install -e .[dev]
3. Install with
Or use uv_ to set up a development environment:

.. code:: bash
.. code:: bash
$ python setup.py build_ext --inplace
$ python setup.py install
$ uv sync --all-extras --dev
Testing
-------

After installation, it is recommended to run all tests with ``pytest``.
After running :code:`pip install pytest` or :code:`conda install -c conda-forge pytest`, run
Run tests using pytest:

.. code:: bash
$ pip install pytest # if not already installed
$ pytest e3fp
Expand Down
3 changes: 2 additions & 1 deletion doc/source/substitutions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
.. _standardiser: https://wwwdev.ebi.ac.uk/chembl/extra/francis/standardiser
.. _cxcalc: https://docs.chemaxon.com/display/CALCPLUGS/cxcalc+command+line+tool
.. _h5py: http://www.h5py.org/
.. _Anaconda distribution: https://docs.continuum.io/anaconda
.. _numba: https://numba.pydata.org/
.. _Anaconda: https://anaconda.org/conda-forge/e3fp
.. _uv: https://docs.astral.sh/uv/
.. _repository: https://github.com/keiserlab/e3fp
.. _paper repository: https://github.com/keiserlab/e3fp-paper
.. _issue tracker: https://github.com/keiserlab/e3fp/issues
Expand Down
4 changes: 2 additions & 2 deletions e3fp/fingerprint/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ class FingerprintDatabase(object):
Alternatively, the underlying `scipy.sparse.csr_matrix` may be accessed.
>>> db.array
<Compressed Sparse Row sparse matrix of dtype 'bool'
...with 327 stored elements and shape (3, 1024)>
<3x1024 sparse matrix of type '<class 'numpy.bool'>'
...with 327 stored elements in Compressed Sparse Row format>
>>> db.array.toarray()
array([[False, False, False, ..., False, False, False],
[False, False, False, ..., False, False, False],
Expand Down
16 changes: 0 additions & 16 deletions environment.yml

This file was deleted.

77 changes: 76 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,77 @@
[build-system]
requires = ["setuptools", "wheel"]
requires = ["flit_core >=3.2,<4"]
build-backend = "flit_core.buildapi"

[project]
name = "e3fp"
dynamic = ["version"]
requires-python = ">=3.9, <3.13"
description = "Molecular 3D fingerprinting"
readme = "README.rst"
authors = [
{name = "Seth Axen", email = "seth.axen@gmail.com"},
]
license = {text = "LGPLv3"}
keywords = ["e3fp", "3d", "molecule", "fingerprint", "conformer"]
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
"Operating System :: OS Independent",
"Development Status :: 4 - Beta",
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
"Topic :: Scientific/Engineering :: Chemistry",
"Topic :: Software Development :: Libraries :: Python Modules",
]
dependencies = [
"mmh3>=2.3.1",
"numpy>=1.11.3",
"rdkit>=2016.03.4",
"scipy>=0.18.0",
"sdaxen_python_utilities>=0.1.5",
"smart_open>=1.8.3",
]

[project.optional-dependencies]
optional = [
"h5py",
"mpi4py",
"numba",
"six", # needed by standardiser, but not listed as a dependency
"standardiser",
]
test = [
"mock",
"pytest",
"e3fp[optional]",
]
dev = [
"e3fp[test]",
"pytest-cov",
]
docs = [
"sphinx",
"sphinxcontrib-programoutput"
]

[project.urls]
Homepage = "https://github.com/keiserlab/e3fp"
Download = "https://github.com/keiserlab/e3fp/tarball/{version}"

[tool.setuptools.packages.find]
include = ["e3fp", "e3fp.*"]

[tool.setuptools.dynamic]
version = {attr = "e3fp.version"}

[tool.pytest.ini_options]
addopts = "-ra -q"
testpaths = ["e3fp/test"]

# https://github.com/astral-sh/uv/issues/6281
[tool.uv]
constraint-dependencies = ["numba>=0.60.0"]
2 changes: 0 additions & 2 deletions setup.cfg

This file was deleted.

Loading

0 comments on commit 29b662d

Please sign in to comment.