File: pyi_module__file__attribute.py

package info (click to toggle)
pyinstaller 6.18.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,820 kB
  • sloc: python: 41,828; ansic: 12,123; makefile: 171; sh: 131; xml: 19
file content (36 lines) | stat: -rw-r--r-- 1,330 bytes parent folder | download | duplicates (2)
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
#-----------------------------------------------------------------------------
# Copyright (c) 2005-2023, PyInstaller Development Team.
#
# Distributed under the terms of the GNU General Public License (version 2
# or later) with exception for distributing the bootloader.
#
# The full license is in the file COPYING.txt, distributed with this software.
#
# SPDX-License-Identifier: (GPL-2.0-or-later WITH Bootloader-exception)
#-----------------------------------------------------------------------------

# Test the value of the __file__ attribute; for a frozen package, it should be:
#   sys.prefix/package/__init__.py
# and for a frozen module, it should be:
#   sys.prefix/module.py

import os
import sys

import shutil as module
import xml.sax as package

correct_mod = os.path.join(sys.prefix, 'shutil.py')
correct_pkg = os.path.join(sys.prefix, 'xml', 'sax', '__init__.py')

# Print.
print(('Actual   mod.__file__: %s' % module.__file__))
print(('Expected mod.__file__: %s' % correct_mod))
print(('Actual   pkg.__file__: %s' % package.__file__))
print(('Expected pkg.__file__: %s' % correct_pkg))

# Test correct values.
if not module.__file__ == correct_mod:
    raise SystemExit('MODULE.__file__ attribute is wrong.')
if not package.__file__ == correct_pkg:
    raise SystemExit('PACKAGE.__file__ attribute is wrong.')