Skip to content

Commit

Permalink
Merge pull request #403 from simonsobs/koopman/modernize-packaging
Browse files Browse the repository at this point in the history
Switch build-backend from setuptools to hatchling
  • Loading branch information
BrianJKoopman authored Sep 11, 2024
2 parents fe03421 + 9d7caf0 commit fa333dd
Show file tree
Hide file tree
Showing 14 changed files with 144 additions and 3,065 deletions.
2 changes: 0 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@ in-place = true
recursive = true
aggressive = 2
exclude =
ocs/_version.py,
versioneer.py,
docs/conf.py,
1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# dynamic package version
ocs/_version.py

# local sqlite db's
*.db

Expand Down
2 changes: 0 additions & 2 deletions MANIFEST.in

This file was deleted.

3 changes: 3 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
]
extensions += ['sphinxarg.ext']

# support inline tabs
extensions += ['sphinx_inline_tabs']

# Present auto-documented members in source order (rather than alphabetical).
autodoc_default_options = {
'member-order': 'bysource',
Expand Down
52 changes: 35 additions & 17 deletions docs/developer/writing-plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,47 @@ within the ``__main__`` block.
Package Entry Point
-------------------
After you have created the plugin file, you need to add an entry point to
``setup.py``. This will register your package for discovery by ocs. This looks
like (assuming the plugin file is called ``plugin.py`` and lives at the top
level of the package):
``pyproject.toml`` or ``setup.py``. This will register your package for
discovery by ocs. This looks like (assuming the plugin file is called
``plugin.py`` and lives at the top level of the package):

.. code-block:: python
.. tab:: pyproject.toml

.. code-block::
[project.entry-points.'ocs.plugins']
<plugin name> = '<package name>.plugin'
.. tab:: setup.py

.. code-block:: python
entry_points={
'ocs.plugins': [
'<plugin name> = <package name>.plugin',
],
},
entry_points={
'ocs.plugins': [
'<plugin name> = <package name>.plugin',
],
},
Plugin name should just match the package name, however the group name must
always be ``ocs.plugins`` in order for OCS to recognize the plugin. For
Plugin name should typically match the package name, however the group name
must always be ``ocs.plugins`` in order for OCS to recognize the plugin. For
example, if your package was called ``my_ocs_pkg`` this would be:

.. code-block:: python
.. tab:: pyproject.toml

.. code-block::
[project.entry-points.'ocs.plugins']
my_ocs_pkg = 'my_ocs_pkg.plugin'
.. tab:: setup.py

.. code-block:: python
entry_points={
'ocs.plugins': [
'my_ocs_pkg = my_ocs_pkg.plugin',
],
},
entry_points={
'ocs.plugins': [
'my_ocs_pkg = my_ocs_pkg.plugin',
],
},
Agent Entry Point
-----------------
Expand Down
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
sphinx>=5.0.0
sphinx_rtd_theme>=2.0.0
sphinx-argparse>=0.4.0
sphinx-inline-tabs
24 changes: 22 additions & 2 deletions ocs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,25 @@

from . import site_config # noqa: F401

from . import _version
__version__ = _version.get_versions()['version']
# Define the variable '__version__':
# This has the closest behavior to versioneer that I could find
# https://github.com/maresb/hatch-vcs-footgun-example
try:
# If setuptools_scm is installed (e.g. in a development environment with
# an editable install), then use it to determine the version dynamically.
from setuptools_scm import get_version

# This will fail with LookupError if the package is not installed in
# editable mode or if Git is not installed.
__version__ = get_version(root="..", relative_to=__file__, version_scheme="no-guess-dev")
except (ImportError, LookupError):
# As a fallback, use the version that is hard-coded in the file.
try:
from ocs._version import __version__ # noqa: F401
except ModuleNotFoundError:
# The user is probably trying to run this without having installed
# the package, so complain.
raise RuntimeError(
"ocs is not correctly installed. "
"Please install it with pip."
)
Loading

0 comments on commit fa333dd

Please sign in to comment.