diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d2c2aa0..b954f22 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,6 +1,8 @@ name: Tests -on: [push] +on: + push: + pull_request: jobs: build: @@ -11,22 +13,69 @@ jobs: python-version: ["3.9", "3.10", "3.11", "3.12"] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + cache: 'pip' + - name: Install dependencies run: | python -m pip install --upgrade pip pip install flake8 pytest pytest-cov if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names flake8 lingam --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 lingam --count --exit-zero --ignore=E203,E501,E741,C901 --max-line-length=127 --statistics + - name: Test with pytest run: | pytest -v --cov=lingam --cov-report=term-missing + + build-and-install: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.9", "3.10", "3.11", "3.12"] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + + - name: Build sdist & wheel via pyproject.toml + run: | + python -m venv venv_b + source venv_b/bin/activate + python -m pip install --upgrade pip setuptools wheel build + python -m build + ls -la dist/ + echo "List sdist contents:" + tar -tf dist/*.tar.gz | head -n 50 + + - name: Test install from wheel + run: | + python -m venv venv_w + source venv_w/bin/activate + pip install --no-cache-dir dist/*.whl + python -c "import lingam; print(lingam.__version__)" + pip check + + - name: Test install from sdist + run: | + python -m venv venv_s + source venv_s/bin/activate + pip install --no-cache-dir dist/*.tar.gz + python -c "import lingam; print(lingam.__version__)" + pip check diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..ac1ad15 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,49 @@ +[build-system] +requires = ["setuptools>=61", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "lingam" +description = "Python package for causal discovery based on LiNGAM." +readme = "README.md" +authors = [ + { name = "Takashi Ikeuchi" }, + { name = "Genya Haraoka" }, + { name = "Mayumi Ide" }, + { name = "Kouhei Nishikawa" }, + { name = "Yan Zeng" }, + { name = "Takashi Nicholas Maeda" }, + { name = "Wataru Kurebayashi" }, + { name = "Shohei Shimizu" } +] +license = { file = "LICENSE" } +requires-python = ">=3.9" +dependencies = [ + "numpy", + "scipy", + "scikit-learn", + "graphviz", + "statsmodels", + "networkx", + "pandas", + "pygam", + "matplotlib", + "psy", + "semopy", + "autograd" +] +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent" +] +dynamic = ["version"] + +[project.urls] +Homepage = "https://github.com/cdt15/lingam" + +[tool.setuptools.packages.find] +exclude = ["tests"] + +[tool.setuptools.dynamic] +version = { attr = "lingam.__version__" } diff --git a/setup.py b/setup.py deleted file mode 100644 index e3b2f0b..0000000 --- a/setup.py +++ /dev/null @@ -1,39 +0,0 @@ -import setuptools - -with open('README.md', 'r', encoding='utf-8') as fh: - README = fh.read() - -import lingam - -VERSION = lingam.__version__ - -setuptools.setup( - name='lingam', - version=VERSION, - author='T.Ikeuchi, G.Haraoka, M.Ide, Y.Zeng, T.N.Maeda, W.Kurebayashi, S.Shimizu', - description='LiNGAM Python Package', - long_description=README, - long_description_content_type='text/markdown', - install_requires=[ - 'numpy', - 'scipy', - 'scikit-learn', - 'graphviz', - 'statsmodels', - 'networkx', - 'pandas', - 'pygam', - 'matplotlib', - 'psy', - 'semopy', - 'autograd', - ], - url='https://github.com/cdt15/lingam', - packages=setuptools.find_packages(exclude=['tests']), - classifiers=[ - 'Programming Language :: Python :: 3', - 'License :: OSI Approved :: MIT License', - 'Operating System :: OS Independent', - ], - python_requires='>=3.9', -)