Skip to content

Commit eb28ce1

Browse files
authored
Merge pull request #2770 from galenlynch/packaging/pyproject.toml
Migrate from setup.py to pyproject.toml (hatchling)
2 parents 7f23f95 + 879a70c commit eb28ce1

40 files changed

Lines changed: 193 additions & 338 deletions

.github/workflows/github-actions-ci.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,10 @@ jobs:
5757
with:
5858
python-version: ${{ matrix.python-version }}
5959
cache: pip
60-
cache-dependency-path: |
61-
requirements.txt
62-
test_requirements.txt
60+
cache-dependency-path: pyproject.toml
6361
- name: Install
6462
run: |
65-
pip install -r test_requirements.txt
66-
pip install .
63+
pip install -e ".[test]"
6764
- name: Test
6865
run: |
6966
python -m pytest -n 4 ${{ (matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13') && '--cov=allensdk' || '' }}
@@ -86,8 +83,7 @@ jobs:
8683
--mount type=tmpfs,destination=/tmp \
8784
--rm \
8885
${{ matrix.image }} \
89-
/bin/bash -c "pip install -r requirements.txt; \
90-
pip install -r test_requirements.txt; \
86+
/bin/bash -c "pip install -e '.[test]'; \
9187
python -m pytest \
9288
--log-level=INFO \
9389
--capture=no \

.github/workflows/nightly.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ jobs:
2626
--mount type=tmpfs,destination=/tmp \
2727
--rm \
2828
${{ matrix.image }} \
29-
/bin/bash -c "pip install -r requirements.txt; \
30-
pip install -r test_requirements.txt; \
31-
pip install -e .; \
29+
/bin/bash -c "pip install -e '.[test]'; \
3230
python -m pytest \
3331
--log-level=INFO \
3432
--capture=no \

.github/workflows/notebook_runner.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,10 @@ jobs:
1818
with:
1919
python-version: ${{ matrix.python-version }}
2020
cache: pip
21-
cache-dependency-path: |
22-
requirements.txt
23-
dev_requirements.txt
24-
notebook_requirements.txt
21+
cache-dependency-path: pyproject.toml
2522
- name: Install
2623
run: |
27-
pip install -r requirements.txt
28-
pip install -r dev_requirements.txt
29-
pip install -r notebook_requirements.txt
30-
pip install .
24+
pip install -e ".[dev,notebooks]"
3125
ipython kernel install --name "python3" --user
3226
- name: Run notebooks
3327
run: |

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ debug.log
3232
/cell_types/
3333
example_ecephys_project_cache/
3434
.DS_Store
35-
/venv/
35+
/venv/

.readthedocs.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ sphinx:
1010
build:
1111
os: ubuntu-22.04
1212
tools:
13-
python: "3.8"
14-
13+
python: "3.13"
1514
python:
1615
install:
17-
- requirements: doc_requirements.txt
16+
- method: pip
17+
path: .
18+
extra_requirements:
19+
- docs
1820

1921
formats:
2022
- epub

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ If you are comfortable addressing this issue yourself, take a look at the [guide
3636
Adding example notebooks are a great way to contribute to documentation and help
3737
other users get started on the AllenSDK. Take a look at our [existing notebooks](https://github.com/AllenInstitute/AllenSDK/tree/master/doc_template/examples_root/examples/nb)
3838
as a general guide for the style and content. We have many great notebooks, but
39-
[Extracellular Electrophysiology Data](https://github.com/AllenInstitute/AllenSDK/blob/master/doc_template/examples_root/examples/nb/ecephys_session.ipynb) is a good one to take a look at to get a sense for what we're looking for. All new notebook contributions should be compatible with Python 3.6+.
39+
[Extracellular Electrophysiology Data](https://github.com/AllenInstitute/AllenSDK/blob/master/doc_template/examples_root/examples/nb/ecephys_session.ipynb) is a good one to take a look at to get a sense for what we're looking for. All new notebook contributions should be compatible with Python 3.10+.
4040

4141
Notebook Guidelines:
4242

@@ -112,14 +112,14 @@ visual git plugins, we prefer the following convention for branch naming:
112112
GH-712/bugfix/auto-reward-key
113113
GH-9999/feature/parallel-behavior-analysis
114114
```
115-
* Create an environment and install necessary requirements: `requirements.txt` and `test_requirements.txt`
115+
* Create an environment and install with test dependencies: `pip install -e ".[test]"`
116116
* Start writing code!
117117

118118
### Style Guidelines
119119
We follow [PEP-8 guidelines](https://www.python.org/dev/peps/pep-0008/) for new python code.
120120
We also follow [PEP-484](https://www.python.org/dev/peps/pep-0484/) for type annotations.
121121
Before submitting a pull request, run [flake8](https://pypi.python.org/pypi/flake8/) and
122-
[mypy](https://pypi.org/project/mypy/) linters to check the style of your code. All new code contributions should be compatible with Python 3.6+.
122+
[mypy](https://pypi.org/project/mypy/) linters to check the style of your code. All new code contributions should be compatible with Python 3.10+.
123123

124124
#### Docstrings
125125
Docstrings for new code should follow the [Numpy docstring standard](https://numpydoc.readthedocs.io/en/latest/format.html). This allows us to ensure consistency in our auto-generated API documentation.

MANIFEST.in

Lines changed: 0 additions & 2 deletions
This file was deleted.

allensdk/__init__.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,12 @@
3434
# POSSIBILITY OF SUCH DAMAGE.
3535
#
3636
import logging
37-
38-
__version__ = '2.16.2'
39-
37+
from importlib.metadata import version, PackageNotFoundError
4038

4139
try:
42-
from logging import NullHandler
43-
except ImportError:
44-
class NullHandler(logging.Handler):
45-
def emit(self, record):
46-
pass
40+
__version__ = version("allensdk")
41+
except PackageNotFoundError:
42+
__version__ = "0.0.0.dev0"
4743

4844

4945
class OneResultExpectedError(RuntimeError):
@@ -66,7 +62,7 @@ def one(x):
6662
return x[0]
6763

6864

69-
logging.getLogger(__name__).addHandler(NullHandler())
65+
logging.getLogger(__name__).addHandler(logging.NullHandler())
7066

7167
if True:
7268
file_download_log = logging.getLogger(

allensdk/config/app/application_config.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,8 @@
3838
import os
3939
import logging
4040
import logging.config as lc
41-
from pkg_resources import resource_filename # @UnresolvedImport
42-
43-
try:
44-
from configparser import ConfigParser # @UnresolvedImport
45-
except:
46-
from ConfigParser import ConfigParser # @UnresolvedImport
41+
from configparser import ConfigParser
42+
from importlib.resources import files
4743

4844

4945
class ApplicationConfig(object):
@@ -54,7 +50,7 @@ class ApplicationConfig(object):
5450

5551
_log = logging.getLogger(__name__)
5652
_DEFAULT_LOG_CONFIG = os.getenv(
57-
'LOG_CFG', resource_filename(__name__, 'logging.conf'))
53+
'LOG_CFG', str(files(__package__).joinpath('logging.conf')))
5854

5955
def __init__(self,
6056
defaults,

allensdk/core/brain_observatory_nwb_data_set.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
import six
4141
import itertools
4242
import logging
43-
from pkg_resources import parse_version
43+
from packaging.version import Version
4444

4545
import h5py
4646
import pandas as pd
@@ -145,9 +145,9 @@ def __init__(self, nwb_file):
145145
meta = self.get_metadata()
146146
if meta and 'pipeline_version' in meta:
147147
pipeline_version_str = meta['pipeline_version']
148-
self.pipeline_version = parse_version(pipeline_version_str)
148+
self.pipeline_version = Version(pipeline_version_str)
149149

150-
if self.pipeline_version > parse_version(self.SUPPORTED_PIPELINE_VERSION):
150+
if self.pipeline_version > Version(self.SUPPORTED_PIPELINE_VERSION):
151151
logging.warning("File %s has a pipeline version newer than the version supported by this class (%s vs %s)."
152152
" Please update your AllenSDK." % (nwb_file, pipeline_version_str, self.SUPPORTED_PIPELINE_VERSION))
153153

@@ -289,7 +289,7 @@ def get_neuropil_traces(self, cell_specimen_ids=None):
289289
timestamps = self.get_fluorescence_timestamps()
290290

291291
with h5py.File(self.nwb_file, 'r') as f:
292-
if self.pipeline_version >= parse_version("2.0"):
292+
if self.pipeline_version >= Version("2.0"):
293293
ds = f['processing'][self.PIPELINE_DATASET][
294294
'Fluorescence']['imaging_plane_1_neuropil_response']['data']
295295
else:
@@ -321,7 +321,7 @@ def get_neuropil_r(self, cell_specimen_ids=None):
321321
'''
322322

323323
with h5py.File(self.nwb_file, 'r') as f:
324-
if self.pipeline_version >= parse_version("2.0"):
324+
if self.pipeline_version >= Version("2.0"):
325325
r_ds = f['processing'][self.PIPELINE_DATASET][
326326
'Fluorescence']['imaging_plane_1_neuropil_response']['r']
327327
else:
@@ -388,7 +388,7 @@ def get_corrected_fluorescence_traces(self, cell_specimen_ids=None):
388388
'''
389389

390390
# starting in version 2.0, neuropil correction follows trace demixing
391-
if self.pipeline_version >= parse_version("2.0"):
391+
if self.pipeline_version >= Version("2.0"):
392392
timestamps, cell_traces = self.get_demixed_traces(cell_specimen_ids)
393393
else:
394394
timestamps, cell_traces = self.get_fluorescence_traces(cell_specimen_ids)

0 commit comments

Comments
 (0)