Skip to content

Commit

Permalink
Merge pull request #242 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 e62a5e8 + 20bb612 commit b62eb67
Show file tree
Hide file tree
Showing 20 changed files with 171 additions and 2,448 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)
2 changes: 1 addition & 1 deletion .github/workflows/black.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: psf/black@stable
with:
options: "--check --diff"
Expand Down
21 changes: 3 additions & 18 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ env:
jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Setup environment
run: |
cp .ci_support/environment.yml environment.yml
Expand All @@ -31,26 +30,12 @@ jobs:
channels: conda-forge
channel-priority: strict
activate-environment: my-env
environment-file: environment.yml
use-mamba: true
- name: Set cache date and number
run: |
echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV
cat .github/variables/cache_number.env >> $GITHUB_ENV
- uses: actions/cache@v2
with:
path: /usr/share/miniconda3/envs/my-env
key: coverage-conda-${{ hashFiles('environment.yml') }}-${{ env.DATE }}-${{ env.CACHE_NUMBER }}
id: cache
- name: Update environment
run: mamba env update -n my-env -f environment.yml
if: steps.cache.outputs.cache-hit != 'true'
- name: Setup
shell: bash -l {0}
run: |
pip install --no-deps .
- name: Test
shell: bash -l {0}
run: |
pip install --no-deps .
coverage run --omit pysqa/_version.py -m unittest discover tests
coverage combine
- name: Coveralls
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
if: (github.actor == 'dependabot[bot]')
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }} # Check out the head of the actual branch, not the PR
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
Expand Down
16 changes: 7 additions & 9 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,17 @@ jobs:
permissions:
id-token: write
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install dependencies
run: >-
python -m pip install --user --upgrade setuptools wheel
run: python -m pip install --user --upgrade setuptools 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
4 changes: 2 additions & 2 deletions .github/workflows/format_black.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
token: ${{ secrets.DEPENDABOT_WORKFLOW_TOKEN }}
ref: ${{ github.event.pull_request.head.ref }} # Check out the head of the actual branch, not the PR
Expand All @@ -22,7 +22,7 @@ jobs:
uses: psf/black@stable
with:
options: ""
src: "./pysqa"
src: ./${{ github.event.repository.name }}
- name: commit
run: |
git config --local user.email "[email protected]"
Expand Down
25 changes: 4 additions & 21 deletions .github/workflows/mini.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,12 @@ on:
pull_request:
branches: [ main ]

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Setup environment
run: |
cp .ci_support/environment.yml environment.yml
Expand All @@ -33,23 +29,10 @@ jobs:
channels: conda-forge
channel-priority: strict
activate-environment: my-env
environment-file: environment.yml
use-mamba: true
- name: Set cache date and number
run: |
echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV
cat .github/variables/cache_number.env >> $GITHUB_ENV
- uses: actions/cache@v2
with:
path: /usr/share/miniconda3/envs/my-env
key: mini-conda-${{ hashFiles('environment.yml') }}-${{ env.DATE }}-${{ env.CACHE_NUMBER }}
id: cache
- name: Update environment
run: mamba env update -n my-env -f environment.yml
if: steps.cache.outputs.cache-hit != 'true'
- name: Setup
- name: Test
shell: bash -l {0}
run: |
pip install --no-deps .
- name: Test
shell: bash -l {0}
run: python -m unittest discover tests
python -m unittest discover tests
19 changes: 3 additions & 16 deletions .github/workflows/pypicheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,17 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup environment
run: cp .ci_support/environment.yml environment.yml
- uses: actions/checkout@v4
- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v2
with:
python-version: '3.10'
python-version: '3.11'
miniforge-variant: Mambaforge
channels: conda-forge
channel-priority: strict
activate-environment: my-env
environment-file: .ci_support/environment.yml
use-mamba: true
- name: Set cache date and number
run: |
echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV
cat .github/variables/cache_number.env >> $GITHUB_ENV
- uses: actions/cache@v2
with:
path: /usr/share/miniconda3/envs/my-env
key: linux-64-py-3-10-conda-${{ hashFiles('environment.yml') }}-${{ env.DATE }}-${{ env.CACHE_NUMBER }}
id: cache
- name: Update environment
run: mamba env update -n my-env -f environment.yml
if: steps.cache.outputs.cache-hit != 'true'
- name: Pip check
shell: bash -l {0}
run: |
Expand Down
28 changes: 4 additions & 24 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,8 @@ on:
pull_request:
branches: [ main ]

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}

jobs:
build:

runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
Expand Down Expand Up @@ -51,9 +46,7 @@ jobs:
prefix: /usr/share/miniconda3/envs/my-env

steps:
- uses: actions/checkout@v2
- name: Setup environment
run: cp .ci_support/environment.yml environment.yml
- uses: actions/checkout@v4
- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v2
with:
Expand All @@ -62,23 +55,10 @@ jobs:
channels: conda-forge
channel-priority: strict
activate-environment: my-env
environment-file: .ci_support/environment.yml
use-mamba: true
- name: Set cache date and number
run: |
echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV
cat .github/variables/cache_number.env >> $GITHUB_ENV
- uses: actions/cache@v2
with:
path: ${{ matrix.prefix }}
key: ${{ matrix.label }}-conda-${{ hashFiles('environment.yml') }}-${{ env.DATE }}-${{ env.CACHE_NUMBER }}
id: cache
- name: Update environment
run: mamba env update -n my-env -f environment.yml
if: steps.cache.outputs.cache-hit != 'true'
- name: Setup
- name: Test
shell: bash -l {0}
run: |
pip install --no-deps .
- name: Test
shell: bash -l {0}
run: python -m unittest discover tests
python -m unittest discover tests
13 changes: 5 additions & 8 deletions .github/workflows/unittests_old.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ on:

jobs:
build:

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v2
with:
Expand All @@ -23,12 +22,10 @@ jobs:
channels: conda-forge
channel-priority: strict
activate-environment: my-env
environment-file: .ci_support/environment-old.yml
use-mamba: true
- name: Update environment
run: mamba env update -n my-env -f .ci_support/environment-old.yml
- name: Setup
shell: bash -l {0}
run: pip install --no-deps .
- name: Test
shell: bash -l {0}
run: python -m unittest discover tests
run: |
pip install --no-deps .
python -m unittest discover tests
4 changes: 1 addition & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
include LICENSE
include versioneer.py
include pysqa/_version.py
include LICENSE
65 changes: 65 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
[build-system]
requires = ["jinja2", "pandas", "pyyaml", "setuptools", "versioneer[toml]==0.29"]
build-backend = "setuptools.build_meta"

[project]
name = "pysqa"
description = "Simple HPC queuing system adapter for Python on based jinja templates to automate the submission script creation."
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",
"Programming Language :: Python :: 3.12",
]
dependencies = [
"jinja2==3.1.2",
"pandas==2.1.3",
"pyyaml==6.0.1",
]
dynamic = ["version"]

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

[project.optional-dependencies]
sge = ["defusedxml==0.7.1"]
remote = [
"paramiko==3.3.1",
"tqdm==4.66.1",
]
executor = [
"pympipool==0.7.5",
"cloudpickle==3.0.0",
]

[project.scripts]
pysqa = "pysqa.cmd:command_line"
pysqa-executor = "pysqa.executor.backend:command_line"

[tool.setuptools]
packages = ["pysqa"]

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

[tool.versioneer]
VCS = "git"
style = "pep440-pre"
versionfile_source = "pysqa/_version.py"
parentdir_prefix = "pysqa"
tag_prefix = "pysqa-"
Loading

0 comments on commit b62eb67

Please sign in to comment.