Skip to content

Commit 3459337

Browse files
author
Simon
committed
first commit
0 parents  commit 3459337

33 files changed

+1843
-0
lines changed

.gitignore

+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# Distribution / packaging
7+
.Python
8+
build/
9+
develop-eggs/
10+
dist/
11+
downloads/
12+
eggs/
13+
.eggs/
14+
lib/
15+
lib64/
16+
parts/
17+
sdist/
18+
var/
19+
wheels/
20+
pip-wheel-metadata/
21+
share/python-wheels/
22+
*.egg-info/
23+
.installed.cfg
24+
*.egg
25+
MANIFEST
26+
27+
# PyInstaller
28+
# Usually these files are written by a python script from a template
29+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
30+
*.manifest
31+
*.spec
32+
33+
# Installer logs
34+
pip-log.txt
35+
pip-delete-this-directory.txt
36+
37+
# Unit test / coverage reports
38+
htmlcov/
39+
.tox/
40+
.nox/
41+
.coverage
42+
.coverage.*
43+
.cache
44+
nosetests.xml
45+
coverage.xml
46+
*.cover
47+
.hypothesis/
48+
.pytest_cache/
49+
50+
# Translations
51+
*.mo
52+
*.pot
53+
54+
# Django stuff:
55+
*.log
56+
local_settings.py
57+
db.sqlite3
58+
59+
# Flask stuff:
60+
instance/
61+
.webassets-cache
62+
63+
# Scrapy stuff:
64+
.scrapy
65+
66+
# Sphinx documentation
67+
docs/_build/
68+
69+
# PyBuilder
70+
target/
71+
72+
# Jupyter Notebook
73+
.ipynb_checkpoints
74+
75+
# IPython
76+
profile_default/
77+
ipython_config.py
78+
79+
# pyenv
80+
.python-version
81+
82+
# pipenv
83+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
84+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
85+
# having no cross-platform support, pipenv may install dependencies that don’t work, or not
86+
# install all needed dependencies.
87+
#Pipfile.lock
88+
89+
# celery beat schedule file
90+
celerybeat-schedule
91+
92+
# SageMath parsed files
93+
*.sage.py
94+
95+
# Environments
96+
.env
97+
.venv
98+
env/
99+
venv/
100+
ENV/
101+
env.bak/
102+
venv.bak/
103+
104+
# mkdocs documentation
105+
/site
106+
107+
# mypy
108+
.mypy_cache/
109+
.dmypy.json
110+
dmypy.json
111+
112+
# Pyre type checker
113+
.pyre/
114+
115+
# Pycharm
116+
.idea

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2019 Parkoview SA
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9+
of the Software, and to permit persons to whom the Software is furnished to do
10+
so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
recursive-include src/_wheel2deb/templates *

