Skip to content

Commit

Permalink
Merge pull request #228 from pyiron/pyproject_toml
Browse files Browse the repository at this point in the history
Switch to pyproject.toml
  • Loading branch information
jan-janssen authored Nov 27, 2023
2 parents 0c6a536 + 7f0ca0c commit ef8bab6
Show file tree
Hide file tree
Showing 13 changed files with 140 additions and 2,354 deletions.
61 changes: 61 additions & 0 deletions .ci_support/release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
def get_setup_version_and_pattern(setup_content):
depend_lst, version_lst = [], []
for l in setup_content:
if '==' in l:
lst = l.split('[')[-1].split(']')[0].replace(' ', '').replace('"', '').replace("'", '').split(',')
for dep in lst:
if dep != '\n':
version_lst.append(dep.split('==')[1])
depend_lst.append(dep.split('==')[0])

version_high_dict = {d: v for d, v in zip(depend_lst, version_lst)}
return version_high_dict


def get_env_version(env_content):
read_flag = False
depend_lst, version_lst = [], []
for l in env_content:
if 'dependencies:' in l:
read_flag = True
elif read_flag:
lst = l.replace('-', '').replace(' ', '').replace('\n', '').split("=")
if len(lst) == 2:
depend_lst.append(lst[0])
version_lst.append(lst[1])
return {d:v for d, v in zip(depend_lst, version_lst)}


def update_dependencies(setup_content, version_low_dict, version_high_dict):
version_combo_dict = {}
for dep, ver in version_high_dict.items():
if dep in version_low_dict.keys() and version_low_dict[dep] != ver:
version_combo_dict[dep] = dep + ">=" + version_low_dict[dep] + ",<=" + ver
else:
version_combo_dict[dep] = dep + "==" + ver

setup_content_new = ""
pattern_dict = {d:d + "==" + v for d, v in version_high_dict.items()}
for l in setup_content:
for k, v in pattern_dict.items():
if v in l:
l = l.replace(v, version_combo_dict[k])
setup_content_new +=l
return setup_content_new


if __name__ == "__main__":
with open('pyproject.toml', "r") as f:
setup_content = f.readlines()

with open('environment.yml', "r") as f:
env_content = f.readlines()

setup_content_new = update_dependencies(
setup_content=setup_content[2:],
version_low_dict=get_env_version(env_content=env_content),
version_high_dict=get_setup_version_and_pattern(setup_content=setup_content[2:]),
)

with open('pyproject.toml', "w") as f:
f.writelines("".join(setup_content[:2]) + setup_content_new)
12 changes: 5 additions & 7 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@ jobs:
- uses: actions/setup-python@v2
with:
python-version: "3.11"

- name: Install dependencies
run: >-
python -m pip install --user --upgrade setuptools wheel
run: python -m pip install --user --upgrade cloudpickle pyzmq setuptools tqdm versioneer wheel
- name: Convert dependencies
run: >-
sed -i 's/==/>=/g' setup.py; cat setup.py
run: |
cp .ci_support/environment-old.yml environment.yml
python .ci_support/release.py; cat pyproject.toml
- name: Build
run: >-
python setup.py sdist bdist_wheel
run: python setup.py sdist bdist_wheel
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
12 changes: 5 additions & 7 deletions .github/workflows/unittest-flux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,14 @@ jobs:
channel-priority: strict
auto-update-conda: true
environment-file: ${{ matrix.environment-file }}
- name: Install flux
shell: bash -l {0}
run: mamba install -y flux-core coverage
- name: Setup
shell: bash -l {0}
run: pip install --no-deps .
- name: Test
shell: bash -l {0}
timeout-minutes: 5
run: cd tests; coverage run --omit pympipool/_version.py -m unittest discover .
run: |
mamba install -y flux-core coverage
pip install --no-deps .
cd tests
coverage run --omit pympipool/_version.py -m unittest discover .
env:
OMPI_MCA_plm: 'isolated'
OMPI_MCA_rmaps_base_oversubscribe: 'yes'
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/unittest-mpich.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ jobs:
channel-priority: strict
auto-update-conda: true
environment-file: .ci_support/environment-mpich.yml
- name: Setup
shell: bash -l {0}
run: pip install --no-deps .
- name: Test
shell: bash -l {0}
timeout-minutes: 5
run: cd tests; python -m unittest discover .
run: |
pip install --no-deps .
cd tests
python -m unittest discover .
8 changes: 4 additions & 4 deletions .github/workflows/unittest-openmpi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ jobs:
channel-priority: strict
auto-update-conda: true
environment-file: .ci_support/environment-openmpi.yml
- name: Setup
shell: bash -l {0}
run: pip install --no-deps .
- name: Test
shell: bash -l {0}
timeout-minutes: 5
run: cd tests; python -m unittest discover .
run: |
pip install --no-deps .
cd tests
python -m unittest discover .
env:
OMPI_MCA_plm: 'isolated'
OMPI_MCA_rmaps_base_oversubscribe: 'yes'
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/unittest-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ jobs:
channel-priority: strict
auto-update-conda: true
environment-file: .ci_support/environment-win.yml
- name: Setup
shell: bash -l {0}
run: pip install --no-deps .
- name: Test
shell: bash -l {0}
timeout-minutes: 5
run: cd tests; python -m unittest discover .
run: |
pip install --no-deps .
cd tests
python -m unittest discover .
8 changes: 4 additions & 4 deletions .github/workflows/unittests-old.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ jobs:
channel-priority: strict
auto-update-conda: true
environment-file: .ci_support/environment-old.yml
- name: Setup
shell: bash -l {0}
run: pip install --no-deps .
- name: Test
shell: bash -l {0}
timeout-minutes: 5
run: cd tests; python -m unittest discover .
run: |
pip install --no-deps .
cd tests
python -m unittest discover .
env:
OMPI_MCA_plm: 'isolated'
OMPI_MCA_rmaps_base_oversubscribe: 'yes'
Expand Down
2 changes: 0 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
include versioneer.py
include pympipool/_version.py
include LICENSE
1 change: 0 additions & 1 deletion pympipool/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@


