Skip to content

Commit 4e1dba6

Browse files
committed
update pyproject.toml and publish_package workflow
1 parent 1095e80 commit 4e1dba6

4 files changed

Lines changed: 98 additions & 10 deletions

File tree

.github/workflows/publish_package.yml

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,61 @@ on:
77

88
jobs:
99
build-and-publish-pypi:
10+
if: ${{ github.event.release.preprelease == false }}
1011
runs-on: ubuntu-latest
1112
steps:
1213
- name: Checkout code
13-
uses: actions/checkout@v2
14+
uses: actions/checkout@v4
1415

1516
- name: Setup Python
16-
uses: actions/setup-python@v2
17+
uses: actions/setup-python@v5
1718
with:
1819
python-version: '3.10'
1920

2021
- name: Install dependencies
2122
run: |
2223
python -m pip install --upgrade pip
23-
pip install setuptools wheel twine
24+
pip install build twine
2425
25-
- name: Build package
26-
run: python setup.py sdist bdist_wheel
26+
- name: Build dists (sdist+wheel)
27+
run: python -m build
28+
29+
- name: Twine check
30+
run: python -m twine check dist/*
31+
32+
- name: Smoke install & import
33+
run: |
34+
python -m venv .venv
35+
. .venv/bin/activate
36+
python -m pip install -U pip
37+
python -m pip install dist/*.whl
38+
python - <<'PY'
39+
import importlib.metadata as md
40+
tops = {str(f).split('/')[0] for d in md.distributions()
41+
for f in (d.files or [])}
42+
assert "tpot" in tops, "tpot not packaged at top level"
43+
import tpot
44+
from tpot import TPOTClassifier, TPOTRegressor
45+
print("OK: imports")
46+
PY
47+
48+
- name: TPOT fit smoke
49+
run: |
50+
. .venv/bin/activate
51+
python - <<'PY'
52+
import numpy as np
53+
from tpot import TPOTClassifier
54+
X = np.random.RandomState(0).randn(40, 5)
55+
y = (X[:,0] > 0).astype(int)
56+
t = TPOTClassifier(generations=1, population_size=5,
57+
max_time_mins=0.1, verbosity=0)
58+
t.fit(X, y)
59+
print("OK: fit")
60+
PY
2761
2862
- name: Upload to PyPI
2963
env:
3064
TWINE_USERNAME: __token__
3165
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
32-
run: twine upload dist/*
66+
run: python -m twine upload dist/*
3367

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ build/*
1717
*.egg
1818
*.coverage*
1919
docs/documentation/
20-
mkdocs.yml
20+
mkdocs.yml
21+
tpot/_version.py

pyproject.toml

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,48 @@ warn_redundant_casts = true
2020
warn_return_any = true
2121
warn_unreachable = true
2222
warn_unused_configs = true
23-
no_implicit_reexport = true
23+
no_implicit_reexport = true
24+
25+
26+
27+
28+
[build-system]
29+
requires = ["setuptools>=80", "setuptools-scm>=8", "wheel", "build"]
30+
build-backend = "setuptools.build_meta"
31+
32+
[project]
33+
name = "tpot"
34+
description = "Automated ML via genetic programming."
35+
readme = "README.md"
36+
license = { text = "LGPL-3.0-or-later" }
37+
authors = [{ name = "EpistasisLab" }]
38+
requires-python = ">=3.10,<3.14"
39+
dynamic = ["version", "dependencies", "optional-dependencies"]
40+
41+
[project.urls]
42+
Homepage = "https://epistasislab.github.io/tpot/"
43+
Source = "https://github.com/EpistasisLab/tpot"
44+
Issues = "https://github.com/EpistasisLab/tpot/issues"
45+
46+
[project.optional-dependencies]
47+
sklearnex = ["scikit-learn-intelex>=2024.0"]
48+
xgboost = ["xgboost>=1.7"]
49+
dask = ["dask>=2023.2.0", "distributed>=2023.2.0", "dask-ml>=2023.3.24"]
50+
lightgbm = ["lightgbm>=3.3.3"]
51+
optuna = ["optuna>=3.0.0"]
52+
jupyter = ["jupyter"]
53+
54+
[tool.setuptools]
55+
zip-safe = false
56+
57+
[tool.setuptools.packages.find]
58+
where = ["."]
59+
include = ["tpot*"]
60+
namespaces = false
61+
62+
[tool.setuptools_scm]
63+
version_file = "tpot/_version.py"
64+
65+
[tool.setuptools.dynamic]
66+
dependencies = { file = ["requirements.txt"] }
67+
optional-dependencies = { dev = { file = ["requirements-dev.txt"] } }

tpot/__init__.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,14 @@
5555
from .tpot_estimator import TPOTClassifier, TPOTRegressor, TPOTEstimator, TPOTEstimatorSteadyState
5656

5757
from update_checker import update_check
58-
from ._version import __version__
59-
update_check("tpot",__version__)
58+
59+
from importlib.metdata import version as _v, PackageNotFoundError as _PNF
60+
61+
try:
62+
__version__ = _v("tpot")
63+
except _PNF:
64+
from ._version import version as __version__ # written by setuptools-scm
65+
66+
# from ._version import __version__
67+
68+
update_check("tpot",__version__)

0 commit comments

Comments
 (0)