Skip to content

Commit

Permalink
Merge pull request #1236 from pyiron/switch_setup
Browse files Browse the repository at this point in the history
Switch to pyproject.toml
  • Loading branch information
jan-janssen authored Dec 2, 2023
2 parents 4649442 + 4bee711 commit 2ccbf78
Show file tree
Hide file tree
Showing 29 changed files with 328 additions and 2,684 deletions.
57 changes: 0 additions & 57 deletions .ci_support/condamerge.py

This file was deleted.

6 changes: 3 additions & 3 deletions .ci_support/environment-notebooks.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
channels:
- conda-forge
- conda-forge
dependencies:
- jupyter
- papermill
- jupyter
- papermill
18 changes: 18 additions & 0 deletions .ci_support/environment-old.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
channels:
- conda-forge
dependencies:
- dill =0.3.1.1
- gitpython =3.1.23
- h5io =0.1.2
- h5py =3.6.0
- jinja2 =2.11.3
- numpy =1.23.5
- pandas =2.0.0
- pint =0.18
- psutil =5.8.0
- pyfileindex =0.0.16
- pysqa =0.1.5
- pytables =3.6.1
- sqlalchemy =2.0.22
- tqdm =4.66.1
- traitlets =5.1.1
1 change: 0 additions & 1 deletion .ci_support/environment.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
channels:
- conda-forge
dependencies:
- coveralls
- coverage
- codacy-coverage
- dill =0.3.7
Expand Down
2 changes: 2 additions & 0 deletions .ci_support/pip_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pip install versioneer[toml]==0.29
pip install . --no-deps --no-build-isolation
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)
5 changes: 3 additions & 2 deletions .ci_support/test_backwards.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#!/bin/bash

pip install --no-deps pyiron_base==0.1.21
pip install pyiron_base==0.1.21 --no-deps
echo "Before save";
for t in tests/backwards/*save.py; do
echo "Running $t";
python $t
done

pip install --no-deps .
pip install versioneer[toml]==0.29
pip install . --no-deps --no-build-isolation
i=0;
echo "Before loading";
for t in tests/backwards/*load.py; do
Expand Down
34 changes: 0 additions & 34 deletions .github/workflows/UpdateDependabotPR.yml

This file was deleted.

49 changes: 14 additions & 35 deletions .github/workflows/atomistics-compat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,28 @@ jobs:
matrix:
include:
- operating-system: macos-latest
python-version: '3.10'
python-version: '3.11'
label: osx-64-py-3-10
prefix: /Users/runner/miniconda3/envs/my-env

- operating-system: windows-latest
python-version: '3.10'
python-version: '3.11'
label: win-64-py-3-10
prefix: C:\Miniconda3\envs\my-env

- operating-system: ubuntu-latest
python-version: '3.10'
python-version: '3.11'
label: linux-64-py-3-10
prefix: /usr/share/miniconda3/envs/my-env

steps:
- uses: actions/checkout@v2
- name: pyiron_atomistic
- uses: actions/checkout@v4
- name: Merge environment
run: |
pip install PyYAML
git clone https://github.com/pyiron/pyiron_atomistics ../pyiron_atomistics
grep -v "pyiron_base" ../pyiron_atomistics/.ci_support/environment.yml > ../pyiron_atomistics/environment.yml
python .ci_support/condamerge.py --base .ci_support/environment.yml --add ../pyiron_atomistics/environment.yml > environment.yml
cp .ci_support/environment.yml environment.yml
tail --lines=+4 ../pyiron_atomistics/environment.yml >> environment.yml
- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v2
with:
Expand All @@ -50,38 +50,17 @@ 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: ${{ 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: pyironconfig
shell: bash -l {0}
run: |
cd ../pyiron_atomistics
python .ci_support/pyironconfig.py
cd ../pyiron_base
- name: Install pyiron_atomistics
- name: Tests
shell: bash -l {0}
timeout-minutes: 30
run: |
pip install versioneer[toml]==0.29
cd ../pyiron_atomistics
pip install --no-deps .
pip install . --no-deps --no-build-isolation
cd ../pyiron_base
- name: Install pyiron_base
shell: bash -l {0}
run: |
pip install --no-deps .
- name: Test
shell: bash -l {0}
timeout-minutes: 30
run: |
pip install . --no-deps --no-build-isolation
cd ../pyiron_atomistics
python .ci_support/pyironconfig.py
python -m unittest discover tests/
31 changes: 9 additions & 22 deletions .github/workflows/backwards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,26 @@ on:

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup environment
- uses: actions/checkout@v4
- name: Merge environment
run: |
python .ci_support/condamerge.py --base .ci_support/environment.yml --add .ci_support/environment-notebooks.yml > environment.yml
cp .ci_support/environment.yml environment.yml
tail --lines=+4 .ci_support/environment-notebooks.yml >> environment.yml
- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v2
with:
python-version: '3.10'
python-version: ${{ matrix.python-version }}
miniforge-variant: Mambaforge
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: 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: Setup
- name: Tests
shell: bash -l {0}
timeout-minutes: 30
run: |
python .ci_support/pyironconfig.py
- name: Test
shell: bash -l {0}
run: ./.ci_support/test_backwards.sh
./.ci_support/test_backwards.sh
Loading

0 comments on commit 2ccbf78

Please sign in to comment.