Skip to content

Commit

Permalink
📦️ PEP 518: Set [build-system] in pyproject.toml (#2111)
Browse files Browse the repository at this point in the history
  • Loading branch information
shnizzedy authored May 22, 2024
2 parents c22ac1c + 9f3413f commit 5bcde5b
Show file tree
Hide file tree
Showing 16 changed files with 68 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ USER root
# install C-PAC
COPY dev/circleci_data/pipe-test_ci.yml /cpac_resources/pipe-test_ci.yml
COPY . /code
RUN pip cache purge && pip install -e /code
RUN pip cache purge && pip install -e "/code[graphviz]"
# set up runscript
COPY dev/docker_data /code/docker_data
RUN rm -Rf /code/docker_data/checksum && \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ USER root
# install C-PAC & set up runscript
COPY dev/circleci_data/pipe-test_ci.yml /cpac_resources/pipe-test_ci.yml
COPY . /code
RUN pip cache purge && pip install -e /code
RUN pip cache purge && pip install -e "/code[graphviz]"
# set up runscript
COPY dev/docker_data /code/docker_data
RUN rm -Rf /code/docker_data/checksum && \
Expand Down
2 changes: 1 addition & 1 deletion .github/Dockerfiles/C-PAC.develop-jammy.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ USER root
# install C-PAC
COPY dev/circleci_data/pipe-test_ci.yml /cpac_resources/pipe-test_ci.yml
COPY . /code
RUN pip cache purge && pip install -e /code
RUN pip cache purge && pip install -e "/code[graphviz]"
# set up runscript
COPY dev/docker_data /code/docker_data
RUN rm -Rf /code/docker_data/checksum && \
Expand Down
2 changes: 1 addition & 1 deletion .github/Dockerfiles/C-PAC.develop-lite-jammy.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ USER root
COPY dev/circleci_data/pipe-test_ci.yml /cpac_resources/pipe-test_ci.yml
COPY . /code
COPY --from=ghcr.io/fcp-indi/c-pac_templates:latest /cpac_templates /cpac_templates
RUN pip cache purge && pip install -e /code
RUN pip cache purge && pip install -e "/code[graphviz]"
# set up runscript
COPY dev/docker_data /code/docker_data
RUN rm -Rf /code/docker_data/checksum && \
Expand Down
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]

### Added

- `pyproject.toml` file with `[build-system]` defined.

### Changed

- Moved `pygraphviz` from requirements to `graphviz` optional dependencies group.

### Fixed

- A bug in which AWS S3 encryption was looked for in Nipype config instead of pipeline config (only affected uploading logs)
- A bug in which AWS S3 encryption was looked for in Nipype config instead of pipeline config (only affected uploading logs).

## [1.8.7] - 2024-05-03

