New packaging relying only pyproject.toml

This commit is contained in:
grossmj 2023-08-10 22:44:37 +10:00
parent 17f71f970e
commit 1cb433c5bc
13 changed files with 38 additions and 82 deletions

View File

@ -31,9 +31,6 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install -r dev-requirements.txt
- name: Install Windows dependencies
if: matrix.os == 'windows-latest'
run: python -m pip install -r win-requirements.txt
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names

View File

@ -1,2 +0,0 @@
Jeremy Grossmann
Julien Duponchelle

View File

@ -1,11 +1,7 @@
include README.md
include AUTHORS
include LICENSE
include MANIFEST.in
include requirements.txt
include conf/*.conf
recursive-include tests *
recursive-exclude docs *
include CHANGELOG
recursive-include gns3server *
recursive-exclude docs *
recursive-exclude * __pycache__
recursive-exclude * *.py[co]

View File

@ -85,7 +85,7 @@ cd gns3-server
git checkout 3.0
python3 -m venv venv-gns3server
source venv-gns3server/bin/activate
python3 setup.py install
python3 -m pip install .
python3 -m gns3server
```

View File

@ -1,5 +1,3 @@
-r requirements.txt
pytest==7.4.0
flake8==5.0.4 # v5.0.4 is the last to support Python 3.7
pytest-timeout==2.1.0

View File

@ -18,11 +18,15 @@
Docker server module.
"""
import os
import sys
import json
import asyncio
import logging
import aiohttp
import shutil
import subprocess
from gns3server.utils import parse_version
from gns3server.utils.asyncio import locking
from gns3server.compute.base_manager import BaseManager
@ -54,6 +58,25 @@ class Docker(BaseManager):
self._session = None
self._api_version = DOCKER_MINIMUM_API_VERSION
@staticmethod
def install_busybox():
if not sys.platform.startswith("linux"):
return
dst_busybox = os.path.join(os.path.dirname(os.path.abspath(__file__)), "resources", "bin", "busybox")
if os.path.isfile(dst_busybox):
return
for busybox_exec in ("busybox-static", "busybox.static", "busybox"):
busybox_path = shutil.which(busybox_exec)
if busybox_path:
log.info(f"Installing busybox from '{busybox_path}'")
try:
shutil.copy2(busybox_path, dst_busybox, follow_symlinks=True)
return
except OSError as e:
raise DockerError(f"Could not install busybox: {e}")
raise DockerError("No busybox executable could be found")
async def _check_connection(self):
if not self._connected:

View File

@ -523,7 +523,7 @@ class DockerVM(BaseNode):
async def update(self):
"""
Destroy an recreate the container with the new settings
Destroy and recreate the container with the new settings
"""
# We need to save the console and state and restore it
@ -544,6 +544,9 @@ class DockerVM(BaseNode):
Starts this Docker container.
"""
# make sure busybox is installed
self.manager.install_busybox()
try:
state = await self._get_container_state()
except DockerHttp404Error:

View File

@ -22,11 +22,6 @@ import asyncio
import aiofiles
import shutil
try:
import importlib_resources
except ImportError:
from importlib import resources as importlib_resources
from typing import Tuple, List
from aiohttp.client_exceptions import ClientError

View File

@ -167,8 +167,9 @@ class Server:
config.Server.allow_remote_console = args.allow
config.Server.host = args.host
config.Server.port = args.port
config.Server.certfile = args.certfile
config.Server.certkey = args.certkey
#FIXME
#config.Server.certfile = args.certfile
#config.Server.certkey = args.certkey
config.Server.enable_ssl = args.ssl
def _signal_handling(self):

View File

@ -7,7 +7,7 @@ name = "gns3-server"
description = "GNS3 graphical interface for the GNS3 server."
license = {file = "LICENSE"}
authors = [
{ name="Jeremy Grossmann" }
{ name = "Jeremy Grossmann", email = "developers@gns3.com" }
]
readme = "README.md"
requires-python = ">=3.7"
@ -29,7 +29,7 @@ classifiers = [
"Programming Language :: Python :: Implementation :: CPython"
]
dynamic = ["version", "dependencies"]
dynamic = ["version", "dependencies", "optional-dependencies"]
[tool.setuptools]
packages = ["gns3server"]
@ -38,15 +38,8 @@ packages = ["gns3server"]
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"
]
[tool.setuptools.dynamic.optional-dependencies]
development = {file = ['dev-requirements.txt']}
[project.urls]
"Homepage" = "http://gns3.com"

View File

@ -19,4 +19,3 @@ email-validator==2.0.0.post2
watchfiles==0.19.0
zstandard==0.21.0
importlib_resources>=1.3
setuptools>=60.8.1

View File

@ -1,47 +0,0 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2013 GNS3 Technologies Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys
import os
import shutil
import subprocess
from setuptools import setup
BUSYBOX_PATH = "gns3server/compute/docker/resources/bin/busybox"
def copy_busybox():
if not sys.platform.startswith("linux"):
return
if os.path.isfile(BUSYBOX_PATH):
return
for bb_cmd in ("busybox-static", "busybox.static", "busybox"):
bb_path = shutil.which(bb_cmd)
if bb_path:
if subprocess.call(["ldd", bb_path],
stdin=subprocess.DEVNULL,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL):
shutil.copy2(bb_path, BUSYBOX_PATH, follow_symlinks=True)
break
else:
raise SystemExit("No static busybox found")
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