diff --git a/.dockerignore b/.dockerignore index 3bc615bd..d4a62d81 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,2 @@ -.git/ venv*/ .tox/ diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 12e21111..967b66eb 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -39,10 +39,12 @@ jobs: run: | python -m isort --check --profile black . - - name: Lint sdx-controller Dockerfile - uses: hadolint/hadolint-action@v3.1.0 - with: - dockerfile: Dockerfile + # # Disable hadolint check until + # # https://github.com/hadolint/hadolint/issues/943 is solved. + # - name: Lint sdx-controller Dockerfile + # uses: hadolint/hadolint-action@v3.1.0 + # with: + # dockerfile: Dockerfile - name: Lint bapm-server Dockerfile uses: hadolint/hadolint-action@v3.1.0 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 30c34e6a..1635a6d6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ on: permissions: contents: read - + jobs: test: @@ -28,7 +28,7 @@ jobs: ports: - 5672:5672 - 15672:15672 - + mongodb: image: mongo:7.0.5 ports: @@ -46,10 +46,10 @@ jobs: - "3.10" steps: - + - name: Check out code uses: actions/checkout@v3 - + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: @@ -82,7 +82,7 @@ jobs: SUB_QUEUE: 'sdx-controller-test-queue' DB_NAME: 'sdx-controllder-test-db' DB_CONFIG_TABLE_NAME: 'sdx-controller-test-table' - MONGODB_CONNSTRING: 'mongodb://guest:guest@localhost:27017/' + MONGODB_CONNSTRING: 'mongodb://guest:guest@localhost:27017/' timeout-minutes: 3 - name: Send coverage data to coveralls.io diff --git a/.gitignore b/.gitignore index 758a7d94..5e4d671c 100644 --- a/.gitignore +++ b/.gitignore @@ -136,3 +136,4 @@ dmypy.json /*.sqlite3-wal /db/* +/swagger_server/_version.py diff --git a/Dockerfile b/Dockerfile index 50982169..e6c7307e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,13 +9,15 @@ RUN apt-get update \ WORKDIR /usr/src/app -COPY requirements.txt /usr/src/app/ - -RUN pip3 install --no-cache-dir -r requirements.txt - WORKDIR /usr/src/app COPY . /usr/src/app +# In order to make setuptools_scm work during container build, we +# temporarily bind-mount .git. Via +# https://github.com/pypa/setuptools_scm/issues/77#issuecomment-844927695 +RUN --mount=source=.git,target=.git,type=bind \ + pip install --no-cache-dir . + EXPOSE 8080 ENTRYPOINT ["python3"] diff --git a/README.md b/README.md index bab773e6..c79015e5 100644 --- a/README.md +++ b/README.md @@ -138,7 +138,7 @@ directory: ```console $ python3 -m venv venv --upgrade-deps $ source ./venv/bin/activate -$ pip3 install -r requirements.txt +$ pip3 install [--editable] . $ source .env $ python3 -m swagger_server ``` diff --git a/pyproject.toml b/pyproject.toml index 0b342166..ea51c998 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,71 @@ +[build-system] +requires = [ + "setuptools >= 61.0", + # "setuptools-scm >= 6.2", +] +build-backend = "setuptools.build_meta" + +[project] +name = "sdx-controller" +description = "AtlanticWave-SDX project's main controller" +dynamic = [ "version" ] +authors = [ + { name = "Yufeng Xin", email = "yxin@renci.org" }, + { name = "Cong Wang", email = "cwang@renci.org" }, + { name = "Sajith Sasidharan", email = "sajith@renci.org" }, +] +readme = "README.md" +requires-python = ">=3.8" +license = {file = "LICENSE"} +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent" +] +dependencies = [ + "jsonschema == 3.2.0", + "connexion[swagger-ui] >= 2.14.1", + "python_dateutil >= 2.8", + "setuptools >= 21.0.0", + "pika >= 1.2.0", + "dataset", + "pymongo > 3.0", + "sdx-pce @ git+https://github.com/atlanticwave-sdx/pce@2.0.6.dev2", +] + +[project.optional-dependencies] +test = [ + "flask_testing == 0.8.1", + "coverage >= 4.0.3", + "networkx == 2.8.8", + "pytest >= 7.2.0", + "pytest-cov >= 4.0.0", + "pluggy >= 0.3.1", + "py >= 1.4.31", + "randomize >= 0.13", +] +lint = [ + "black == 23.*", + "isort == 5.*", +] + +[options.packages.find] +where = "swagger_server" + +[tool.setuptools] +packages = ["swagger_server", "bapm_server"] + +[tool.setuptools_scm] +# Write version info collected from git to a file. This happens when +# we run `python -m build`. +write_to = "swagger_server/_version.py" + [tool.black] include = '\.py?$' [tool.isort] profile = "black" -src_paths = ["setup.py", "swagger_server", "bapm_server"] +src_paths = ["swagger_server", "bapm_server"] [tool.coverage.run] branch = true diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 801101a2..00000000 --- a/requirements.txt +++ /dev/null @@ -1,9 +0,0 @@ -jsonschema==3.2.0 -connexion[swagger-ui] >= 2.14.1 -python_dateutil >= 2.8 -setuptools >= 21.0.0 -pika >= 1.2.0 -dataset -pymongo > 3.0 - -sdx-pce @ git+https://github.com/atlanticwave-sdx/pce@2.0.6.dev2 diff --git a/setup.py b/setup.py deleted file mode 100644 index 154448b4..00000000 --- a/setup.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding: utf-8 - - -from setuptools import find_packages, setup - -NAME = "swagger_server" -VERSION = "2.0.0" -# To install the library, run the following -# -# python setup.py install -# -# prerequisite: setuptools -# http://pypi.python.org/pypi/setuptools - -REQUIRES = ["connexion"] - -setup( - name=NAME, - version=VERSION, - description="SDX-Controller", - author_email="yxin@renci.org", - url="", - keywords=["Swagger", "SDX-Controller"], - install_requires=REQUIRES, - packages=find_packages(), - package_data={"": ["swagger/swagger.yaml"]}, - include_package_data=True, - entry_points={"console_scripts": ["swagger_server=swagger_server.__main__:main"]}, - long_description="""\ - You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). - """, -) diff --git a/test-requirements.txt b/test-requirements.txt deleted file mode 100644 index c65f17ff..00000000 --- a/test-requirements.txt +++ /dev/null @@ -1,9 +0,0 @@ -flask_testing==0.8.1 -coverage>=4.0.3 -networkx==2.8.8 -pytest>=7.2.0 -pytest-cov>=4.0.0 -pluggy>=0.3.1 -py>=1.4.31 -randomize>=0.13 -tox==3.25 diff --git a/tox.ini b/tox.ini index 095bbc7e..87ef9229 100644 --- a/tox.ini +++ b/tox.ini @@ -1,10 +1,12 @@ [tox] envlist = py3 +requires = + tox>=4 + [testenv] deps = - -r{toxinidir}/requirements.txt - -r{toxinidir}/test-requirements.txt + [test] commands = pytest --cov swagger_server --cov bapm_server {posargs}