Access to package.py file path in EarlyThis object
Motivation
I'm attempting to create a package.py file for use in developer workflows, which would live in the git repo of the project,
Its for a python library project and I would like the package.py to read in from the its requiments.txt in the root of the repo
Currently any relative paths are are anchored to my shell cwd and __file__ is not available
Unless there another way to get the current package.py path, please let me know
My example using rez tools:
@early()
def requires():
from rez.utils.pip import packaging_req_to_rez_req, normalize_requirement
with open('requirements.txt') as f:
lines = [str(l).rstrip() for l in f.readlines() if not l.startswith('#')]
require = [
packaging_req_to_rez_req(normalize_requirement(line)[0]).safe_str()
for line in lines
]
return require
Proposed Solution
I dont think this would be too much of an issue to facilitate,
changing rez.serialise._load_py, it could set the attr package to have the filename var already in the function scope
So this.package will have /repo/package_name/package.py value
Access to package.py file path in EarlyThis object
Motivation I'm attempting to create a package.py file for use in developer workflows, which would live in the git repo of the project, Its for a python library project and I would like the package.py to read in from the its
requiments.txt
in the root of the repoCurrently any relative paths are are anchored to my shell cwd and
__file__
is not available Unless there another way to get the current package.py path, please let me knowMy example using rez tools:
Proposed Solution I dont think this would be too much of an issue to facilitate, changing
rez.serialise._load_py
, it could set the attrpackage
to have thefilename
var already in the function scopeSo
this.package
will have/repo/package_name/package.py
value