Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
周伟奇
/
encryption_script
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
a75f6d66
authored
2022-10-25 17:07:27 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix windows error
1 parent
97b2d3ed
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
py2so.py
py2so.py
View file @
a75f6d6
...
...
@@ -7,11 +7,13 @@ from distutils.core import setup
from
distutils.extension
import
Extension
from
Cython.Build
import
cythonize
from
Cython.Distutils
import
build_ext
import
platform
if
sys
.
version_info
[
0
]
<
3
:
raise
Exception
(
"This program requires at least python3.6"
)
is_windows
=
platform
.
system
()
==
'Windows'
parser
=
argparse
.
ArgumentParser
(
description
=
'compile the .py to .so(Linux/Mac) or .pdy(Win)'
)
parser
.
add_argument
(
'-i'
,
'--input'
,
help
=
'the directory(file) path of your project'
,
required
=
True
)
...
...
@@ -20,6 +22,18 @@ parser.add_argument('-e', '--exclude', help='exclude file. eg: ignore/ignore.py,
args
=
parser
.
parse_args
()
def
get_export_symbols_fixed
(
self
,
ext
):
names
=
ext
.
name
.
split
(
'.'
)
if
names
[
-
1
]
!=
"__init__"
:
initfunc_name
=
"PyInit_"
+
names
[
-
1
]
else
:
# take name of the package if it is an __init__-file
initfunc_name
=
"PyInit_"
+
names
[
-
2
]
if
initfunc_name
not
in
ext
.
export_symbols
:
ext
.
export_symbols
.
append
(
initfunc_name
)
return
ext
.
export_symbols
def
get_exclude_paths
(
input_path
):
exclude_paths
=
[]
if
args
.
exclude
is
not
None
and
os
.
path
.
isdir
(
input_path
):
...
...
@@ -140,6 +154,10 @@ def main():
print
(
'---------- compile start ----------'
)
success
=
False
try
:
if
is_windows
:
# replace wrong version with the fixed:
build_ext
.
get_export_symbols
=
get_export_symbols_fixed
compiler_directives
=
{
"language_level"
:
'3'
}
ext_modules
=
cythonize
(
module_list
=
extensions
,
compiler_directives
=
compiler_directives
)
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment