From ccafad57adb31229e5539a402a5ac922c7bb69e1 Mon Sep 17 00:00:00 2001 From: Taras Shapovalov Date: Sun, 25 Aug 2024 15:06:37 +0400 Subject: [PATCH] Fix package creation --- .pypirc | 2 +- Makefile | 14 +++-- jupyterhub_config.py | 4 +- setup.py | 63 ++++++------------- .../__init__.py | 0 .../form.html.jinja | 0 {swm_jupyter_spawner => swmjupyter}/form.py | 0 .../job.sh.jinja | 0 .../spawner.py | 2 +- 9 files changed, 32 insertions(+), 53 deletions(-) rename {swm_jupyter_spawner => swmjupyter}/__init__.py (100%) rename {swm_jupyter_spawner => swmjupyter}/form.html.jinja (100%) rename {swm_jupyter_spawner => swmjupyter}/form.py (100%) rename {swm_jupyter_spawner => swmjupyter}/job.sh.jinja (100%) rename {swm_jupyter_spawner => swmjupyter}/spawner.py (99%) diff --git a/.pypirc b/.pypirc index 8ed3430..7b47653 100644 --- a/.pypirc +++ b/.pypirc @@ -3,4 +3,4 @@ index-servers=pypi [pypi] repository=https://upload.pypi.org/legacy/ -username=openworkload +username=__token__ diff --git a/Makefile b/Makefile index 6a01306..f366ccd 100644 --- a/Makefile +++ b/Makefile @@ -15,16 +15,16 @@ prepare-venv: .PHONY: format format: . .venv/bin/activate - $(VENV_BIN)/autoflake -i -r --ignore-init-module-imports swm_jupyter_spawner - $(VENV_BIN)/black swm_jupyter_spawner - $(VENV_BIN)/isort swm_jupyter_spawner + $(VENV_BIN)/autoflake -i -r --ignore-init-module-imports swmjupyter + $(VENV_BIN)/black swmjupyter + $(VENV_BIN)/isort swmjupyter .PHONY: check check: . .venv/bin/activate - $(VENV_BIN)/ruff check swm_jupyter_spawner - $(VENV_BIN)/mypy swm_jupyter_spawner - $(VENV_BIN)/bandit -r swm_jupyter_spawner -c "pyproject.toml" --silent + $(VENV_BIN)/ruff check swmjupyter + $(VENV_BIN)/mypy swmjupyter + $(VENV_BIN)/bandit -r swmjupyter -c "pyproject.toml" --silent .PHONY: package package: @@ -34,6 +34,8 @@ package: .PHONY: clean clean: rm -f ./dist/*.whl + rm -fr swmjupyter.egg-info/* + rm -fr build/* .PHONY: upload upload: diff --git a/jupyterhub_config.py b/jupyterhub_config.py index 97c8902..f5afbe3 100644 --- a/jupyterhub_config.py +++ b/jupyterhub_config.py @@ -4,12 +4,12 @@ # For development purpose we use the spawner package from the sources: sys.path.append(os.path.dirname(os.path.realpath(__file__))) -from swm_jupyter_spawner.spawner import SwmSpawner +from swmjupyter.spawner import SwmSpawner c.JupyterHub.hub_ip = '0.0.0.0' c.JupyterHub.hub_port = 8081 c.JupyterHub.log_level = 'DEBUG' -c.JupyterHub.spawner_class = 'swm_jupyter_spawner.spawner.SwmSpawner' +c.JupyterHub.spawner_class = 'swmjupyter.spawner.SwmSpawner' c.JupyterHub.authenticator_class = 'jupyterhub.auth.DummyAuthenticator' c.JupyterHub.tornado_settings = { "slow_spawn_timeout": 0, diff --git a/setup.py b/setup.py index 49f7138..550cc2a 100644 --- a/setup.py +++ b/setup.py @@ -1,13 +1,12 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python +# coding: utf-8 -import os -import sys +from codecs import open # to use a consistent encoding +from os import path +from subprocess import check_output -from distutils.core import setup -from pathlib import Path -from setuptools import find_packages +from setuptools import setup, find_packages -HERE = Path(__file__).parent.resolve() def get_version(): cmd = "git describe --tags" @@ -21,65 +20,43 @@ def get_version(): def get_long_description(): - with open(os.path.join(HERE, "README.md"), encoding="utf-8") as f: + here = path.abspath(path.dirname(__file__)) + with open(path.join(here, "README.md"), encoding="utf-8") as f: long_description = f.read() return long_description -setup_args = dict( - name='swm_jupyter_spawner', +setup( + name="swmjupyter", version=get_version(), - description="""A spawner for Jupyterhub to spawn notebooks over Sky Port""", + description="A spawner for JupyterHub to spawn notebooks over Sky Port", long_description=get_long_description(), long_description_content_type="text/markdown", + url="https://github.com/openworkload/swm-jupyter-term", author="Taras Shapovalov", author_email="taras@iclouds.net", - url="https://github.com/openworkload/swm-jupyter-term", - license="BSD", - platforms="Linux, Mac OS X, Windows", packages=find_packages(), + license="BSD", + include_package_data=True, + python_requires=">=3.10, <4", + platforms="Linux", keywords=[ "HPC", "High Performance Computing", "Cloud Computing", - "Sky Port", - "Open Workload" + "Open Workload", + "Sky Port" ], classifiers=[ "Development Status :: 3 - Alpha", - "Intended Audience :: Developers", - "Intended Audience :: System Administrators", - "Intended Audience :: Science/Research", - "License :: OSI Approved :: BSD License", - "Programming Language :: Python", "Programming Language :: Python :: 3", + "License :: OSI Approved :: BSD License", + "Operating System :: OS Independent", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3 :: Only", - "Framework :: Jupyter", - "Framework :: Jupyter :: JupyterLab", - "Framework :: Jupyter :: JupyterLab :: 3", - "Framework :: Jupyter :: JupyterLab :: Extensions", - "Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt", ], project_urls={ "Bug Reports": "https://github.com/openworkload/swm-jupyter-term/issues", "Source": "https://github.com/openworkload/swm-jupyter-term", }, ) - -# setuptools requirements -if "setuptools" in sys.modules: - setup_args["install_requires"] = install_requires = [] - with open("requirements.txt") as f: - for line in f.readlines(): - req = line.strip() - if not req or req.startswith(("-e", "#")): - continue - install_requires.append(req) - - -def main(): - setup(**setup_args) - -if __name__ == "__main__": - main() diff --git a/swm_jupyter_spawner/__init__.py b/swmjupyter/__init__.py similarity index 100% rename from swm_jupyter_spawner/__init__.py rename to swmjupyter/__init__.py diff --git a/swm_jupyter_spawner/form.html.jinja b/swmjupyter/form.html.jinja similarity index 100% rename from swm_jupyter_spawner/form.html.jinja rename to swmjupyter/form.html.jinja diff --git a/swm_jupyter_spawner/form.py b/swmjupyter/form.py similarity index 100% rename from swm_jupyter_spawner/form.py rename to swmjupyter/form.py diff --git a/swm_jupyter_spawner/job.sh.jinja b/swmjupyter/job.sh.jinja similarity index 100% rename from swm_jupyter_spawner/job.sh.jinja rename to swmjupyter/job.sh.jinja diff --git a/swm_jupyter_spawner/spawner.py b/swmjupyter/spawner.py similarity index 99% rename from swm_jupyter_spawner/spawner.py rename to swmjupyter/spawner.py index 493c6f9..4518c93 100644 --- a/swm_jupyter_spawner/spawner.py +++ b/swmjupyter/spawner.py @@ -31,7 +31,7 @@ class SwmSpawner(Spawner): # type: ignore _swm_cert_file = Unicode("~/.swm/cert.pem", help="PEM certificate file path", config=True) # type: ignore _swm_job_id = None - _spool_dir = TemporaryDirectory(prefix=".swm_jupyter_spawner_") + _spool_dir = TemporaryDirectory(prefix=".swmjupyter_") _msg_queue: Queue[tuple[str, int]] = Queue() _last_msg: str = ""