Add a Rust project.

This commit is contained in:
Emmanuel Gil Peyrot 2018-10-17 05:12:21 +02:00 committed by Maxime “pep” Buquet
parent c0d5d7ab0d
commit f8b4ef7698
6 changed files with 65 additions and 33 deletions

View file

@ -38,57 +38,46 @@ security-check:
- pip3 install safety
- safety check -r requirements.txt
pytest-3.7:
stage: test
image: python:3.7
.poezio-tests:
script:
- apt-get update && apt-get install -y libidn11-dev
- wget https://static.rust-lang.org/rustup/archive/1.24.3/x86_64-unknown-linux-gnu/rustup-init
- chmod +x rustup-init
- ./rustup-init -y --no-modify-path --default-toolchain nightly
- rm rustup-init
- ls ~/.cargo/bin
- export PATH=$PATH:$HOME/.cargo/bin
- git clone https://lab.louiz.org/poezio/slixmpp.git
- pip3 install pytest pyasn1-modules cffi --upgrade
- pip3 install pytest pyasn1-modules cffi setuptools-rust --upgrade
- cd slixmpp
- python3 setup.py install
- cd ..
- python3 setup.py install
- py.test -v test/
pytest-3.7:
stage: test
image: python:3.7
extends:
- .poezio-tests
pytest-3.8:
stage: test
image: python:3.8
script:
- apt-get update && apt-get install -y libidn11-dev
- git clone https://lab.louiz.org/poezio/slixmpp.git
- pip3 install pytest pyasn1-modules cffi --upgrade
- cd slixmpp
- python3 setup.py install
- cd ..
- python3 setup.py install
- py.test -v test/
extends:
- .poezio-tests
pytest-3.9:
stage: test
image: python:3.9
script:
- apt-get update && apt-get install -y libidn11-dev
- git clone https://lab.louiz.org/poezio/slixmpp.git
- pip3 install pytest pyasn1-modules cffi --upgrade
- cd slixmpp
- python3 setup.py install
- cd ..
- python3 setup.py install
- py.test -v test/
extends:
- .poezio-tests
pytest-3.10:
stage: test
image: python:3.10-rc
script:
- apt-get update && apt-get install -y libidn11-dev
- git clone https://lab.louiz.org/poezio/slixmpp.git
- pip3 install pytest pyasn1-modules cffi --upgrade
- cd slixmpp
- python3 setup.py install
- cd ..
- python3 setup.py install
- py.test -v test/
extends:
- .poezio-tests
pylint-plugins:
stage: lint
@ -96,7 +85,13 @@ pylint-plugins:
allow_failure: true
script:
- apt-get update && apt-get install -y libidn11-dev
- pip3 install pylint pyasn1-modules cffi --upgrade
- wget https://static.rust-lang.org/rustup/archive/1.14.0/x86_64-unknown-linux-gnu/rustup-init
- chmod +x rustup-init
- ./rustup-init -y --no-modify-path --default-toolchain nightly
- rm rustup-init
- ls ~/.cargo/bin
- export PATH=$PATH:$HOME/.cargo/bin
- pip3 install pylint pyasn1-modules cffi setuptools-rust --upgrade
- pip3 install -e git+https://lab.louiz.org/poezio/slixmpp.git#egg=slixmpp
- pip3 install -r requirements-plugins.txt
- python3 setup.py install

13
Cargo.toml Normal file
View file

@ -0,0 +1,13 @@
[package]
name = "poezio"
version = "0.1.0"
authors = [
"Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>",
"Maxime “pep” Buquet <pep@bouah.net>",
]
[dependencies]
cpython = "0.7"
[lib]
crate-type = ["cdylib"]

View file

@ -1,5 +1,7 @@
recursive-include doc/source *
recursive-include tools
recursive-include src *
include Cargo.toml
include data/poezio.1
include data/io.poez.Poezio.appdata.xml
include data/io.poez.Poezio.desktop

View file

@ -5,3 +5,4 @@ pycares==2.3.0
pyasn1==0.4.2
pyasn1-modules==0.2.1
typing_extensions
setuptools-rust==1.1.2

View file

@ -10,6 +10,12 @@ except ImportError:
print('\nSetuptools was not found. Install setuptools for python 3.\n')
sys.exit(1)
try:
from setuptools_rust import Binding, RustExtension
except ImportError:
print('\nsetuptools-rust was not found. Install setuptools-rust for python 3.\n')
sys.exit(1)
cmdclass = {}
try:
from sphinx.setup_command import BuildDoc
@ -124,6 +130,7 @@ setup(
description="A console XMPP client",
long_description=LONG_DESCRIPTION,
ext_modules=[module_poopt],
rust_extensions=[RustExtension('poezio.libpoezio', binding=Binding.RustCPython)],
url='https://poez.io/',
license='GPL-3.0-or-later',
download_url='https://dev.louiz.org/projects/poezio/files',
@ -165,7 +172,15 @@ setup(
+ find_doc('share/doc/poezio/html', 'build/html')
+ sphinx_files_found
),
install_requires=['slixmpp>=1.6.0', 'aiodns', 'pyasn1_modules', 'pyasn1', 'typing_extensions', 'setuptools'],
install_requires=[
'slixmpp>=1.8.2',
'aiodns',
'pyasn1_modules',
'pyasn1',
'typing_extensions',
'setuptools',
'setuptools-rust',
],
extras_require={'OTR plugin': 'python-potr>=1.0',
'Screen autoaway plugin': 'pyinotify==0.9.4',
'Avoiding cython': 'cffi'},

6
src/lib.rs Normal file
View file

@ -0,0 +1,6 @@
#[macro_use]
extern crate cpython;
py_module_initializer!(libpoezio, initlibpoezio, PyInit_libpoezio, |py, m| {
Ok(())
});