FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
xtensor-python/setup.py at master · maxstidbits/xtensor-python · GitHub
maxstidbits
xtensor-python
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
xtensor-python
/
setup.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
74 lines (53 loc) · 2.26 KB
Breadcrumbs
xtensor-python
/
setup.py
Copy path
File metadata and controls
74 lines (53 loc) · 2.26 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#!/usr/bin/env python
"""
Minimal setup.py for backward compatibility.
This setup.py relies on pyproject.toml for the main configuration
following modern Python packaging standards (PEP 517/518/621).
"""
import
os
import
re
from
pathlib
import
Path
from
setuptools
import
setup
def
get_version
():
"""Extract version from C++ header file."""
config_file
=
Path
(
"include/xtensor-python/xtensor_python_config.hpp"
)
if
not
config_file
.
exists
():
raise
FileNotFoundError
(
f"Version config file not found:
{
config_file
}
"
)
content
=
config_file
.
read_text
(
encoding
=
"utf-8"
)
# Extract version components from C++ defines
major_match
=
re
.
search
(
r"#define\s+XTENSOR_PYTHON_VERSION_MAJOR\s+(\d+)"
,
content
)
minor_match
=
re
.
search
(
r"#define\s+XTENSOR_PYTHON_VERSION_MINOR\s+(\d+)"
,
content
)
patch_match
=
re
.
search
(
r"#define\s+XTENSOR_PYTHON_VERSION_PATCH\s+(\d+)"
,
content
)
if
not
all
([
major_match
,
minor_match
,
patch_match
]):
raise
ValueError
(
"Could not extract version from xtensor_python_config.hpp"
)
major
=
major_match
.
group
(
1
)
minor
=
minor_match
.
group
(
1
)
patch
=
patch_match
.
group
(
1
)
return
f"
{
major
}
.
{
minor
}
.
{
patch
}
"
def
create_version_file
():
"""Create a Python version file for dynamic version extraction."""
version
=
get_version
()
# Ensure src/xtensor_python directory exists
version_dir
=
Path
(
"src/xtensor_python"
)
version_dir
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
# Create __init__.py if it doesn't exist
init_file
=
version_dir
/
"__init__.py"
if
not
init_file
.
exists
():
init_file
.
write_text
(
'"""xtensor-python: Python bindings for xtensor."""
\n
\n
'
)
# Create _version.py
version_file
=
version_dir
/
"_version.py"
version_content
=
f'''"""Version information for xtensor-python."""
__version__ = "
{
version
}
"
'''
version_file
.
write_text
(
version_content
,
encoding
=
"utf-8"
)
return
version
if
__name__
==
"__main__"
:
# Create version file before setup
version
=
create_version_file
()
# Call setup with minimal configuration
# Main configuration is in pyproject.toml
setup
(
# Minimal setup for compatibility
# All other configuration is in pyproject.toml
version
=
version
,
)
Back
|
FazBrowse Home
|
New Git URL