14
0
Files
python-port-for/python-port-for.spec
Markéta Machová 1bd2bf9f95 Accepting request 967279 from home:pgajdos:python
- version update to 0.6.2
  0.6.2
  ----------
  Misc
  ++++
  - Added Python 3.10 to trove classifiers and to CI
  0.6.1
  ----------
  Bugfix
  ++++++
  - Fixed typing definition for get_port function
  0.6.0
  ----------
  Feature
  +++++++
  - Added `get_port` helper that can randomly select open port out of given set, or range-tuple
  - Added type annotations and compatibility with PEP 561
  - Support only python 3.7 and up
- python-mock is not required for build

OBS-URL: https://build.opensuse.org/request/show/967279
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-port-for?expand=0&rev=3
2022-04-06 12:42:16 +00:00

100 lines
3.1 KiB
RPMSpec

#
# spec file for package python-port-for
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-port-for
Version: 0.6.2
Release: 0
License: MIT
Summary: Utility that helps with local TCP ports managment
URL: https://github.com/kmike/port-for/
Group: Development/Languages/Python
Source: https://github.com/kmike/port-for/archive/refs/tags/v%{version}.tar.gz
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires(post): update-alternatives
Requires(postun):update-alternatives
BuildArch: noarch
%python_subpackages
%description
port-for is a command-line utility and a python library that
helps with local TCP ports management.
It can find an unused TCP localhost port and remember the association::
$ sudo port-for foo
37987
This can be useful when you are installing a stack of software
with multiple parts needing port numbers.
There are several rules port-for is trying to follow to find and
return a new unused port:
1) Port must be unused: port-for checks this by trying to connect
to the port and to bind to it.
2) Port must be IANA unassigned and otherwise not well-known:
this is acheived by maintaining unassigned ports list
(parsed from IANA and Wikipedia).
3) Port shouldn't be inside ephemeral port range.
This is important because ports from ephemeral port range can
be assigned temporary by OS (e.g. by machine's IP stack) and
this may prevent service restart in some circumstances.
``port-for`` doesn't return ports from ephemeral port ranges
configured at the current machine.
4) Other heuristics are also applied: ``port-for`` tries to return
a port from larger port ranges; it also doesn't return ports that are
too close to well-known ports.
%prep
%setup -q -n port-for-%{version}
%build
%python_build
%install
%python_install
%python_expand rm -f %{buildroot}%{$python_sitelib}/port_for/tests.py* %{buildroot}%{$python_sitelib}/port_for/__pycache__/tests.*
%python_clone -a %{buildroot}%{_bindir}/port-for
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check
sed -i '/^addopts =/d' setup.cfg
%pytest --doctest-modules src/port_for/utils.py tests/test*.py
%post
%python_install_alternative port-for
%postun
%python_uninstall_alternative port-for
%files %{python_files}
%license LICENSE.txt
%doc README.rst
%{python_sitelib}/*
%python_alternative %{_bindir}/port-for
%changelog