From dc3e5a6fbe0dd02fa6966725ecef25412df754c4 Mon Sep 17 00:00:00 2001 From: David Grayson Date: Wed, 11 Dec 2024 04:28:36 +0000 Subject: [PATCH 1/5] feat: enable ccd updates from pip package --- README.rst | 3 +++ pyproject.toml | 3 +++ setup_ccd.py => src/biotite/setup_ccd.py | 8 ++++++-- 3 files changed, 12 insertions(+), 2 deletions(-) rename setup_ccd.py => src/biotite/setup_ccd.py (98%) diff --git a/README.rst b/README.rst index 5079d12f8..01d6b5793 100644 --- a/README.rst +++ b/README.rst @@ -71,6 +71,9 @@ Some functions require some extra packages: $ pip install biotite +After install, biotite's Chemical Component Dictionary (CCD) can be updated via + + $ biotite-setup-ccd Usage ----- diff --git a/pyproject.toml b/pyproject.toml index 2f8f47181..6875fe41e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -147,3 +147,6 @@ requires = [ "cython >= 3.0", ] build-backend = "hatchling.build" + +[project.scripts] +biotite-setup-ccd = "biotite.setup_ccd:main" \ No newline at end of file diff --git a/setup_ccd.py b/src/biotite/setup_ccd.py similarity index 98% rename from setup_ccd.py rename to src/biotite/setup_ccd.py index 8bcc67f8a..162ed7561 100644 --- a/setup_ccd.py +++ b/src/biotite/setup_ccd.py @@ -8,7 +8,7 @@ from biotite.structure.io.pdbx import * OUTPUT_CCD = ( - Path(__file__).parent / "src" / "biotite" / "structure" / "info" / "components.bcif" + Path(__file__).parent / "structure" / "info" / "components.bcif" ) CCD_URL = "https://files.wwpdb.org/pub/pdb/data/monomers/components.cif.gz" @@ -184,9 +184,13 @@ def _into_fitting_type(string_array, mask): return array -if __name__ == "__main__": +def main(): logging.basicConfig(level=logging.INFO, format="%(levelname)s:%(message)s") OUTPUT_CCD.parent.mkdir(parents=True, exist_ok=True) compressed_ccd = concatenate_ccd(["chem_comp", "chem_comp_atom", "chem_comp_bond"]) compressed_ccd.write(OUTPUT_CCD) + + +if __name__ == "__main__": + main() From 646c3113dc57cbff5aa7e209d5ed415978afecbc Mon Sep 17 00:00:00 2001 From: David Grayson Date: Sat, 14 Dec 2024 03:27:03 +0000 Subject: [PATCH 2/5] minor edits to setup instructions --- README.rst | 3 --- doc/install.rst | 4 ++-- pyproject.toml | 3 --- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/README.rst b/README.rst index 01d6b5793..5079d12f8 100644 --- a/README.rst +++ b/README.rst @@ -71,9 +71,6 @@ Some functions require some extra packages: $ pip install biotite -After install, biotite's Chemical Component Dictionary (CCD) can be updated via - - $ biotite-setup-ccd Usage ----- diff --git a/doc/install.rst b/doc/install.rst index 3b51fc4ef..8b468e0a5 100644 --- a/doc/install.rst +++ b/doc/install.rst @@ -67,7 +67,7 @@ After cloning the repository, navigate to its top-level directory (the one .. code-block:: console $ pip install . - $ python setup_ccd.py + $ python -m biotite.setup_ccd $ pip install . The `setup_ccd.py` script can also be used to update the internal CCD to the current @@ -80,7 +80,7 @@ Substitute the installation with the following commands instead: .. code-block:: console $ pip install -e . - $ python setup_ccd.py + $ python -m biotite.setup_ccd Common issues and solutions --------------------------- diff --git a/pyproject.toml b/pyproject.toml index 6875fe41e..2f8f47181 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -147,6 +147,3 @@ requires = [ "cython >= 3.0", ] build-backend = "hatchling.build" - -[project.scripts] -biotite-setup-ccd = "biotite.setup_ccd:main" \ No newline at end of file From 756d2a015677ad074189c9984b8ebca9c0d30d19 Mon Sep 17 00:00:00 2001 From: Patrick Kunzmann Date: Fri, 20 Dec 2024 10:19:34 +0100 Subject: [PATCH 3/5] Remove outdated information, as these processes now work automatically --- doc/contribution/deployment.rst | 41 +-------------------------------- 1 file changed, 1 insertion(+), 40 deletions(-) diff --git a/doc/contribution/deployment.rst b/doc/contribution/deployment.rst index 8ad460f0b..29c40ec71 100644 --- a/doc/contribution/deployment.rst +++ b/doc/contribution/deployment.rst @@ -4,14 +4,6 @@ This section describes how create and deploy a release build of the *Biotite* package and documentation. Therefore, this section primarily addresses the maintainers of the project. -CCD update ----------- -:mod:`biotite.structure.info` bundles selected information from the -`Chemical Component Dictionary `_ (CCD). -From time to time, this dataset needs an update to include new components -added to the CCD. -This is achieved by running ``setup_ccd.py``. - Creating a new release ---------------------- When a new *GitHub* release is created, the CI jobs building the distributions @@ -20,6 +12,7 @@ After the successful completion of these jobs, the artifacts are added to the release. The distributions for different platforms and Python versions are automatically uploaded to *PyPI*. +The documentation is also uploaded to this website via the CI. Conda release ------------- @@ -28,35 +21,3 @@ an automatic pull request for the new release of the `Conda package `_. If no dependencies changed, this pull request can usually be merged without further effort. - -Documentation website ---------------------- -The final step of the deployment is putting the directory containing the built -documentation onto the server hosting the website. - -The document root of the website should look like this: - -.. code-block:: - - ├─ .htaccess - ├─ latest -> x.y.z/ - ├─ x.y.z/ - │ ├─ index.html - │ ├─ ... - ├─ a.b.c/ - ├─ index.html - ├─ ... - -``x.y.z/`` and ``a.b.c/`` represent the documentation directories for two -different *Biotite* release versions. - -``.htaccess`` should have the following content: - -.. code-block:: apache - - RewriteBase / - RewriteEngine On - # Redirect if page name does not start with 'latest' or version identifier - RewriteRule ^(?!latest|\d+\.\d+\.\d+|robots.txt)(.*) latest/$1 [R=301,L] - - ErrorDocument 404 /latest/404.html \ No newline at end of file From 7e921353c7cb5cd5f5ad7b429749965c618e4dd1 Mon Sep 17 00:00:00 2001 From: Patrick Kunzmann Date: Fri, 20 Dec 2024 10:39:13 +0100 Subject: [PATCH 4/5] Update CI and docs for new CCD build process --- .github/workflows/test_and_deploy.yml | 6 +++--- doc/install.rst | 9 ++++----- pyproject.toml | 3 +-- src/biotite/setup_ccd.py | 4 +--- src/biotite/structure/info/ccd.py | 4 ++-- 5 files changed, 11 insertions(+), 15 deletions(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 85937ceb0..e532d3c70 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -72,14 +72,14 @@ jobs: id: cache-ccd with: path: ./src/biotite/structure/info/components.bcif - key: cache-${{ hashFiles('setup_ccd.py') }}-${{ hashFiles('components.cif.gz') }} + key: cache-${{ hashFiles('src/biotite/setup_ccd.py') }}-${{ hashFiles('components.cif.gz') }} - name: Remove CCD used for hashing run: rm components.cif.gz - name: Build internal CCD if: steps.cache-ccd.outputs.cache-hit != 'true' run: | - pip install . - python setup_ccd.py + pip install -e . + python -m biotite.setup_ccd - name: Install build backend run: pip install build - name: Build distribution diff --git a/doc/install.rst b/doc/install.rst index 8b468e0a5..d314ae05f 100644 --- a/doc/install.rst +++ b/doc/install.rst @@ -57,10 +57,10 @@ You can also install *Biotite* from the `project repository `_. However, in addition to building and installing the package, the internal `Chemical Component Dictionary (CCD) `_. for -:mod:`biotite.structure.info` needs to be built with the ``setup_ccd.py`` script. +:mod:`biotite.structure.info` needs to be built with the ``setup_ccd`` module. The script in turn requires *Biotite*. The solution to this chicken-and-egg problem is to first install Biotite without the -CCD, then build the CCD and finally install Biotite again. +CCD and build the CCD afterwards. After cloning the repository, navigate to its top-level directory (the one ``setup.py`` is in) and type the following: @@ -68,10 +68,9 @@ After cloning the repository, navigate to its top-level directory (the one $ pip install . $ python -m biotite.setup_ccd - $ pip install . -The `setup_ccd.py` script can also be used to update the internal CCD to the current -upstream version from the PDB. +``setup_ccd.py`` can also be used to update the internal CCD to the current upstream +version from the PDB. Having the *Biotite* installation always pointing to your repository clone is also possible. diff --git a/pyproject.toml b/pyproject.toml index 2f8f47181..2c6ae641a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,7 +58,7 @@ ignore = [ [tool.ruff.lint.per-file-ignores] # Due to `* import` of BCIF encoding -"setup_ccd.py" = ["F405", "F403"] +"src/biotite/setup_ccd.py" = ["F405", "F403"] # Due to imports after the PATH has been adjusted "doc/conf.py" = ["E402"] # Due to `from .module import *` imports in `__init__.py` modules @@ -109,7 +109,6 @@ exclude = [ "benchmarks", "doc", "environment.yml", - "setup_ccd.py", # .github, .gitignore, .gitattributes ".git*", ] diff --git a/src/biotite/setup_ccd.py b/src/biotite/setup_ccd.py index 162ed7561..0032dfcfb 100644 --- a/src/biotite/setup_ccd.py +++ b/src/biotite/setup_ccd.py @@ -7,9 +7,7 @@ import requests from biotite.structure.io.pdbx import * -OUTPUT_CCD = ( - Path(__file__).parent / "structure" / "info" / "components.bcif" -) +OUTPUT_CCD = Path(__file__).parent / "structure" / "info" / "components.bcif" CCD_URL = "https://files.wwpdb.org/pub/pdb/data/monomers/components.cif.gz" diff --git a/src/biotite/structure/info/ccd.py b/src/biotite/structure/info/ccd.py index adcbc92f0..8c791b554 100644 --- a/src/biotite/structure/info/ccd.py +++ b/src/biotite/structure/info/ccd.py @@ -53,7 +53,7 @@ def get_ccd(): return BinaryCIFFile.read(_CCD_FILE).block except FileNotFoundError: raise RuntimeError( - "Internal CCD not found. Please run 'setup_ccd.py' and reinstall Biotite." + "Internal CCD not found. Please run 'python -m biotite.setup_ccd'." ) @@ -68,7 +68,7 @@ def set_ccd_path(ccd_path): ---------- ccd_path : path-like The path to the custom CCD in BinaryCIF format, prepared with the - ``setup_ccd.py`` script. + ``setup_ccd.py`` module. Notes ----- From 41f103701116025991d8106df52495187beee940 Mon Sep 17 00:00:00 2001 From: Patrick Kunzmann Date: Fri, 20 Dec 2024 12:20:57 +0100 Subject: [PATCH 5/5] Add dunderscore attributes --- src/biotite/setup_ccd.py | 3 +++ tests/test_modname.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/biotite/setup_ccd.py b/src/biotite/setup_ccd.py index 0032dfcfb..b31c05e95 100644 --- a/src/biotite/setup_ccd.py +++ b/src/biotite/setup_ccd.py @@ -1,3 +1,6 @@ +__author__ = "Patrick Kunzmann" +__all__ = [] + import gzip import logging from collections import defaultdict diff --git a/tests/test_modname.py b/tests/test_modname.py index 39a394d8b..131c533bf 100644 --- a/tests/test_modname.py +++ b/tests/test_modname.py @@ -16,6 +16,9 @@ def find_all_modules(package_name, src_dir): """ module_names = [] for _, module_name, is_package in pkgutil.iter_modules([src_dir]): + if module_name == "setup_ccd": + # This module is not intended to be imported + continue full_module_name = f"{package_name}.{module_name}" if is_package: module_names.extend(