-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py.in
105 lines (93 loc) · 3.4 KB
/
setup.py.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# Load dll libraries directly from memory
# -*- coding: utf-8 -*-
###################################################
#........../\./\...___......|\.|..../...\.........#
#........./..|..\/\.|.|_|._.|.\|....|.c.|.........#
#......../....../--\|.|.|.|i|..|....\.../.........#
# Mathtin (c) #
###################################################
# Author: Daniel [Mathtin] Shiko #
# Copyright (c) 2019 <[email protected]> #
# This file is released under the MPL license. #
###################################################
__author__ = "Mathtin"
__date__ = "$07.02.2019 00:00:00$"
"""
* Python library for Memory DLL loading
*
* Copyright (c) 2019 by Daniel [Mathtin] Shiko / [email protected]
* https://mathtin.ru
*
* The contents of this file are subject to the Mozilla Public License Version
* 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Initial Developer of the Original Code is Daniel [Mathtin] Shiko.
*
* Portions created by Daniel [Mathtin] Shiko are Copyright (C) 2019
* Daniel [Mathtin] Shiko. All Rights Reserved.
"""
from setuptools import setup, Extension
import distutils.util
from os import name as OS, path
from platform import architecture
from sys import executable as PYEXEPATH
from glob import glob as ls
if OS != "nt":
raise Exception('Only NT OS is supported')
ARCH = architecture()[0]
#if distutils.util.get_platform() == 'mingw':
# if ARCH == '64bit':
# distutils.util.get_platform = lambda: 'mingw64'
# elif ARCH == '32bit':
# distutils.util.get_platform = lambda: 'mingw32'
if ARCH == '64bit':
if path.join('mingw64', 'bin') in PYEXEPATH:
ENV = 'mingw64'
else:
ENV = 'win64'
ARCH_SUFFIX = 'x86_64'
elif ARCH == '32bit':
if path.join('mingw32', 'bin') in PYEXEPATH:
ENV = 'mingw32'
else:
ENV = 'win32'
ARCH_SUFFIX = 'win32'
else:
raise Exception('Unsupported architecture')
CXXINCS = ''
if 'mingw' in ENV:
CFLAGS = ['-std=c11', '-Wall']
CXXFLAGS = ['-std=c++17', '-Wall']
else:
CFLAGS = []
CXXFLAGS = []
CFLAGS.append('-DPy_DBUG=0')
def lookup(path_, ext):
res = []
for e in ext:
res += ls(path.join(path_, e))
return res
_memmod = Extension('memmod._memmod',
sources = lookup('src/memmod/_memmod', ['*.c']),
extra_compile_args=CFLAGS)
setup(name = 'memmod',
version = %MEMMOD_VER%,
description = 'loads dll directly from memory',
long_description = 'Python library used to load dll libraries directly from memory',
author='Daniel Shiko',
author_email='[email protected]',
url='https://github.com/Mathtin/memmod/',
license='MPL',
platforms = ['nt'],
packages=['memmod', 'memmod.tests'],
package_dir={'memmod' : 'src/memmod', 'memmod.tests': 'tests'},
package_data={'memmod.tests': ['StrQueue-%s.dll' % ARCH_SUFFIX]},
ext_modules=[_memmod],
test_suite='tests.test_suite')