__version__ = get_versions()["version"]
del get_versions


class Executor:
Expand Down
50 changes: 50 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[build-system]
requires = ["cloudpickle", "pyzmq", "setuptools", "tqdm", "versioneer[toml]==0.29"]
build-backend = "setuptools.build_meta"

[project]
name = "pympipool"
description = "Scale serial and MPI-parallel python functions over hundreds of compute nodes all from within a jupyter notebook or serial python process."
authors = [
{ name = "Jan Janssen", email = "[email protected]" },
]
readme = "README.md"
license = { file = "LICENSE" }
keywords = ["pyiron"]
requires-python = ">=3.8"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Topic :: Scientific/Engineering :: Physics",
"License :: OSI Approved :: BSD License",
"Intended Audience :: Science/Research",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
dependencies = [
"cloudpickle==3.0.0",
"mpi4py==3.1.5",
"pyzmq==25.1.1",
"tqdm==4.66.1",
]
dynamic = ["version"]

[project.urls]
Homepage = "https://github.com/pyiron/pympipool"
Documentation = "https://pympipool.readthedocs.io"
Repository = "https://github.com/pyiron/pympipool"

[tool.setuptools.packages.find]
include = ["pympipool*"]

[tool.setuptools.dynamic]
version = {attr = "pympipool.__version__"}

[tool.versioneer]
VCS = "git"
style = "pep440-pre"
versionfile_source = "pympipool/_version.py"
parentdir_prefix = "pympipool"
tag_prefix = "pympipool-"
12 changes: 0 additions & 12 deletions setup.cfg

This file was deleted.

35 changes: 3 additions & 32 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,8 @@
"""
Setuptools based setup module
"""
from setuptools import setup, find_packages
from pathlib import Path
import versioneer
from setuptools import setup

import versioneer

setup(
name='pympipool',
version=versioneer.get_version(),
description='pympipool - Scale serial and MPI-parallel python functions over hundreds of compute nodes all from within a jupyter notebook or serial python process.',
long_description=Path("README.md").read_text(),
long_description_content_type='text/markdown',
url='https://github.com/pyiron/pympipool',
author_email='[email protected]',
license='BSD',

classifiers=[
'Development Status :: 5 - Production/Stable',
'License :: OSI Approved :: BSD License',
'Intended Audience :: Science/Research',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11'
],
packages=find_packages(exclude=["*tests*", "*.ci_support*"]),
install_requires=[
'cloudpickle==3.0.0',
'mpi4py==3.1.5',
'tqdm==4.66.1',
'pyzmq==25.1.1',
],
cmdclass=versioneer.get_cmdclass(),
)
)
Loading

0 comments on commit ef8bab6

Please sign in to comment.