Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
Amulet-Map-Editor/setup.py at breaking_changes · jtmoree-github-com/Amulet-Map-Editor · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
See all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
jtmoree-github-com
Amulet-Map-Editor
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
breaking_changes
Breadcrumbs
Amulet-Map-Editor
/
setup.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
138 lines (117 loc) · 4.69 KB
breaking_changes
Breadcrumbs
Amulet-Map-Editor
/
setup.py
Copy path
Top
File metadata and controls
Code
Blame
138 lines (117 loc) · 4.69 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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
from
typing
import
List
,
Tuple
from
setuptools
import
setup
,
find_packages
from
setuptools
.
command
.
bdist_wheel
import
bdist_wheel
from
Cython
.
Build
import
cythonize
import
glob
import
sys
import
numpy
import
subprocess
import
logging
import
re
import
os
import
versioneer
first_party
=
{
"amulet-core"
,
"amulet-nbt"
,
"pymctranslate"
,
"minecraft-resource-pack"
,
}
def
freeze_requirements
(
packages
:
List
[
str
])
->
List
[
str
]:
# Pip install the requirements to find the newest compatible versions
# This makes sure that the source versions are using the same dependencies as the compiled version.
# This also makes sure that the source version is using the newest version of the dependency.
if
any
(
"~="
in
r
and
r
.
split
(
"~="
,
1
)[
0
].
lower
()
in
first_party
for
r
in
packages
):
print
(
"pip-install"
)
try
:
# make sure pip is up to date
subprocess
.
run
([
sys
.
executable
,
"-m"
,
"pip"
,
"install"
,
"--upgrade"
,
"pip"
])
# run pip install
subprocess
.
run
(
[
sys
.
executable
,
"-m"
,
"pip"
,
"install"
,
*
packages
,
"--upgrade"
]
)
# run pip freeze
installed
=
(
subprocess
.
check_output
(
[
sys
.
executable
,
"-m"
,
"pip"
,
"freeze"
],
encoding
=
"utf-8"
)
.
strip
()
.
split
(
"
\n
"
)
)
requirements_map
=
{
r
.
split
(
"=="
)[
0
].
lower
():
r
for
r
in
installed
}
print
(
installed
,
requirements_map
)
for
index
,
requirement
in
enumerate
(
packages
):
if
"~="
in
requirement
:
lib
=
requirement
.
split
(
"~="
)[
0
].
strip
().
lower
()
if
lib
in
first_party
and
lib
in
requirements_map
:
packages
[
index
]
=
requirements_map
[
lib
]
print
(
f"Modified packages to
{
packages
}
"
)
except
Exception
as
e
:
print
(
"Failed to bake versions:"
,
e
)
return
packages
GCCPattern
=
re
.
compile
(
r"gcc version (?P<major>\d+)\.(?P<minor>\d+)"
)
ClangPattern
=
re
.
compile
(
r"clang(?:-|\s+version\s+)(?P<major>\d+)\.(?P<minor>\d+)"
)
def
get_openmp_args
()
->
Tuple
[
List
[
str
],
List
[
str
],
List
[
str
],
List
[
str
]]:
# This has been lifted from here https://github.com/cython/cython/blob/606bd8cf235149c3be6876d0f5ae60032c8aab6c/runtests.py
import
sysconfig
from
distutils
import
ccompiler
def
get_openmp_args_for
(
arg
)
->
Tuple
[
List
[
str
],
List
[
str
]]:
"""arg == 'CC' or 'CXX'"""
cc
=
(
sysconfig
.
get_config_var
(
arg
)
or
ccompiler
.
get_default_compiler
()
).
split
()[
0
]
if
cc
==
"msvc"
:
# Microsoft Visual C
return
[
"/openmp"
], []
elif
cc
:
# Try GCC and Clang
try
:
out
=
subprocess
.
check_output
([
cc
,
"-v"
]).
decode
()
except
ChildProcessError
:
logging
.
exception
(
f"Could not resolve unknown compiler
{
cc
}
"
)
else
:
gcc_match
=
GCCPattern
.
search
(
out
)
if
gcc_match
:
if
(
gcc_match
.
group
(
"major"
),
gcc_match
.
group
(
"minor"
))
>=
(
4
,
2
):
return
[
"-fopenmp"
], [
"-fopenmp"
]
return
[], []
clang_match
=
ClangPattern
.
search
(
out
)
if
clang_match
:
# if (clang_match.group("major"), clang_match.group("minor")) >= (3, 7):
# return ['-fopenmp'], ['-fopenmp']
return
[], []
# If all else fails disable openmp
return
[], []
omp_ccargs
,
omp_clargs
=
get_openmp_args_for
(
"CC"
)
omp_cppcargs
,
omp_cpplargs
=
get_openmp_args_for
(
"CXX"
)
return
omp_ccargs
,
omp_clargs
,
omp_cppcargs
,
omp_cpplargs
# build cython extensions
if
next
(
glob
.
iglob
(
"amulet_map_editor/**/*.pyx"
,
recursive
=
True
),
None
):
# This throws an error if it does not match any files
omp_ccargs
,
omp_clargs
,
omp_cppcargs
,
omp_cpplargs
=
get_openmp_args
()
ext
=
cythonize
(
"amulet_map_editor/**/*.pyx"
,
aliases
=
{
"OPENMP_CCARGS"
:
omp_ccargs
,
"OPENMP_CLARGS"
:
omp_clargs
,
"OPENMP_CPPCARGS"
:
omp_cppcargs
,
"OPENMP_CPPLARGS"
:
omp_cpplargs
,
},
)
else
:
ext
=
()
cmdclass
=
versioneer
.
get_cmdclass
()
class
BDistWheel
(
bdist_wheel
):
def
finalize_options
(
self
):
if
"BDISTWHEELFREEZELIBS"
in
os
.
environ
:
self
.
distribution
.
install_requires
=
freeze_requirements
(
list
(
self
.
distribution
.
install_requires
)
)
super
().
finalize_options
()
cmdclass
[
"bdist_wheel"
]
=
BDistWheel
setup
(
version
=
versioneer
.
get_version
(),
cmdclass
=
cmdclass
,
include_dirs
=
[
numpy
.
get_include
()],
packages
=
find_packages
(),
ext_modules
=
ext
,
)
You can’t perform that action at this time.