Skip to content

Commit

Permalink
Merge pull request #95 from pyiron/pyproject_toml
Browse files Browse the repository at this point in the history
Switch to pyproject.toml
  • Loading branch information
jan-janssen committed Nov 26, 2023
2 parents 9ff7191 + 02a5e3c commit 0f2c6a9
Show file tree
Hide file tree
Showing 11 changed files with 137 additions and 72 deletions.
1 change: 1 addition & 0 deletions .ci_support/environment-old.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
channels:
- conda-forge
dependencies:
- numpy =1.23.5
- pandas =1.5.3
- scandir =1.10.0
1 change: 1 addition & 0 deletions .ci_support/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ channels:
- conda-forge
dependencies:
- coverage
- numpy =1.26.0
- pandas =2.1.3
- scandir =1.10.0
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,
version_low_dict=get_env_version(env_content=env_content),
version_high_dict=get_setup_version_and_pattern(setup_content=setup_content),
)

with open('pyproject.toml', "w") as f:
f.writelines(setup_content_new)
11 changes: 5 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@ jobs:
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
8 changes: 4 additions & 4 deletions .github/workflows/pypicheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v2.2.0
- uses: conda-incubator/setup-miniconda@v2
with:
python-version: "3.10"
mamba-version: "*"
miniforge-variant: Mambaforge
channels: conda-forge
channel-priority: strict
auto-update-conda: true
activate-environment: my-env
environment-file: .ci_support/environment.yml
miniforge-variant: Mambaforge
use-mamba: true
- name: Setup
shell: bash -l {0}
run: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v2.2.0
- uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.python-version }}
mamba-version: "*"
miniforge-variant: Mambaforge
channels: conda-forge
channel-priority: strict
auto-update-conda: true
activate-environment: my-env
environment-file: .ci_support/environment.yml
miniforge-variant: Mambaforge
use-mamba: true
- name: Test
shell: bash -l {0}
run: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/unittests_old.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v2.2.0
- uses: conda-incubator/setup-miniconda@v2
with:
python-version: '3.9'
mamba-version: "*"
miniforge-variant: Mambaforge
channels: conda-forge
channel-priority: strict
auto-update-conda: true
activate-environment: my-env
environment-file: .ci_support/environment-old.yml
miniforge-variant: Mambaforge
use-mamba: true
- name: Test
shell: bash -l {0}
run: |
Expand Down
12 changes: 6 additions & 6 deletions pyfileindex/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
__version__ = "0.0.1"
__all__ = []
from . import _version

from ._version import get_versions
from .pyfileindex import PyFileIndex
try:
from pyfileindex.pyfileindex import PyFileIndex
except ImportError:
pass

__version__ = get_versions()["version"]
del get_versions
__version__ = _version.get_versions()["version"]
49 changes: 49 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "pyfileindex"
description = "pyfileindex - pythonic file system index"
authors = [
{ name = "Jan Janssen", email = "janssen@mpie.de" },
]
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 = [
"numpy==1.26.0",
"pandas==2.1.3",
"scandir==1.10.0",
]
dynamic = ["version"]

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

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

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

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

This file was deleted.

38 changes: 2 additions & 36 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,3 @@
"""
Setuptools based setup module
"""
from setuptools import setup, find_packages
import versioneer
from setuptools import setup

setup(
name='pyfileindex',
version=versioneer.get_version(),
description='pyfileindex - pythonic file system index',
long_description='pyfileindex creates a dynamic file system index inside a pandas DataFrame.',

url='https://github.com/pyfileindex/pyfileindex',
author='Jan Janssen',
author_email='janssen@mpie.de',
license='BSD',

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.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11'
],

keywords='pyfileindex',
packages=find_packages(exclude=["*tests*", "*binder*", "*notebooks*"]),
install_requires=[
'pandas==2.1.3',
'scandir==1.10.0'
],
cmdclass=versioneer.get_cmdclass(),
)
setup()

0 comments on commit 0f2c6a9

Please sign in to comment.