Compare commits
40 Commits
master
...
Release_2.
Author | SHA1 | Date |
---|---|---|
![]() |
339aa93922 | 3 years ago |
![]() |
3f15e1c174 | 3 years ago |
![]() |
1adb9c1894 | 3 years ago |
![]() |
f5cdaf1a1d | 3 years ago |
![]() |
389a812d3d | 3 years ago |
![]() |
23e1e6ac98 | 3 years ago |
![]() |
e4ef9b2bc4 | 3 years ago |
![]() |
69bda89fa2 | 3 years ago |
![]() |
268a4c5d26 | 3 years ago |
![]() |
d1a8e6e413 | 3 years ago |
![]() |
8e0644ceef | 3 years ago |
![]() |
e2040fdc66 | 3 years ago |
![]() |
06e4e23ece | 3 years ago |
![]() |
d4bf4c0181 | 4 years ago |
![]() |
49a6758e77 | 4 years ago |
![]() |
731a78ba61 | 4 years ago |
![]() |
d2899c9f7f | 4 years ago |
![]() |
cd6243079c | 4 years ago |
![]() |
44db8b7510 | 4 years ago |
![]() |
7d2fff8083 | 4 years ago |
![]() |
e4482be063 | 4 years ago |
![]() |
7a8bf38984 | 4 years ago |
![]() |
597e5749ab | 4 years ago |
![]() |
41a0f49281 | 4 years ago |
![]() |
6a715e199d | 4 years ago |
![]() |
f5d83b7454 | 4 years ago |
![]() |
d6568b0075 | 4 years ago |
![]() |
312c6d9b92 | 4 years ago |
![]() |
3c75e518fc | 4 years ago |
![]() |
50a09206cd | 4 years ago |
![]() |
194f18b04f | 4 years ago |
![]() |
bc645f5da2 | 4 years ago |
![]() |
d8172a43aa | 4 years ago |
![]() |
71cbbbdc5f | 4 years ago |
![]() |
0a8527c094 | 4 years ago |
![]() |
2fbef542e0 | 4 years ago |
![]() |
e04c8ed1d3 | 4 years ago |
![]() |
6212687b62 | 4 years ago |
![]() |
7b02820e5c | 4 years ago |
![]() |
010060f2ea | 4 years ago |
16 changed files with 293 additions and 89 deletions
@ -1,6 +1,5 @@ |
|||||
# 1st Party Dependencies |
# 1st Party Dependencies |
||||
## Prefer git tags instead of SHA hashes when possible. |
## Prefer git tags instead of SHA hashes when possible. |
||||
|
|
||||
libpEpAdapter=Release_2.1.17 |
libpEpAdapter=Release_2.1.22 |
||||
pEpEngine=Release_2.1.23 |
pEpEngine=Release_2.1.62 |
||||
sequoia=365d00a08bec6a5a48d48a7c7893d78c27092b59 |
|
||||
|
@ -0,0 +1,146 @@ |
|||||
|
import os |
||||
|
import re |
||||
|
import sys |
||||
|
import subprocess |
||||
|
import winreg |
||||
|
import zipfile as zf |
||||
|
from os.path import dirname |
||||
|
from os.path import join |
||||
|
|
||||
|
def get_bindependencies(lib, debug=False): |
||||
|
"""Gets the pEp dependencies of a library""" |
||||
|
|
||||
|
python_location = sys.exec_prefix |
||||
|
bindepend = join(python_location, 'Scripts', 'pyi-bindepend.exe') |
||||
|
output = subprocess.run([bindepend, lib], capture_output=True) |
||||
|
if os.path.isfile(lib): |
||||
|
yield lib |
||||
|
if len(output.stdout) > 0: |
||||
|
deps = parse_bindepend_output(output.stdout) |
||||
|
for dep in add_full_paths(deps, debug): |
||||
|
for d in get_bindependencies(dep): |
||||
|
yield d |
||||
|
|
||||
|
|
||||
|
def parse_bindepend_output(stdout): |
||||
|
"""Parses the output of pyi-bindepent and returns a list of file names""" |
||||
|
|
||||
|
deps = [] |
||||
|
if stdout == None: |
||||
|
return None |
||||
|
p = re.compile('(.*){(.*)}(.*)') |
||||
|
str_val = bytes.decode(stdout) |
||||
|
raw_val = p.findall(str_val) |
||||
|
if len(raw_val) == 0: |
||||
|
return deps |
||||
|
else: |
||||
|
libs = raw_val[0][1].replace(' ', '').split(',') |
||||
|
for lib in libs: |
||||
|
lib = lib.strip("'") |
||||
|
if not 'api' in lib: |
||||
|
deps.append(lib) |
||||
|
return deps |
||||
|
|
||||
|
|
||||
|
def get_pEp_install_location(debug=False): |
||||
|
"""Gets the location where pEp is installed""" |
||||
|
|
||||
|
reg_path = "SOFTWARE\\Classes\\TypeLib\\{564A4350-419E-47F1-B0DF-6FCCF0CD0BBC}\\1.0\\0\\win32" |
||||
|
KeyName = None |
||||
|
regKey = None |
||||
|
try: |
||||
|
regKey = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, reg_path, 0, winreg.KEY_READ) |
||||
|
# Keys: Description, FileName, FriendlyName, LoadBehavior |
||||
|
com_server, _ = winreg.QueryValueEx(regKey, KeyName) |
||||
|
except WindowsError as error: |
||||
|
print('Error getting install location: ' + error) |
||||
|
com_server = None |
||||
|
finally: |
||||
|
if winreg: |
||||
|
winreg.CloseKey(regKey) |
||||
|
location = os.path.dirname(com_server) |
||||
|
if debug: |
||||
|
location = location.strip('Release') + 'Debug' |
||||
|
return location |
||||
|
|
||||
|
|
||||
|
def get_boost_directories(): |
||||
|
"""Gets the location of the boost libraries""" |
||||
|
|
||||
|
for dir in [f.path for f in os.scandir(join(dirname(os.getcwd()), 'packages')) if f.is_dir()]: |
||||
|
if 'boost.' in dir or 'boost_python' in dir or 'boost_locale' in dir: |
||||
|
yield join(dir, 'lib', 'native') |
||||
|
|
||||
|
|
||||
|
def add_full_paths(libs, debug=False): |
||||
|
"""Combines a list of libraries with a set of common directories. Returns a list of file names that exist on this machine""" |
||||
|
|
||||
|
paths = [get_pEp_install_location(debug)] + [dir for dir in get_boost_directories()] + [p for p in os.environ['PATH'].split(';')] |
||||
|
paths = [p for p in paths if not "system32" in p.lower()] |
||||
|
full_paths = [] |
||||
|
for lib in libs: |
||||
|
for p in paths: |
||||
|
test_path = join(p, lib) |
||||
|
if os.path.isfile(test_path) and not test_path.casefold() in (f.casefold for f in full_paths): |
||||
|
full_paths.append(test_path) |
||||
|
return full_paths |
||||
|
|
||||
|
|
||||
|
def main(): |
||||
|
|
||||
|
args = sys.argv |
||||
|
cwd = dirname(args[0]) |
||||
|
del args[0] |
||||
|
|
||||
|
# Check for debug build |
||||
|
debug = False |
||||
|
if len(args) > 0 and args[0] == '--debug': |
||||
|
debug = True |
||||
|
del args[0] |
||||
|
|
||||
|
# Get the pEp wheel and extract the pEp Python library |
||||
|
dist_path = join(dirname(cwd), 'dist') |
||||
|
print('Dist path is: ' + dist_path) |
||||
|
pEp_python_library = None |
||||
|
if os.path.exists(dist_path): |
||||
|
for _, _, files in os.walk(dist_path): |
||||
|
for f in files: |
||||
|
if f[:3] == 'pEp' and f[-3:] == 'whl': |
||||
|
wheel_name = join(dist_path, f) |
||||
|
with zf.ZipFile(wheel_name, 'a') as wheel: |
||||
|
for archive_member in wheel.namelist(): |
||||
|
if '_pEp' in archive_member and archive_member[-3:] == 'pyd': |
||||
|
wheel.extract(archive_member, path=dist_path) |
||||
|
pEp_python_library = join(dist_path, archive_member) |
||||
|
print('pEp Python library found and extracted to ' + pEp_python_library) |
||||
|
break |
||||
|
break |
||||
|
|
||||
|
# Get all dependencies for the pEp Python library |
||||
|
if pEp_python_library == None: |
||||
|
raise FileNotFoundError('pEp Python library not found in ' + dist_path) |
||||
|
pEp_python_library = pEp_python_library.replace('/', '\\') |
||||
|
libs = [] |
||||
|
for lib in get_bindependencies(pEp_python_library, debug): |
||||
|
if not lib.casefold() in (l.casefold for l in libs) and lib.casefold() != pEp_python_library.casefold(): |
||||
|
print('Dependency found: ' + lib) |
||||
|
libs.append(lib) |
||||
|
|
||||
|
# Copy dependencies into the wheel |
||||
|
with zf.ZipFile(wheel_name, 'a') as wheel: |
||||
|
for lib in libs: |
||||
|
filename = os.path.basename(lib) |
||||
|
arcname = 'pEp/' + filename |
||||
|
if not arcname in wheel.namelist(): |
||||
|
wheel.write(filename=lib, arcname=arcname, compress_type=zf.ZIP_DEFLATED) |
||||
|
|
||||
|
# Delete the temporarily extracted pEp Python library |
||||
|
if os.path.isfile(pEp_python_library): |
||||
|
os.remove(pEp_python_library) |
||||
|
dir = os.path.dirname(pEp_python_library) |
||||
|
if dir[-3:].lower() == 'pep' and os.path.isdir(dir): |
||||
|
os.rmdir(dir) |
||||
|
|
||||
|
|
||||
|
if __name__ == '__main__': |
||||
|
main() |
@ -1,31 +0,0 @@ |
|||||
|
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00 |
|
||||
# Visual Studio Version 16 |
|
||||
VisualStudioVersion = 16.0.31005.135 |
|
||||
MinimumVisualStudioVersion = 10.0.40219.1 |
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pEpPythonAdapter", "pEpPythonAdapter.vcxproj", "{F7D4314B-C7BA-4117-9AE7-AC5C1492153D}" |
|
||||
EndProject |
|
||||
Global |
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
|
||||
Debug|x64 = Debug|x64 |
|
||||
Debug|x86 = Debug|x86 |
|
||||
Release|x64 = Release|x64 |
|
||||
Release|x86 = Release|x86 |
|
||||
EndGlobalSection |
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
|
||||
{F7D4314B-C7BA-4117-9AE7-AC5C1492153D}.Debug|x64.ActiveCfg = Debug|x64 |
|
||||
{F7D4314B-C7BA-4117-9AE7-AC5C1492153D}.Debug|x64.Build.0 = Debug|x64 |
|
||||
{F7D4314B-C7BA-4117-9AE7-AC5C1492153D}.Debug|x86.ActiveCfg = Debug|Win32 |
|
||||
{F7D4314B-C7BA-4117-9AE7-AC5C1492153D}.Debug|x86.Build.0 = Debug|Win32 |
|
||||
{F7D4314B-C7BA-4117-9AE7-AC5C1492153D}.Release|x64.ActiveCfg = Release|x64 |
|
||||
{F7D4314B-C7BA-4117-9AE7-AC5C1492153D}.Release|x64.Build.0 = Release|x64 |
|
||||
{F7D4314B-C7BA-4117-9AE7-AC5C1492153D}.Release|x86.ActiveCfg = Release|Win32 |
|
||||
{F7D4314B-C7BA-4117-9AE7-AC5C1492153D}.Release|x86.Build.0 = Release|Win32 |
|
||||
EndGlobalSection |
|
||||
GlobalSection(SolutionProperties) = preSolution |
|
||||
HideSolutionNode = FALSE |
|
||||
EndGlobalSection |
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution |
|
||||
SolutionGuid = {B63BC9BA-EF76-4FB4-9126-29CBFAD9092C} |
|
||||
EndGlobalSection |
|
||||
EndGlobal |
|
@ -1,19 +0,0 @@ |
|||||
|
|
||||
[build-system] |
|
||||
# Preparing for PEP-517/PEP-518, but not in effect yet. |
|
||||
# These requires are not effective yet, setup.cfg is. |
|
||||
requires =[ |
|
||||
"setuptools >=39.2.0", |
|
||||
"setuptools_scm >= 4.1.2", |
|
||||
"wheel", |
|
||||
] |
|
||||
|
|
||||
build-backend = "setuptools.build_meta" |
|
||||
|
|
||||
[tool.pytest.ini_options] |
|
||||
minversion = "6.0" |
|
||||
addopts = "-rP --forked" |
|
||||
testpaths = [ |
|
||||
"tests", |
|
||||
] |
|
||||
|
|
@ -0,0 +1,35 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# This file is under GNU Affero General Public License 3.0 |
||||
|
# see LICENSE.txt |
||||
|
|
||||
|
"""Blob unit tests.""" |
||||
|
|
||||
|
import pytest |
||||
|
|
||||
|
from . import constants |
||||
|
from . import model |
||||
|
|
||||
|
def test_blob_data_constructor(pEp): |
||||
|
bdata = b'this is binary \x00\x01\xbb\xa7\xa4\xab test data' |
||||
|
b = pEp.Blob(bdata) |
||||
|
assert b.data == bdata |
||||
|
assert not b.mime_type |
||||
|
assert not b.filename |
||||
|
|
||||
|
|
||||
|
def test_blob_data_property(pEp): |
||||
|
bdata = b'this is binary \x00\x01\xbb\xa7\xa4\xab test data' |
||||
|
b = pEp.Blob(b'dummy') |
||||
|
b.data = bdata |
||||
|
assert b.data == bdata |
||||
|
assert not b.mime_type |
||||
|
assert not b.filename |
||||
|
|
||||
|
|
||||
|
def test_blob_data_property_keeps_other_fields(pEp): |
||||
|
bdata = b'this is binary \x00\x01\xbb\xa7\xa4\xab test data' |
||||
|
b = pEp.Blob(b'dummy', 'application/x-mydata', 'myfile.dat') |
||||
|
b.data = bdata |
||||
|
assert b.data == bdata |
||||
|
assert b.mime_type == 'application/x-mydata' |
||||
|
assert b.filename == 'myfile.dat' |
Loading…
Reference in new issue