Makefile

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
MAKE := $(MAKE) --no-print-directory
2+
SHELL = bash
3+
4+
default:
5+
@echo "Makefile for wheel2deb"
6+
@echo
7+
@echo 'Usage:'
8+
@echo
9+
@echo ' make check check coding style (PEP-8, PEP-257)'
10+
@echo ' make bdist build python wheel'
11+
@echo ' make images build docker images'
12+
@echo ' make clean cleanup all temporary files'
13+
@echo
14+
15+
bdist:
16+
@python3 setup.py bdist_wheel
17+
18+
images: bdist
19+
@cp docker/dh-autoreconf_* dist/
20+
$(call build_image,debian:jessie-slim,jessie)
21+
$(call build_image,debian:stretch-slim,stretch)
22+
$(call build_image,debian:buster-slim,buster)
23+
24+
check:
25+
@flake8 src
26+
27+
clean:
28+
@rm -Rf src/*.egg-info .cache .coverage .tox build dist docs/build htmlcov
29+
@find -depth -type d -name __pycache__ -exec rm -Rf {} \;
30+
@find -type f -name '*.pyc' -delete
31+
32+
.PHONY: default bdist images clean
33+
34+
define build_image
35+
cat docker/Dockerfile.in | sed s/_IMAGE_/$(1)/ | docker build -f - -t wheel2deb:$(2) dist
36+
endef

README.md

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[![asciicast](https://asciinema.org/a/249779.svg)](https://asciinema.org/a/249779)
2+
3+
## Quick Example
4+
5+
```
6+
# Download (and build if needed) pytest, numpy and their requirements
7+
pip3 wheel pytest numpy
8+
# Convert all wheels to debian source packages
9+
wheel2deb --map attrs=attr
10+
# Call dpkg-buildpackages for each source package
11+
wheel2deb build
12+
ls -l output/*.deb
13+
# Install generated packages
14+
dpkg -i output/*.deb
15+
# Run pytest on numpy
16+
python3 -c "import numpy; numpy.test()"
17+
```
18+
19+
## Features
20+
21+
- TODO
22+
23+
## Bugs/Requests
24+
25+
Please use the [GitHub issue tracker](<https://github.com/parkoview/wheel2deb/issues>) to submit bugs or request features.
26+
27+
## License
28+
29+
Copyright Parkoview SA 2019.
30+
31+
Distributed under the terms of the [MIT](https://github.com/parkoview/wheel2deb/blob/master/LICENSE) license, pytest is free and open source software.
32+

docker/Dockerfile.in

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
FROM _IMAGE_
2+
LABEL maintainer="[email protected]"
3+
4+
ENV LC_ALL=C.UTF-8
5+
ENV LANG=C.UTF-8
6+
7+
COPY dh-autoreconf* /
8+
RUN dpkg -i dh-autoreconf* && rm dh-autoreconf*
9+
10+
RUN dpkg --add-architecture armhf \
11+
&& (apt-get -yq update || true) \
12+
&& apt-get -yq --no-install-suggests --no-install-recommends install \
13+
debhelper \
14+
python3-minimal \
15+
devscripts \
16+
fakeroot \
17+
libc6:armhf \
18+
lintian \
19+
apt-file \
20+
binutils-arm-linux-gnueabihf \
21+
python3-apt \
22+
curl \
23+
&& (python3 -c "import distutils.util" || apt-get install -yq python3-distutils) \
24+
&& apt-get clean
25+
26+
RUN apt-file update
27+
28+
RUN curl -k https://bootstrap.pypa.io/get-pip.py > /tmp/get-pip.py \
29+
&& chmod +x /tmp/get-pip.py \
30+
&& python3 /tmp/get-pip.py \
31+
&& rm /tmp/get-pip.py
32+
33+
COPY ./wheel2deb*.whl /
34+
35+
RUN pip3 install $(find ./ -name wheel2deb*.whl) \
36+
&& rm /wheel2deb*
37+
38+
VOLUME /data
39+
WORKDIR /data
40+
41+
ENTRYPOINT ["wheel2deb"]

docker/dh-autoreconf

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Dummy dh-autoreconf package made with equivs to avoid ~90MB of dependencies
2+
# debhelper depends on dh-autoreconf but we don't actually need it
3+
Section: devel
4+
Priority: optional
5+
Standards-Version: 3.9.2
6+
Package: dh-autoreconf
7+
Version: 14

docker/dh-autoreconf_14_all.deb

2.35 KB
Binary file not shown.

setup.cfg

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[metadata]
2+
name = wheel2deb
3+
description = wheel2deb: python wheel to debian package converter
4+
long_description = file: README.md
5+
long-description-content-type = text/markdown
6+
url = https://github.com/parkoview/wheel2deb/
7+
project_urls =
8+
Source=https://github.com/parkoview/wheel2deb
9+
Tracker=https://github.com/parkoview/wheel2deb/issues
10+
author = Simon Guigui
11+
license = MIT license
12+
license_file = LICENSE
13+
keywords = debian, package, converter
14+
classifiers =
15+
Development Status :: 6 - Mature
16+
Intended Audience :: Developers
17+
License :: OSI Approved :: MIT License
18+
Topic :: Utilities
19+
Programming Language :: Python :: 3
20+
Programming Language :: Python :: 3.4
21+
Programming Language :: Python :: 3.5
22+
Programming Language :: Python :: 3.6
23+
Programming Language :: Python :: 3.7
24+
platforms = linux
25+
26+
[options]
27+
zip_safe = no
28+
packages = _wheel2deb
29+
py_modules = wheel2deb
30+
python_requires = !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
31+
32+
[options.entry_points]
33+
console_scripts =
34+
wheel2deb=wheel2deb:main
35+
36+
[check-manifest]
37+
ignore = _wheel2deb/version.py

setup.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from setuptools import setup
2+
3+
with open('src/_wheel2deb/version.py') as f:
4+
exec(f.read())
5+
6+
INSTALL_REQUIRES = [
7+
'setuptools',
8+
'wheel',
9+
'pkginfo',
10+
'jinja2',
11+
'colorama',
12+
'attrs>=17',
13+
'packaging',
14+
'pyyaml'
15+
]
16+
17+
setup(setup_requires=['setuptools>=38.6.0'],
18+
package_dir={'': 'src'},
19+
install_requires=INSTALL_REQUIRES,
20+
include_package_data=True,
21+
version=__version__)

src/_wheel2deb/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import os
2+
3+
TEMPLATE_PATH = os.path.dirname(__file__) + '/templates/'

src/_wheel2deb/apt.py

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import attr
2+
import apt
3+
import re
4+
from . import logger as logging
5+
6+
# https://www.debian.org/doc/debian-policy/ch-controlfields.html#version
7+
PACKAGE_VER_RE = re0 = re.compile(
8+
r'^(?:(?P<epoch>\d+):)?'
9+
r'(?P<version>(?:[\w\.~\-]+(?=-(?P<revision>[^-]+$)))|[\w\.~\-]+)')
10+
11+
logger = logging.getLogger(__name__)
12+
13+
_cache = None
14+
15+
16+
@attr.s(frozen=True)
17+
class Package:
18+
# package name
19+
name = attr.ib(type=str)
20+
# upstream version
21+
version = attr.ib(type=str)
22+
# debian revision
23+
revision = attr.ib(type=str)
24+
epoch = attr.ib(type=str)
25+
26+
@classmethod
27+
def factory(cls, name, pkg_version):
28+
g = PACKAGE_VER_RE.match(pkg_version).groupdict()
29+
return cls(name, **g)
30+
31+
def __str__(self):
32+
# show only package name and upstream version
33+
return '{}=={}'.format(self.name, self.version)
34+
35+
36+
def search_packages(names):
37+
if not names:
38+
return
39+
40+
global _cache
41+
if not _cache:
42+
_cache = apt.Cache()
43+
_cache.open()
44+
45+
logger.debug('searching %s in apt cache...', ' '.join(names))
46+
47+
for name in names:
48+
if name in _cache:
49+
yield Package.factory(name, _cache[name].versions[0].version)
50+
else:
51+
yield None

0 commit comments

Comments
 (0)