Expand Down
3 changes: 1 addition & 2 deletions CPAC/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,7 @@ def get_cpac_gitversion():
"psutil",
"PyBASC",
"pybids",
"pygraphviz",
"PyPEER @ git+https://[email protected]/ChildMindInstitute/PyPEER.git@6965d2b2bea0fef824e885fec33a8e0e6bd50a97#egg=PyPEER",
"PyPEER @ https://github.com/shnizzedy/PyPEER/archive/6965d2b2bea0fef824e885fec33a8e0e6bd50a97.zip",
"python-dateutil",
"pyyaml",
"scikit-learn",
Expand Down
Empty file.
46 changes: 24 additions & 22 deletions CPAC/utils/versioning/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def cli_version(
with Popen(command, stdout=PIPE, stderr=STDOUT, shell=True) as _command:
_version = _command.stdout.read().decode("utf-8")
_command_poll = _command.poll()
if _command_poll is None or int(_command_poll) == 127:
if _command_poll is None or int(_command_poll) == 127: # noqa: PLR2004
# handle missing command
return {}
if formatting is not None:
Expand All @@ -80,19 +80,23 @@ def last_line(stdout: str) -> str:
return stdout


def _version_sort(_version_item):
def _version_sort(_version_item) -> str:
"""Key to report by case-insensitive dependecy name."""
return _version_item[0].lower()


PYTHON_PACKAGES = dict(
sorted(
{
getattr(d, "name", d.metadata["Name"]): d.version
for d in list(distributions())
}.items(),
key=_version_sort,
def sorted_versions(versions: dict) -> dict:
"""Sort versions by case-insensitive names."""
return dict(
sorted(
((name, version) for name, version in versions.items() if name),
key=_version_sort,
)
)


PYTHON_PACKAGES = sorted_versions(
{getattr(d, "name", d.metadata["Name"]): d.version for d in list(distributions())}
)


Expand Down Expand Up @@ -130,18 +134,16 @@ def requirements() -> dict:
return reqs


REPORTED = dict(
sorted(
{
**cli_version("ldd --version", formatting=first_line),
"Python": sys.version.replace("\n", " ").replace(" ", " "),
**cli_version(
"3dECM -help",
delimiter="_",
formatting=lambda _: last_line(_).split("{")[-1].rstrip("}"),
),
}.items(),
key=_version_sort,
)
REPORTED = sorted_versions(
{
**cli_version("ldd --version", formatting=first_line),
"Python": sys.version.replace("\n", " ").replace(" ", " "),
**cli_version(
"3dECM -help",
delimiter="_",
formatting=lambda _: last_line(_).split("{")[-1].rstrip("}"),
),
}
)

REQUIREMENTS = requirements()
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ USER root
# install C-PAC
COPY dev/circleci_data/pipe-test_ci.yml /cpac_resources/pipe-test_ci.yml
COPY . /code
RUN pip cache purge && pip install -e /code
RUN pip cache purge && pip install -e "/code[graphviz]"
# set up runscript
COPY dev/docker_data /code/docker_data
RUN rm -Rf /code/docker_data/checksum && \
Expand Down
2 changes: 1 addition & 1 deletion dev/docker_data/unpinned_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ prov
psutil
PyBASC
pybids
PyPEER @ git+https://git@github.com/ChildMindInstitute/PyPEER.git@6965d2b2bea0fef824e885fec33a8e0e6bd50a97
PyPEER @ https://github.com/shnizzedy/PyPEER/archive/6965d2b2bea0fef824e885fec33a8e0e6bd50a97.zip
python-dateutil
PyYAML
requests
Expand Down
19 changes: 19 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright (C) 2024 C-PAC Developers

# This file is part of C-PAC.

# C-PAC is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.

# C-PAC is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
# License for more details.

# You should have received a copy of the GNU Lesser General Public
# License along with C-PAC. If not, see <https://www.gnu.org/licenses/>.
[build-system]
requires = ["nipype", "numpy", "pyyaml", "setuptools", "voluptuous"]
build-backend = "setuptools.build_meta"
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ prov==2.0.0
psutil==5.9.5
PyBASC==0.6.1
pybids==0.15.6
PyPEER @ git+https://git@github.com/ChildMindInstitute/PyPEER.git@6965d2b2bea0fef824e885fec33a8e0e6bd50a97
PyPEER @ https://github.com/shnizzedy/PyPEER/archive/6965d2b2bea0fef824e885fec33a8e0e6bd50a97.zip
python-dateutil==2.8.2
PyYAML==6.0
requests==2.31.0
Expand Down
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2022 C-PAC Developers
# Copyright (C) 2022-2024 C-PAC Developers

# This file is part of C-PAC.

Expand Down Expand Up @@ -43,9 +43,12 @@ def configuration(parent_package="", top_path=None):

def main(**extra_args):
from glob import glob
import sys

from numpy.distutils.core import setup

# prepend this file's parent directory to sys.path to find CPAC when building
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
from CPAC.info import (
AUTHOR,
AUTHOR_EMAIL,
Expand Down Expand Up @@ -78,6 +81,7 @@ def main(**extra_args):
platforms=PLATFORMS,
version=VERSION,
install_requires=REQUIREMENTS,
extras_require={"graphviz": ["pygraphviz"]},
configuration=configuration,
scripts=glob("scripts/*"),
entry_points={"console_scripts": ["cpac = CPAC.__main__:main"]},
Expand Down
2 changes: 1 addition & 1 deletion variant-ABCD-HCP.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ USER root
# install C-PAC
COPY dev/circleci_data/pipe-test_ci.yml /cpac_resources/pipe-test_ci.yml
COPY . /code
RUN pip cache purge && pip install -e /code
RUN pip cache purge && pip install -e "/code[graphviz]"
# set up runscript
COPY dev/docker_data /code/docker_data
RUN rm -Rf /code/docker_data/checksum && \
Expand Down
2 changes: 1 addition & 1 deletion variant-fMRIPrep-LTS.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ USER root
# install C-PAC & set up runscript
COPY dev/circleci_data/pipe-test_ci.yml /cpac_resources/pipe-test_ci.yml
COPY . /code
RUN pip cache purge && pip install -e /code
RUN pip cache purge && pip install -e "/code[graphviz]"
# set up runscript
COPY dev/docker_data /code/docker_data
RUN rm -Rf /code/docker_data/checksum && \
Expand Down
2 changes: 1 addition & 1 deletion variant-lite.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ USER root
COPY dev/circleci_data/pipe-test_ci.yml /cpac_resources/pipe-test_ci.yml
COPY . /code
COPY --from=ghcr.io/fcp-indi/c-pac_templates:latest /cpac_templates /cpac_templates
RUN pip cache purge && pip install -e /code
RUN pip cache purge && pip install -e "/code[graphviz]"
# set up runscript
COPY dev/docker_data /code/docker_data
RUN rm -Rf /code/docker_data/checksum && \
Expand Down

0 comments on commit 5bcde5b

Please sign in to comment.