From ffe35b6559ab2d042dc34c255d66719d82867bef Mon Sep 17 00:00:00 2001 From: grossmj Date: Tue, 21 Mar 2023 17:41:01 +1000 Subject: [PATCH 1/2] Migrate to pyproject.toml --- pyproject.toml | 58 +++++++++++++++++++++++++++++++++++++++++ setup.py | 71 +++----------------------------------------------- 2 files changed, 61 insertions(+), 68 deletions(-) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..13ac8c42 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,58 @@ +[build-system] +requires = ["setuptools>=61.0"] +build-backend = "setuptools.build_meta" + +[project] +name = "gns3-server" +description = "GNS3 graphical interface for the GNS3 server." +license = {file = "LICENSE"} +authors = [ + { name="Jeremy Grossmann" } +] +readme = "README.md" +requires-python = ">=3.7" +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Console", + "Framework :: FastAPI", + "Intended Audience :: Information Technology", + "Topic :: System :: Networking", + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + "Natural Language :: English", + "Operating System :: POSIX :: Linux", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: Implementation :: CPython" +] + +dynamic = ["version", "dependencies"] + +[tool.setuptools] +packages = ["gns3server"] + +[tool.setuptools.dynamic] +version = {attr = "gns3server.version.__version__"} +dependencies = {file = "requirements.txt"} + +[project.optional-dependencies] +test = [ + "pytest==7.2.2", + "flake8==5.0.4", # v5.0.4 is the last to support Python 3.7 + "pytest-timeout==2.1.0", + "pytest-asyncio==0.20.3", + "requests==2.28.2", + "httpx==0.23.3" +] + +[project.urls] +"Homepage" = "http://gns3.com" +"Repository" = "http://github.com/GNS3/gns3-server" +"Bug tracker" = "http://github.com/GNS3/gns3-server/issues" + +[project.scripts] +gns3server = "gns3server.main:main" +gns3vmnet = "gns3server.utils.vmnet:main" diff --git a/setup.py b/setup.py index 595336c7..87d5c711 100644 --- a/setup.py +++ b/setup.py @@ -20,28 +20,7 @@ import os import shutil import subprocess -from setuptools import setup, find_packages -from setuptools.command.test import test as TestCommand - -# we only support Python 3 version >= 3.7 -if len(sys.argv) >= 2 and sys.argv[1] == "install" and sys.version_info < (3, 7, 0): - raise SystemExit("Python 3.7 or higher is required") - - -class PyTest(TestCommand): - - def finalize_options(self): - TestCommand.finalize_options(self) - self.test_args = [] - self.test_suite = True - - def run_tests(self): - # import here, cause outside the eggs aren't loaded - import pytest - - errcode = pytest.main(self.test_args) - sys.exit(errcode) - +from setuptools import setup BUSYBOX_PATH = "gns3server/compute/docker/resources/bin/busybox" @@ -64,49 +43,5 @@ def copy_busybox(): raise SystemExit("No static busybox found") -copy_busybox() -dependencies = open("requirements.txt", "r").read().splitlines() - -setup( - name="gns3-server", - version=__import__("gns3server").__version__, - url="http://github.com/GNS3/gns3-server", - license="GNU General Public License v3 (GPLv3)", - cmdclass={"test": PyTest}, - description="GNS3 server", - long_description=open("README.md", "r").read(), - long_description_content_type="text/markdown", - install_requires=dependencies, - entry_points={ - "console_scripts": [ - "gns3server = gns3server.main:main", - "gns3vmnet = gns3server.utils.vmnet:main" - ] - }, - packages=find_packages(".", exclude=["docs", "tests*"]), - include_package_data=True, - zip_safe=False, - platforms="any", - python_requires='>=3.7.0', - setup_requires=["setuptools>=17.1"], - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Environment :: Console", - "Intended Audience :: Information Technology", - "Topic :: System :: Networking", - "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", - "Natural Language :: English", - "Operating System :: POSIX", - "Operating System :: MacOS :: MacOS X", - "Operating System :: Microsoft :: Windows", - "Programming Language :: Python", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: Implementation :: CPython", - ], -) +copy_busybox() # TODO: this should probably be done when the first time the server is started +setup() # required with setuptools below version 64.0.0 From 513bc0fb162707cd51e97da521fe46aec6dfd060 Mon Sep 17 00:00:00 2001 From: grossmj Date: Tue, 21 Mar 2023 18:56:00 +1000 Subject: [PATCH 2/2] Do not use setup.py directly --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 159a729f..4ced87dc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,4 +34,4 @@ COPY . /gns3server RUN mkdir -p ~/.config/GNS3/3.0/ RUN cp scripts/gns3_server.conf ~/.config/GNS3/3.0/ -RUN python3 setup.py install +RUN python3 -m pip install .