Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ jobs:
strategy:
matrix:
python-version: ['3.12']
os: ['ubuntu-latest']

steps:
- uses: actions/checkout@v4
Expand All @@ -222,3 +221,40 @@ jobs:
pip install '.[dev]'
- name: "Run tests"
run: python -m pysr test main,jax,torch

wheel_test:
name: Test from wheel
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.12']
julia-version: ['1']
defaults:
run:
shell: bash -l {0}

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.julia-version }}

- name: "Build wheel"
run: |
python -m pip install --upgrade pip build virtualenv
python -m build --wheel
mkdir -p /tmp/artifacts
mv dist/*.whl /tmp/artifacts/

- name: "Install wheel in venv & run smoke test"
run: |
mkdir -p /tmp/wheeltest
cd /tmp/wheeltest
python -m virtualenv .venv
source .venv/bin/activate
pip install /tmp/artifacts/*.whl
python -c "import pysr; pysr.PySRRegressor(niterations=1).fit([[1]], [1])"
1 change: 0 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:
- 'pysr/**'
- '.github/workflows/docs.yml'
- 'docs/**'
- 'setup.py'
- 'README.md'
- 'mkdocs.yml'
workflow_dispatch:
Expand Down
3 changes: 2 additions & 1 deletion Apptainer.def
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ Stage: runtime

%files
./pyproject.toml /pysr/pyproject.toml
./setup.py /pysr/setup.py
./LICENSE /pysr/LICENSE
./README.md /pysr/README.md
./pysr /pysr/pysr

%post
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Scan through our [existing issues](https://github.com/MilesCranmer/PySR/issues)
check out the [guide](https://ai.damtp.cam.ac.uk/pysr/backend/) on modifying a custom SymbolicRegression.jl library.
In this case, you might instead be interested in making suggestions to the [SymbolicRegression.jl](http://github.com/MilesCranmer/SymbolicRegression.jl) library.

4. You can install your local version of PySR with `python setup.py install`, and run tests with `python -m pysr test main`.
4. You can install your local version of PySR with `pip install -e '.[dev]'`, and run tests with `python -m pysr test main`.

### Commit your update

Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
# Install PySR:
# We do a minimal copy so it doesn't need to rerun at every file change:
ADD ./pyproject.toml /pysr/pyproject.toml
ADD ./setup.py /pysr/setup.py
ADD ./LICENSE /pysr/LICENSE
ADD ./README.md /pysr/README.md
ADD ./pysr /pysr/pysr
RUN pip3 install --no-cache-dir .

Expand All @@ -28,8 +29,8 @@
RUN python3 -c 'import pysr; pysr.load_all_packages()'

# metainformation
LABEL org.opencontainers.image.authors = "Miles Cranmer"

Check warning on line 32 in Dockerfile

View workflow job for this annotation

GitHub Actions / docker (ubuntu-latest, linux/amd64, 3.12.3, 1.10.3)

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "LABEL key=value" should be used instead of legacy "LABEL key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
LABEL org.opencontainers.image.source = "https://github.com/MilesCranmer/PySR"

Check warning on line 33 in Dockerfile

View workflow job for this annotation

GitHub Actions / docker (ubuntu-latest, linux/amd64, 3.12.3, 1.10.3)

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "LABEL key=value" should be used instead of legacy "LABEL key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
LABEL org.opencontainers.image.licenses = "Apache License 2.0"

Check warning on line 34 in Dockerfile

View workflow job for this annotation

GitHub Actions / docker (ubuntu-latest, linux/amd64, 3.12.3, 1.10.3)

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "LABEL key=value" should be used instead of legacy "LABEL key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

CMD ["ipython"]
13 changes: 2 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "pysr"
Expand All @@ -24,7 +24,6 @@ dependencies = [
"scikit_learn>=1.0.0,<2.0.0",
"juliacall>=0.9.24,<0.9.26",
"click>=7.0.0,<9.0.0",
"setuptools>=50.0.0",
"beartype>=0.19,<0.22",
"typing-extensions>=4.0.0,<5.0.0",
]
Expand All @@ -49,13 +48,5 @@ dev = [
"types-pytz",
]

[tool.setuptools]
packages = ["pysr", "pysr._cli", "pysr.test"]
include-package-data = false
package-data = {pysr = ["juliapkg.json"]}

[tool.setuptools.dynamic]
dependencies = {file = "requirements.txt"}

[tool.isort]
profile = "black"
10 changes: 8 additions & 2 deletions pysr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
# old libraries:
from .julia_import import jl, SymbolicRegression # isort:skip

# Get the version using importlib.metadata (Python >= 3.8 is required):
from importlib.metadata import PackageNotFoundError, version

from . import sklearn_monkeypatch
from .deprecated import best, best_callable, best_row, best_tex, install, pysr
from .export_jax import sympy2jax
Expand All @@ -33,8 +36,11 @@
from .logger_specs import AbstractLoggerSpec, TensorBoardLoggerSpec
from .sr import PySRRegressor

# This file is created by setuptools_scm during the build process:
from .version import __version__
try:
__version__ = version("pysr")
except PackageNotFoundError: # pragma: no cover
# package is not installed
__version__ = "unknown"

__all__ = [
"jl",
Expand Down
3 changes: 2 additions & 1 deletion pysr/test/test_dev_pysr.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ WORKDIR /pysr
# Install PySR:
# We do a minimal copy so it doesn't need to rerun at every file change:
ADD ./pyproject.toml /pysr/pyproject.toml
ADD ./setup.py /pysr/setup.py
ADD ./LICENSE /pysr/LICENSE
ADD ./README.md /pysr/README.md

RUN mkdir /pysr/pysr
ADD ./pysr/*.py /pysr/pysr/
Expand Down
41 changes: 12 additions & 29 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,15 @@
import os
# setup.py – retained only for users who still type python setup.py ..."
import sys

from setuptools import setup
sys.stderr.write(
"""⚠️ PySR uses pyproject.toml instead of setup.py.

if os.path.exists(".git"):
kwargs = {
"use_scm_version": {
"write_to": "pysr/version.py",
},
"setup_requires": ["setuptools", "setuptools_scm"],
}
else:
# Read from pyproject.toml directly
import re
Install from a checkout with:
python -m pip install . # normal
python -m pip install -e . # editable (pip ≥21.3)

with open(os.path.join(os.path.dirname(__file__), "pyproject.toml")) as f:
data = f.read()
# Find the version
version = re.search(r'version = "(.*)"', data).group(1)

# Write the version to version.py
with open(os.path.join(os.path.dirname(__file__), "pysr", "version.py"), "w") as f:
f.write(f'__version__ = "{version}"')

kwargs = {
"use_scm_version": False,
"version": version,
}


# Build options are managed in pyproject.toml
setup(**kwargs)
Or install from PyPI with:
pip install pysr
"""
)
sys.exit(1)
Loading