Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import sys
import subprocess
import shutil
from wheel.pep425tags import get_abi_tag, get_platform
os.environ["PYTHONDONTWRITEBYTECODE"] = "1"
def run(cmd):
print(cmd)
try:
subprocess.check_call(cmd)
except subprocess.CalledProcessError as e:
sys.exit(e.returncode)
venv = "test-venv-{}-{}".format(get_abi_tag(), get_platform())
if not exists(venv):
print("-- Creating venv in {} --".format(venv))
run([sys.executable, "-m", "virtualenv", "-p", sys.executable, venv])
python_candidates = [
join(venv, "bin", "python"),
join(venv, "Scripts", "python.exe"),
]
for python_candidate in python_candidates:
if exists(python_candidate):
python_exe = python_candidate
break
else:
raise RuntimeError("I don't understand this platform's virtualenv layout")
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Utility script to print the python tag + the abi tag for a Python
# See PEP 425 for exactly what these are, but an example would be:
# cp27-cp27mu
from wheel.pep425tags import get_abbr_impl, get_impl_ver, get_abi_tag
print("{0}{1}-{2}".format(get_abbr_impl(), get_impl_ver(), get_abi_tag()))
# Utility script to print the python tag + the abi tag for a Python
# See PEP 425 for exactly what these are, but an example would be:
# cp27-cp27mu
from wheel.pep425tags import get_abbr_impl, get_impl_ver, get_abi_tag
print("{0}{1}-{2}".format(get_abbr_impl(), get_impl_ver(), get_abi_tag()))
# Utility script to print the python tag + the abi tag for a Python
# See PEP 425 for exactly what these are, but an example would be:
# cp27-cp27mu
from wheel.pep425tags import get_abbr_impl, get_impl_ver, get_abi_tag
print("{0}{1}-{2}".format(get_abbr_impl(), get_impl_ver(), get_abi_tag()))
# Utility script to print the python tag + the abi tag for a Python
# See PEP 425 for exactly what these are, but an example would be:
# cp27-cp27mu
from wheel.pep425tags import get_abbr_impl, get_impl_ver, get_abi_tag
print("{0}{1}-{2}".format(get_abbr_impl(), get_impl_ver(), get_abi_tag()))
kernel = uname[3] # 5.1.2600
release = uname[2] # XP, 2000, 7
version = uname[3] + service_pack # 5.1.2600 SP3, 6.1.7601 SP1
elif system == "Darwin":
kernel = uname[2] # 12.2.0
release = "OSX" # OSX
version = platform.mac_ver()[0] # 10.8.2
elif system == "Linux":
kernel = uname[2] # 3.2.5
release = platform.linux_distribution()[0] # Ubuntu
version = platform.linux_distribution()[1] # 12.04
# Emulate PEP 425 naming conventions - e.g. cp27-cp27mu-linux_x86_64.
pep425tag = "%s%s-%s-%s" % (pep425tags.get_abbr_impl(),
pep425tags.get_impl_ver(),
str(pep425tags.get_abi_tag()).lower(),
pep425tags.get_platform())
return cls.from_keywords(
session=session,
system=system,
architecture=architecture,
node=uname[1],
release=release,
version=version,
machine=uname[4], # x86, x86_64
kernel=kernel,
fqdn=fqdn,
pep425tag=pep425tag,
)
if plat_name in ('linux-x86_64', 'linux_x86_64') and sys.maxsize == 2147483647:
plat_name = 'linux_i686'
plat_name = plat_name.replace('-', '_').replace('.', '_')
if self.root_is_pure:
if self.universal:
impl = 'py2.py3'
else:
impl = self.python_tag
tag = (impl, 'none', plat_name)
else:
impl_name = get_abbr_impl()
impl_ver = get_impl_ver()
# PEP 3149
abi_tag = str(get_abi_tag()).lower()
tag = (impl_name + impl_ver, abi_tag, plat_name)
supported_tags = pep425tags.get_supported(
supplied_platform=plat_name if self.plat_name_supplied else None)
# XXX switch to this alternate implementation for non-pure:
assert tag == supported_tags[0], "%s != %s" % (tag, supported_tags[0])
return tag
else:
impl = self.python_tag
tag = (impl, 'none', plat_name)
else:
impl_name = get_abbr_impl()
impl_ver = get_impl_ver()
impl = impl_name + impl_ver
# We don't work on CPython 3.1, 3.0.
if self.py_limited_api and (impl_name + impl_ver).startswith('cp3'):
impl = self.py_limited_api
if sys.platform == "win32":
abi_tag = 'none'
else:
abi_tag = 'abi3'
else:
abi_tag = str(get_abi_tag()).lower()
tag = (impl, abi_tag, plat_name)
supported_tags = pep425tags.get_supported(
supplied_platform=plat_name if self.plat_name_supplied else None)
# XXX switch to this alternate implementation for
# non-pure:
if not self.py_limited_api:
assert tag == supported_tags[0], "%s != %s" % (tag, supported_tags[0])
assert tag in supported_tags, \
"would build wheel with unsupported tag {}".format(tag)
return tag