Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate setup to poetry #790

Merged
merged 11 commits into from
Aug 31, 2023
17 changes: 15 additions & 2 deletions .github/scripts/static_version_writer.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
import os
import os
import re
from importlib.util import module_from_spec, spec_from_file_location

ROOT = os.path.dirname(os.path.abspath(__file__))

def version_writer(func):
def wrapper(package_path):
version = func(package_path)
toml_path = os.path.join(package_path, "..", "pyproject.toml")
with open(toml_path, "r") as f:
toml_content = f.read()
toml_content = re.sub("version\s=\s\"[0-9\.]+\"", f"version = \"{version}\"", toml_content)
with open(toml_path, "w") as f:
f.write(toml_content)
return version
return wrapper

@version_writer
def get_version(package_path):
spec = spec_from_file_location("version", os.path.join(package_path, "_version.py"))
module = module_from_spec(spec)
Expand All @@ -13,9 +25,10 @@ def get_version(package_path):
return version



try:
version = get_version(os.path.join(ROOT, "..", "..", "ersilia"))
except:
version = get_version(os.path.join(ROOT, "ersilia"))

print(version)
print(version)
13 changes: 9 additions & 4 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,21 @@ jobs:
wget https://raw.githubusercontent.com/ersilia-os/ersilia/master/ersilia/_static_version.py
mv _static_version.py ersilia/.

- name: Install dependencies
- name: Install Poetry
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
python -m pip install --upgrade pip
pip install setuptools wheel twine
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
source $HOME/.poetry/env
echo `poetry --version`
echo "Poetry successfully installed"

- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}

run: |
python setup.py sdist bdist_wheel
source $HOME/.poetry/env
poetry build
twine upload --verbose --skip-existing dist/* -u $TWINE_USERNAME -p $TWINE_PASSWORD
8 changes: 8 additions & 0 deletions ersilia/setup/requirements/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from .bentoml import BentoMLRequirement

def check_bentoml():
req = BentoMLRequirement()
if not req.is_bentoml_ersilia_version():
req.install()
return

66 changes: 66 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
[tool.poetry]
name = "ersilia"
version = "0.1.27"
description = "A hub of AI/ML models for open source drug discovery and global health"
license = "GPLv3"
authors = ["Ersilia Open Source Initiative <hello@ersilia.io>"]
readme = "README.md"
homepage = "https://ersilia.io"
repository = "https://github.com/ersilia-os/ersilia"
documentation = "https://ersilia.io/model-hub"
keywords= ["drug-discovery", "machine-learning", "ersilia", "open-science", "global-health", "model-hub", "infectious-diseases"]
classifiers=[
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Operating System :: OS Independent",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
]
packages = [
{include = "ersilia"},
]
include = [
"ersilia/hub/content/metadata/*.txt",
"ersilia/io/types/examples/*.tsv",
]

[tool.poetry.dependencies]
python = ">=3.7"
inputimeout = "^1.0.4"
emoji = "^2.8.0"
validators = [
{version="0.20.0", python="3.7.*"},
{version="~0.21.0", python=">=3.8"},
]
h5py = "^3.7.0" # For compatibility with isaura
loguru = "^0.6.0" # For compatibility with isaura
pyairtable = "<2"
PyYAML = "^6.0.1"
dockerfile-parse = "^2.0.1"
tqdm = "^4.66.1"
click = "^8.1.7"
docker = "^6.1.3"
isaura = {version="0.1", optional=true}
pytest = {version = "^7.4.0", optional = true}
fuzzywuzzy = {version = "^0.18.0", optional = true}
sphinx = {version = ">=5.3.0", optional = true} # For compatibility with python 3.7.x
jinja2 = {version = "^3.1.2", optional = true}
levenshtein = {version = "^0.21.1", optional = true} # For faster fuzzy search


[tool.poetry.extras]
# Instead of using poetry dependency groups, we use extras to make it pip installable
lake = ["isaura"]
docs = ["sphinx", "jinja2"]
test = ["pytest", "fuzzywuzzy", "levenshtein"]
#all = [lake, docs, test]

[tool.poetry.scripts]
ersilia = "ersilia.cli:cli"
bentoml = "ersilia.setup.requirements:check_bentoml"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Loading