diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d6fb33f --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +mitogen-*.tar.gz diff --git a/README.md b/README.md deleted file mode 100644 index bfe18de..0000000 --- a/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# python-mitogen - -Distributed self-replicating programs in Python \ No newline at end of file diff --git a/python-mitogen.spec b/python-mitogen.spec new file mode 100644 index 0000000..7836149 --- /dev/null +++ b/python-mitogen.spec @@ -0,0 +1,135 @@ +# what it's called on pypi +%global srcname mitogen +# what it's imported as +%global libname %{srcname} +# name of egg info directory +%global eggname %{srcname} +# package name fragment +%global pkgname %{srcname} + +%global common_description %{expand: +Mitogen is a Python library for writing distributed self-replicating programs. + +There is no requirement for installing packages, copying files around, writing +shell snippets, upfront configuration, or providing any secondary link to a +remote machine aside from an SSH connection. Due to its origins for use in +managing potentially damaged infrastructure, the remote machine need not even +have free disk space or a writeable filesystem. + +It is not intended as a generic RPC framework; the goal is to provide a robust +and efficient low-level API on which tools like Salt, Ansible, or Fabric can be +built, and while the API is quite friendly and comparable to Fabric, ultimately +it is not intended for direct use by consumer software. + +The focus is to centralize and perfect the intricate dance required to run +Python code safely and efficiently on a remote machine, while avoiding +temporary files or large chunks of error-prone shell scripts, and supporting +common privilege escalation techniques like sudo, potentially in combination +with exotic connection methods such as WMI, telnet, or console-over-IPMI.} + + +%if (%{defined fedora} && 0%{?fedora} < 30) || (%{defined rhel} && 0%{?rhel} < 8) +%bcond_without python2 +%endif + +%if %{defined fedora} || (%{defined rhel} && 0%{?rhel} >= 8) +%bcond_without python3 +%endif + + +Name: python-%{pkgname} +Version: 0.2.6 +Release: 1%{?dist} +Summary: Distributed self-replicating programs in Python +License: BSD +URL: https://github.com/dw/mitogen +Source0: %pypi_source +# Mitogen jumps through some hoops for Python 2.4 support. We don't need that in +# Fedora or EPEL. Part of that is bundled compatibility libraries. This patch +# removes the methods that stuff those compat libraries into the PYTHONPATH. You +# should also delete the mitogen/compat and ansible_mitogen/compat directories. +Patch0: remove-compat.patch +BuildArch: noarch + + +%description %{common_description} + + +%if %{with python2} +%package -n python2-%{pkgname} +Summary: %{summary} +BuildRequires: python2-devel +BuildRequires: python2-setuptools +%{?python_provide:%python_provide python2-%{pkgname}} + + +%description -n python2-%{pkgname} %{common_description} +%endif + + +%if %{with python3} +%package -n python%{python3_pkgversion}-%{pkgname} +Summary: %{summary} +BuildRequires: python%{python3_pkgversion}-devel +BuildRequires: python%{python3_pkgversion}-setuptools +%{?python_provide:%python_provide python%{python3_pkgversion}-%{pkgname}} + + +%description -n python%{python3_pkgversion}-%{pkgname} %{common_description} +%endif + + +%prep +%autosetup -n %{srcname}-%{version} -p 1 + +rm -rf %{eggname}.egg-info + +# See patch0 comment above +rm -r mitogen/compat ansible_mitogen/compat + + +%build +%{?with_python2:%py2_build} +%{?with_python3:%py3_build} + + +%install +%{?with_python2:%py2_install} +%{?with_python3:%py3_install} + + +%check +# tests/README.md says the tests need: +# - internet connection +# - working docker daemon + + +%if %{with python2} +%files -n python2-%{pkgname} +%license LICENSE +%doc README.md +%{python2_sitelib}/%{libname} +%{python2_sitelib}/ansible_%{libname} +%{python2_sitelib}/%{eggname}-%{version}-py%{python2_version}.egg-info +%endif + + +%if %{with python3} +%files -n python%{python3_pkgversion}-%{pkgname} +%license LICENSE +%doc README.md +%{python3_sitelib}/%{libname} +%{python3_sitelib}/ansible_%{libname} +%{python3_sitelib}/%{eggname}-%{version}-py%{python3_version}.egg-info +%endif + + +%changelog +* Tue Apr 16 2019 Carl George - 0.2.6-1 +- Latest upstream + +* Thu Feb 14 2019 Carl George - 0.2.5-1 +- Latest upstream + +* Tue Feb 12 2019 Carl George - 0.2.4-1 +- Initial package diff --git a/remove-compat.patch b/remove-compat.patch new file mode 100644 index 0000000..518e19b --- /dev/null +++ b/remove-compat.patch @@ -0,0 +1,122 @@ +Mitogen jumps through some hoops for Python 2.4 support. We don't need that in +Fedora or EPEL. Part of that is bundled compatibility libraries. This patch +removes the methods that stuff those compat libraries into the PYTHONPATH. You +should also delete the mitogen/compat and ansible_mitogen/compat directories. + +diff -Nurp mitogen-0.2.5.orig/ansible_mitogen/process.py mitogen-0.2.5/ansible_mitogen/process.py +--- mitogen-0.2.5.orig/ansible_mitogen/process.py 2019-02-14 08:26:50.682543969 -0600 ++++ mitogen-0.2.5/ansible_mitogen/process.py 2019-02-14 08:43:00.947596131 -0600 +@@ -236,64 +236,6 @@ class MuxProcess(object): + if secs: + mitogen.debug.dump_to_logger(secs=secs) + +- def _setup_simplejson(self, responder): +- """ +- We support serving simplejson for Python 2.4 targets on Ansible 2.3, at +- least so the package's own CI Docker scripts can run without external +- help, however newer versions of simplejson no longer support Python +- 2.4. Therefore override any installed/loaded version with a +- 2.4-compatible version we ship in the compat/ directory. +- """ +- responder.whitelist_prefix('simplejson') +- +- # issue #536: must be at end of sys.path, in case existing newer +- # version is already loaded. +- compat_path = os.path.join(os.path.dirname(__file__), 'compat') +- sys.path.append(compat_path) +- +- for fullname, is_pkg, suffix in ( +- (u'simplejson', True, '__init__.py'), +- (u'simplejson.decoder', False, 'decoder.py'), +- (u'simplejson.encoder', False, 'encoder.py'), +- (u'simplejson.scanner', False, 'scanner.py'), +- ): +- path = os.path.join(compat_path, 'simplejson', suffix) +- fp = open(path, 'rb') +- try: +- source = fp.read() +- finally: +- fp.close() +- +- responder.add_source_override( +- fullname=fullname, +- path=path, +- source=source, +- is_pkg=is_pkg, +- ) +- +- def _setup_responder(self, responder): +- """ +- Configure :class:`mitogen.master.ModuleResponder` to only permit +- certain packages, and to generate custom responses for certain modules. +- """ +- responder.whitelist_prefix('ansible') +- responder.whitelist_prefix('ansible_mitogen') +- self._setup_simplejson(responder) +- +- # Ansible 2.3 is compatible with Python 2.4 targets, however +- # ansible/__init__.py is not. Instead, executor/module_common.py writes +- # out a 2.4-compatible namespace package for unknown reasons. So we +- # copy it here. +- responder.add_source_override( +- fullname='ansible', +- path=ansible.__file__, +- source=(ANSIBLE_PKG_OVERRIDE % ( +- ansible.__version__, +- ansible.__author__, +- )).encode(), +- is_pkg=True, +- ) +- + def _setup_master(self): + """ + Construct a Router, Broker, and mitogen.unix listener +@@ -303,7 +245,6 @@ class MuxProcess(object): + broker=self.broker, + max_message_size=4096 * 1048576, + ) +- self._setup_responder(self.router.responder) + mitogen.core.listen(self.broker, 'shutdown', self.on_broker_shutdown) + mitogen.core.listen(self.broker, 'exit', self.on_broker_exit) + self.listener = mitogen.unix.Listener( +diff -Nurp mitogen-0.2.5.orig/mitogen/core.py mitogen-0.2.5/mitogen/core.py +--- mitogen-0.2.5.orig/mitogen/core.py 2019-02-14 08:26:50.675543919 -0600 ++++ mitogen-0.2.5/mitogen/core.py 2019-02-14 09:16:46.650790432 -0600 +@@ -1080,7 +1080,6 @@ class Importer(object): + # The Mitogen package is handled specially, since the child context must + # construct it manually during startup. + MITOGEN_PKG_CONTENT = [ +- 'compat', + 'debug', + 'doas', + 'docker', +diff -Nurp mitogen-0.2.5.orig/mitogen/master.py mitogen-0.2.5/mitogen/master.py +--- mitogen-0.2.5.orig/mitogen/master.py 2019-02-14 08:26:50.673543905 -0600 ++++ mitogen-0.2.5/mitogen/master.py 2019-02-14 08:51:13.808265622 -0600 +@@ -50,11 +50,6 @@ import threading + import types + import zlib + +-if not hasattr(pkgutil, 'find_loader'): +- # find_loader() was new in >=2.5, but the modern pkgutil.py syntax has +- # been kept intentionally 2.3 compatible so we can reuse it. +- from mitogen.compat import pkgutil +- + import mitogen + import mitogen.core + import mitogen.minify +diff -Nurp mitogen-0.2.5.orig/mitogen/minify.py mitogen-0.2.5/mitogen/minify.py +--- mitogen-0.2.5.orig/mitogen/minify.py 2019-02-14 08:26:50.676543927 -0600 ++++ mitogen-0.2.5/mitogen/minify.py 2019-02-14 08:27:09.436677438 -0600 +@@ -37,10 +37,7 @@ except ImportError: + + import mitogen.core + +-if sys.version_info < (2, 7, 11): +- from mitogen.compat import tokenize +-else: +- import tokenize ++import tokenize + + + def minimize_source(source): diff --git a/sources b/sources new file mode 100644 index 0000000..a050e00 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (mitogen-0.2.6.tar.gz) = cddf59d364edf00d857b0e97d38b3d1837111735910e7678df1196479970db421e4ab62396c8a64dbf360fdf01d62ba88d56da57430848f06ee906d4b526a0e0