Skip to content

Commit c831797

Browse files
authored
Merge pull request #1187 from datajoint/migrate-pyproject
Replace setup.py with pyproject.toml
2 parents 4ee287c + 9884672 commit c831797

14 files changed

+142
-220
lines changed

.devcontainer/devcontainer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Update the 'dockerComposeFile' list if you have more compose files or use different names.
66
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
77
"dockerComposeFile": [
8-
"../LNX-docker-compose.yml",
8+
"../docker-compose.yaml",
99
"docker-compose.yml"
1010
],
1111
// The 'service' property is the name of the service for the container that VS Code should

.github/workflows/development.yaml

+11-14
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,13 @@ jobs:
2929
COMPOSE_HTTP_TIMEOUT: "120"
3030
steps:
3131
- uses: actions/checkout@v4
32+
- uses: actions/setup-python@v5
33+
with:
34+
python-version: ${{matrix.py_ver}}
3235
- name: Validate version and release notes
3336
run: |
3437
DJ_VERSION=$(grep -oP '\d+\.\d+\.\d+' datajoint/version.py)
35-
RELEASE_BODY=$(python -c \
38+
RELEASE_BODY=$(python3 -c \
3639
'print(open("./CHANGELOG.md").read().split("\n\n")[1].split("\n", 1)[1])' \
3740
)
3841
echo "DJ_VERSION=${DJ_VERSION}" >> $GITHUB_ENV
@@ -41,8 +44,8 @@ jobs:
4144
echo "EOF" >> $GITHUB_ENV
4245
- name: Build pip artifacts
4346
run: |
44-
export HOST_UID=$(id -u)
45-
docker compose -f docker-compose-build.yaml up --exit-code-from app --build
47+
python3 -m pip install build
48+
python3 -m build .
4649
echo "DJ_VERSION=${DJ_VERSION}" >> $GITHUB_ENV
4750
- if: matrix.py_ver == '3.9' && matrix.distro == 'debian'
4851
name: Add pip artifacts
@@ -70,12 +73,6 @@ jobs:
7073
uses: actions/setup-python@v5
7174
with:
7275
python-version: ${{matrix.py_ver}}
73-
- name: Install dependencies
74-
run: |
75-
python -m pip install --upgrade pip
76-
pip install flake8 black
77-
- name: Run syntax tests
78-
run: flake8 datajoint --count --select=E9,F63,F7,F82 --show-source --statistics
7976
- name: Run primary tests
8077
env:
8178
PY_VER: ${{matrix.py_ver}}
@@ -87,7 +84,7 @@ jobs:
8784
COMPOSE_HTTP_TIMEOUT: "120"
8885
run: |
8986
export HOST_UID=$(id -u)
90-
docker compose -f LNX-docker-compose.yml up --build --exit-code-from app
87+
docker compose --profile test up --quiet-pull --build --exit-code-from djtest djtest
9188
lint:
9289
runs-on: ubuntu-latest
9390
strategy:
@@ -101,8 +98,8 @@ jobs:
10198
python-version: ${{matrix.py_ver}}
10299
- name: Install dependencies
103100
run: |
104-
python -m pip install --upgrade pip
105-
pip install flake8 black==24.2.0
101+
python3 -m pip install --upgrade pip
102+
python3 -m pip install ".[test]"
106103
- name: Run syntax tests
107104
run: flake8 datajoint --count --select=E9,F63,F7,F82 --show-source --statistics
108105
- name: Run style tests
@@ -138,7 +135,7 @@ jobs:
138135
export PACKAGE=datajoint
139136
export UPSTREAM_REPO=https://github.com/${GITHUB_REPOSITORY}.git
140137
export HOST_UID=$(id -u)
141-
docker compose -f docs/docker-compose.yaml up --exit-code-from docs --build
138+
docker compose -f docs/docker-compose.yaml up --quiet-pull --exit-code-from docs --build
142139
git push origin gh-pages
143140
publish-release:
144141
if: |
@@ -219,7 +216,7 @@ jobs:
219216
- name: Publish pip release
220217
run: |
221218
export HOST_UID=$(id -u)
222-
docker compose -f docker-compose-build.yaml run \
219+
docker compose run --build --quiet-pull \
223220
-e TWINE_USERNAME=${TWINE_USERNAME} -e TWINE_PASSWORD=${TWINE_PASSWORD} app \
224221
sh -c "pip install twine && python -m twine upload dist/*"
225222
- name: Login to DockerHub

Dockerfile

+21-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
1-
ARG IMAGE=jupyter/docker-stacks-foundation
2-
ARG PY_VER=3.9
3-
ARG DISTRO=debian
1+
ARG IMAGE=mambaorg/micromamba:1.5-bookworm-slim
42
FROM ${IMAGE}
5-
RUN conda install -y -n base -c conda-forge python=${PY_VER} && \
6-
conda clean -afy
7-
COPY --chown=anaconda:anaconda ./setup.py ./datajoint.pub ./requirements.txt /main/
8-
COPY --chown=anaconda:anaconda ./datajoint /main/datajoint
3+
4+
ARG CONDA_BIN=micromamba
5+
ARG PY_VER=3.9
6+
ARG HOST_UID=1000
7+
8+
RUN ${CONDA_BIN} install --no-pin -qq -y -n base -c conda-forge \
9+
python=${PY_VER} pip setuptools git graphviz pydot && \
10+
${CONDA_BIN} clean -qq -afy
11+
ENV PATH="$PATH:/home/mambauser/.local/bin"
12+
13+
COPY --chown=${HOST_UID:-1000}:mambauser ./pyproject.toml ./README.md ./LICENSE.txt /main/
14+
COPY --chown=${HOST_UID:-1000}:mambauser ./datajoint /main/datajoint
15+
16+
VOLUME /src
17+
WORKDIR /src
18+
USER root
919
RUN \
10-
pip install --no-cache-dir /main && \
20+
chown -R ${HOST_UID:-1000}:mambauser /main && \
21+
chown -R ${HOST_UID:-1000}:mambauser /src && \
22+
${CONDA_BIN} run -n base pip install -q --no-cache-dir /main && \
1123
rm -r /main/*
24+
USER ${MAMBA_USER}

MANIFEST.in

-1
This file was deleted.

datajoint/fetch.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def __call__(
136136
format=None,
137137
as_dict=None,
138138
squeeze=False,
139-
download_path="."
139+
download_path=".",
140140
):
141141
"""
142142
Fetches the expression results from the database into an np.array or list of dictionaries and

datajoint/s3.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def __init__(
2727
*,
2828
secure=False,
2929
proxy_server=None,
30-
**_
30+
**_,
3131
):
3232
# from https://docs.min.io/docs/python-client-api-reference
3333
self.client = minio.Minio(
+21-49
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
# PY_VER=3.8 MYSQL_VER=5.7 DISTRO=alpine MINIO_VER=RELEASE.2022-08-11T04-37-28Z HOST_UID=$(id -u) docker compose -f LNX-docker-compose.yml up --exit-code-from app --build
2-
version: "2.4"
3-
x-net:
4-
&net
5-
networks:
6-
- main
1+
# DJ_VERSION=$(grep -oP '\d+\.\d+\.\d+' datajoint/version.py) docker compose --profile test up --build --exit-code-from djtest djtest
72
services:
83
db:
9-
<<: *net
104
image: datajoint/mysql:${MYSQL_VER:-8.0}
115
environment:
126
- MYSQL_ROOT_PASSWORD=${DJ_PASS:-password}
@@ -21,7 +15,6 @@ services:
2115
retries: 5
2216
interval: 15s
2317
minio:
24-
<<: *net
2518
image: minio/minio:${MINIO_VER:-RELEASE.2022-08-11T04-37-28Z}
2619
environment:
2720
- MINIO_ACCESS_KEY=datajoint
@@ -34,74 +27,53 @@ services:
3427
command: server --address ":9000" /data
3528
healthcheck:
3629
test:
37-
[
38-
"CMD",
39-
"curl",
40-
"--fail",
41-
"http://minio:9000/minio/health/live"
42-
]
30+
- "CMD"
31+
- "curl"
32+
- "--fail"
33+
- "http://minio:9000/minio/health/live"
4334
timeout: 30s
4435
retries: 5
4536
interval: 15s
46-
fakeservices.datajoint.io:
47-
<<: *net
48-
image: datajoint/nginx:latest
49-
environment:
50-
- ADD_db_TYPE=DATABASE
51-
- ADD_db_ENDPOINT=db:3306
52-
- ADD_minio_TYPE=MINIO
53-
- ADD_minio_ENDPOINT=minio:9000
54-
- ADD_minio_PORT=80 # allow unencrypted connections
55-
- ADD_minio_PREFIX=/datajoint
56-
# ports:
57-
# - "80:80"
58-
# - "443:443"
59-
# - "3306:3306"
6037
app:
61-
<<: *net
62-
image: datajoint/djtest:py${PY_VER:-3.8}-${DISTRO:-alpine}
38+
image: datajoint/datajoint:${DJ_VERSION:-latest}
6339
build:
6440
context: .
6541
dockerfile: Dockerfile
6642
args:
6743
PY_VER: ${PY_VER:-3.8}
68-
DISTRO: ${DISTRO:-alpine}
44+
HOST_UID: ${HOST_UID:-1000}
6945
depends_on:
7046
db:
7147
condition: service_healthy
7248
minio:
7349
condition: service_healthy
74-
fakeservices.datajoint.io:
75-
condition: service_healthy
7650
environment:
77-
- DJ_HOST=fakeservices.datajoint.io
51+
- DJ_HOST=db
7852
- DJ_USER=root
7953
- DJ_PASS=password
80-
- DJ_TEST_HOST=fakeservices.datajoint.io
54+
- DJ_TEST_HOST=db
8155
- DJ_TEST_USER=datajoint
8256
- DJ_TEST_PASSWORD=datajoint
83-
- S3_ENDPOINT=fakeservices.datajoint.io
57+
- S3_ENDPOINT=minio:9000
8458
- S3_ACCESS_KEY=datajoint
8559
- S3_SECRET_KEY=datajoint
8660
- S3_BUCKET=datajoint.test
8761
- PYTHON_USER=dja
8862
- JUPYTER_PASSWORD=datajoint
89-
- DISPLAY
9063
working_dir: /src
64+
user: ${HOST_UID:-1000}:mambauser
65+
volumes:
66+
- .:/src
67+
djtest:
68+
extends:
69+
service: app
70+
profiles: ["test"]
9171
command:
9272
- sh
9373
- -c
9474
- |
9575
set -e
96-
pip install -e .
97-
pip list --format=freeze | grep datajoint
98-
pytest -sv --cov-report term-missing --cov=datajoint tests
99-
# ports:
100-
# - "8888:8888"
101-
user: ${HOST_UID:-1000}:anaconda
102-
volumes:
103-
- .:/src
104-
- /tmp/.X11-unix:/tmp/.X11-unix:rw
105-
# - ./notebooks:/home/dja/notebooks
106-
networks:
107-
main:
76+
pip install -q -e ".[test]"
77+
pip freeze | grep datajoint
78+
pytest --cov-report term-missing --cov=datajoint tests
79+

local-docker-compose.yml

-66
This file was deleted.

pyproject.toml

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
[project]
2+
name = "datajoint"
3+
version = "0.14.2"
4+
dependencies = [
5+
"numpy",
6+
"pymysql>=0.7.2",
7+
"pyparsing",
8+
"ipython",
9+
"pandas",
10+
"tqdm",
11+
"networkx",
12+
"pydot",
13+
"minio>=7.0.0",
14+
"matplotlib",
15+
"otumat",
16+
"faker",
17+
"cryptography",
18+
"urllib3"
19+
]
20+
requires-python = ">=3.8,<4.0"
21+
authors = [
22+
{name = "Dimitri Yatsenko", email = "[email protected]"},
23+
{name = "Raphael Guzman"},
24+
{name = "Edgar Walker"},
25+
{name = "DataJoint Contributors", email = "[email protected]"},
26+
]
27+
maintainers = [
28+
{name = "Dimitri Yatsenko", email = "[email protected]"},
29+
{name = "DataJoint Contributors", email = "[email protected]"},
30+
]
31+
description = "A relational data pipeline framework."
32+
readme = "README.md"
33+
license = {file = "LICENSE.txt"}
34+
keywords = [
35+
"database",
36+
"data pipelines",
37+
"scientific computing",
38+
"automated research workflows",
39+
]
40+
classifiers = [
41+
"Programming Language :: Python"
42+
]
43+
44+
[project.optional-dependencies]
45+
test = [
46+
"pytest",
47+
"pytest-cov",
48+
"black==24.2.0",
49+
"flake8",
50+
]
51+
52+
[project.urls]
53+
Homepage = "https://datajoint.com/docs"
54+
Documentation = "https://datajoint.com/docs"
55+
Repository = "https://github.com/datajoint/datajoint-python"
56+
"Bug Tracker" = "https://github.com/datajoint/datajoint-python/issues"
57+
Changelog = "https://github.com/datajoint/datajoint-python/blob/master/CHANGELOG.md"
58+
59+
[project.entry-points."console_scripts"]
60+
dj = "datajoint.cli:cli"
61+
datajoint = "datajoint.cli:cli"
62+
63+
[tool.setuptools]
64+
packages = ["datajoint"]
65+
66+
[build-system]
67+
requires = [
68+
"setuptools>=60",
69+
"setuptools-scm>=8.0"
70+
]
71+
build-backend = "setuptools.build_meta"

0 commit comments

Comments
 (0)