本文整理汇总了Python中nuitka.Utils.abspath方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.abspath方法的具体用法?Python Utils.abspath怎么用?Python Utils.abspath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nuitka.Utils
的用法示例。
在下文中一共展示了Utils.abspath方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: isSameModulePath
# 需要导入模块: from nuitka import Utils [as 别名]
# 或者: from nuitka.Utils import abspath [as 别名]
def isSameModulePath(path1, path2):
if Utils.basename(path1) == "__init__.py":
path1 = Utils.dirname(path1)
if Utils.basename(path2) == "__init__.py":
path2 = Utils.dirname(path2)
return Utils.abspath(path1) == Utils.abspath(path2)
示例2: considerFilename
# 需要导入模块: from nuitka import Utils [as 别名]
# 或者: from nuitka.Utils import abspath [as 别名]
def considerFilename( module_filename, module_package ):
assert module_package is None or ( type( module_package ) is str and module_package != "" )
module_filename = Utils.normpath( module_filename )
if Utils.isDir( module_filename ):
module_filename = Utils.abspath( module_filename )
module_name = Utils.basename( module_filename )
module_relpath = Utils.relpath( module_filename )
return module_filename, module_relpath, module_name
elif module_filename.endswith( ".py" ):
module_name = Utils.basename( module_filename )[:-3]
module_relpath = Utils.relpath( module_filename )
return module_filename, module_relpath, module_name
else:
return None
示例3: buildModuleTree
# 需要导入模块: from nuitka import Utils [as 别名]
# 或者: from nuitka.Utils import abspath [as 别名]
def buildModuleTree( filename, package, is_top, is_main ):
# Many variables, branches, due to the many cases, pylint: disable=R0912
assert package is None or type( package ) is str
if is_main and Utils.isDir( filename ):
source_filename = Utils.joinpath( filename, "__main__.py" )
if not Utils.isFile( source_filename ):
sys.stderr.write(
"%s: can't find '__main__' module in '%s'\n" % (
Utils.basename( sys.argv[0] ),
filename
)
)
sys.exit( 2 )
filename = source_filename
main_added = True
else:
main_added = False
if Utils.isFile( filename ):
source_filename = filename
source_ref = SourceCodeReferences.fromFilename(
filename = filename,
future_spec = FutureSpec()
)
if is_main:
module_name = "__main__"
else:
module_name = Utils.basename( filename )
if module_name.endswith( ".py" ):
module_name = module_name[:-3]
if "." in module_name:
sys.stderr.write(
"Error, '%s' is not a proper python module name.\n" % (
module_name
)
)
sys.exit( 2 )
if is_main:
result = PythonMainModule(
source_ref = source_ref,
main_added = main_added
)
else:
result = PythonModule(
name = module_name,
package = package,
source_ref = source_ref
)
elif Utils.isDir( filename ) and Utils.isFile( Utils.joinpath( filename, "__init__.py" ) ):
source_filename = Utils.joinpath( filename, "__init__.py" )
if is_top:
source_ref = SourceCodeReferences.fromFilename(
filename = Utils.abspath( source_filename ),
future_spec = FutureSpec()
)
package_name = Utils.splitpath( filename )[-1]
else:
source_ref = SourceCodeReferences.fromFilename(
filename = Utils.abspath( source_filename ),
future_spec = FutureSpec()
)
package_name = Utils.basename( filename )
result = PythonPackage(
name = package_name,
package = package,
source_ref = source_ref
)
else:
sys.stderr.write(
"%s: can't open file '%s'.\n" % (
Utils.basename( sys.argv[0] ),
filename
)
)
sys.exit( 2 )
if not Options.shallHaveStatementLines():
source_ref = source_ref.atInternal()
source_code = readSourceCodeFromFilename( source_filename )
module_body = buildParseTree(
provider = result,
source_code = source_code,
source_ref = source_ref,
#.........这里部分代码省略.........
示例4: detectBinaryDLLs
# 需要导入模块: from nuitka import Utils [as 别名]
# 或者: from nuitka.Utils import abspath [as 别名]
def detectBinaryDLLs(binary_filename, package_name):
result = set()
if Utils.getOS() in ("Linux", "NetBSD"):
# Ask "ldd" about the libraries being used by the created binary, these
# are the ones that interest us.
process = subprocess.Popen(
args = [
"ldd",
binary_filename
],
stdout = subprocess.PIPE,
stderr = subprocess.PIPE
)
stdout, _stderr = process.communicate()
for line in stdout.split(b"\n"):
if not line:
continue
if b"=>" not in line:
continue
part = line.split(b" => ", 2)[1]
if b"(" in part:
filename = part[:part.rfind(b"(")-1]
else:
filename = part
if not filename:
continue
if Utils.python_version >= 300:
filename = filename.decode("utf-8")
result.add(filename)
elif Utils.getOS() == "Windows":
depends_exe = getDependsExePath()
env = os.environ.copy()
path = env.get("PATH","").split(";")
path += sys.path
if package_name is not None:
for element in sys.path:
candidate = Utils.joinpath(element, package_name)
if Utils.isDir(candidate):
path.append(candidate)
env["PATH"] = ";".join(path)
subprocess.call(
(
depends_exe,
"-c",
"-ot%s" % binary_filename + ".depends",
"-f1",
"-pa1",
"-ps1",
binary_filename
),
env = env,
)
inside = False
for line in open(binary_filename + ".depends"):
if "| Module Dependency Tree |" in line:
inside = True
continue
if not inside:
continue
if "| Module List |" in line:
break
if "]" not in line:
continue
# Skip missing DLLs, apparently not needed anyway.
if "?" in line[:line.find("]")]:
continue
dll_filename = line[line.find("]")+2:-1]
assert Utils.isFile(dll_filename), dll_filename
# The executable itself is of course excempted.
if Utils.normcase(dll_filename) == \
Utils.normcase(Utils.abspath(binary_filename)):
continue
dll_name = Utils.basename(dll_filename).upper()
# Win API can be assumed.
if dll_name.startswith("API-MS-WIN-") or dll_name.startswith("EXT-MS-WIN-"):
#.........这里部分代码省略.........
示例5: decideModuleTree
# 需要导入模块: from nuitka import Utils [as 别名]
# 或者: from nuitka.Utils import abspath [as 别名]
def decideModuleTree(filename, package, is_shlib, is_top, is_main):
# Many variables, branches, due to the many cases, pylint: disable=R0912
assert package is None or type( package ) is str
if is_main and Utils.isDir( filename ):
source_filename = Utils.joinpath( filename, "__main__.py" )
if not Utils.isFile( source_filename ):
sys.stderr.write(
"%s: can't find '__main__' module in '%s'\n" % (
Utils.basename( sys.argv[0] ),
filename
)
)
sys.exit( 2 )
filename = source_filename
main_added = True
else:
main_added = False
if Utils.isFile( filename ):
source_filename = filename
source_ref = SourceCodeReferences.fromFilename(
filename = filename,
future_spec = FutureSpec()
)
if is_main:
module_name = "__main__"
else:
module_name = Utils.basename( filename )
if module_name.endswith( ".py" ):
module_name = module_name[:-3]
if is_shlib:
module_name = module_name.split(".")[0]
if "." in module_name:
sys.stderr.write(
"Error, '%s' is not a proper python module name.\n" % (
module_name
)
)
sys.exit( 2 )
if is_shlib:
result = PythonShlibModule(
name = module_name,
source_ref = source_ref,
package_name = package,
)
elif is_main:
result = PythonMainModule(
source_ref = source_ref,
main_added = main_added
)
else:
result = PythonModule(
name = module_name,
package_name = package,
source_ref = source_ref
)
elif Importing.isPackageDir(filename):
if is_top:
package_name = Utils.splitpath(filename)[-1]
else:
package_name = Utils.basename(filename)
source_filename = Utils.joinpath(filename, "__init__.py")
if not Utils.isFile( source_filename ):
assert Utils.python_version >= 330, source_filename
source_ref, result = createNamespacePackage(
package_name = package_name,
module_relpath = filename
)
source_filename = None
else:
source_ref = SourceCodeReferences.fromFilename(
filename = Utils.abspath( source_filename ),
future_spec = FutureSpec()
)
result = PythonPackage(
name = package_name,
package_name = package,
source_ref = source_ref
)
else:
sys.stderr.write(
"%s: can't open file '%s'.\n" % (
Utils.basename( sys.argv[0] ),
filename
#.........这里部分代码省略.........