Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
MMCV
Commits
9ba29737
Commit
9ba29737
authored
Apr 26, 2023
by
xiabo
Browse files
适配版本号
parent
1db3967e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
setup.py
setup.py
+30
-0
No files found.
setup.py
View file @
9ba29737
...
...
@@ -4,6 +4,9 @@ import platform
import
re
from
pkg_resources
import
DistributionNotFound
,
get_distribution
,
parse_version
from
setuptools
import
find_packages
,
setup
import
subprocess
from
typing
import
Optional
,
Union
from
pathlib
import
Path
EXT_TYPE
=
''
try
:
...
...
@@ -35,8 +38,32 @@ def choose_requirement(primary, secondary):
return
str
(
primary
)
def
get_sha
(
pytorch_root
:
Union
[
str
,
Path
])
->
str
:
try
:
return
subprocess
.
check_output
([
'git'
,
'rev-parse'
,
'HEAD'
],
cwd
=
pytorch_root
).
decode
(
'ascii'
).
strip
()
except
Exception
:
return
'Unknown'
def
get_version_add
(
sha
:
Optional
[
str
]
=
None
)
->
str
:
mmcv_root
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
add_version_path
=
os
.
path
.
join
(
os
.
path
.
join
(
mmcv_root
,
"mmcv"
),
"version.py"
)
if
sha
!=
'Unknown'
:
if
sha
is
None
:
sha
=
get_sha
(
mmcv_root
)
version
=
'git'
+
sha
[:
7
]
if
os
.
getenv
(
'MMCV_BUILD_VERSION'
):
version_dtk
=
os
.
getenv
(
'MMCV_BUILD_VERSION'
,
""
)
version
+=
"."
+
version_dtk
with
open
(
add_version_path
,
encoding
=
"utf-8"
,
mode
=
"a"
)
as
file
:
file
.
write
(
"__version__=__version__+'+{}'
\n
"
.
format
(
version
))
file
.
close
()
def
get_version
():
get_version_add
()
version_file
=
'mmcv/version.py'
with
open
(
version_file
,
encoding
=
'utf-8'
)
as
f
:
exec
(
compile
(
f
.
read
(),
version_file
,
'exec'
))
...
...
@@ -223,6 +250,9 @@ def get_extensions():
define_macros
+=
[(
'MMCV_WITH_CUDA'
,
None
)]
cuda_args
=
os
.
getenv
(
'MMCV_CUDA_ARGS'
)
extra_compile_args
[
'nvcc'
]
=
[
cuda_args
]
if
cuda_args
else
[]
if
is_rocm_pytorch
and
platform
.
system
()
!=
'Windows'
:
extra_compile_args
[
'nvcc'
]
+=
\
[
'--gpu-max-threads-per-block=1024'
]
op_files
=
glob
.
glob
(
'./mmcv/ops/csrc/pytorch/*.cpp'
)
+
\
glob
.
glob
(
'./mmcv/ops/csrc/pytorch/cpu/*.cpp'
)
+
\
glob
.
glob
(
'./mmcv/ops/csrc/pytorch/cuda/*.cu'
)
+
\
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
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 comment