Accessing installed non-python files in cli program?

56 views Asked by At

I am trying to package a console program that I've written in python that has some non-python xslt files.

This is what my package directory looks like:

fpds-converter
|   debug.log
|   MANIFEST.in
|   requirements-dev.txt
|   requirements.txt
|   setup.py
\---converter
|   |   fpds_conversion.py
|   |   __init__.py
|   \---xlst
|   |   |    normalize-record.xsl
\---scripts
|   |   __init__.py
|   |   cli.py

My cli program is a cli program run by fpds; however when I run fpds args ... I get

Traceback (most recent call last):
  File "D:\projects\fpds-converter\.venv\Scripts\fpds-script.py", line 11, in <module>
    load_entry_point('fpds-converter==1.0.0', 'console_scripts', 'fpds')()
  File "d:\projects\fpds-converter\.venv\lib\site-packages\pkg_resources\__init__.py", line 489, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "d:\projects\fpds-converter\.venv\lib\site-packages\pkg_resources\__init__.py", line 2852, in load_entry_point
    return ep.load()
  File "d:\projects\fpds-converter\.venv\lib\site-packages\pkg_resources\__init__.py", line 2443, in load
    return self.resolve()
  File "d:\projects\fpds-converter\.venv\lib\site-packages\pkg_resources\__init__.py", line 2449, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "d:\projects\fpds-converter\.venv\lib\site-packages\scripts\cli.py", line 4, in <module>
    from converter.fpds_conversion import parse
  File "d:\projects\fpds-converter\.venv\lib\site-packages\converter\fpds_conversion.py", line 9, in <module>
    with open("xslt/normalize-record.xsl", 'rb') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'xslt/normalize-record.xsl'

Inside my converter\fpds_converions.py

with open("xslt/normalize-record.xsl", 'rb') as f:
    transform = et.XSLT(et.fromstring(f.read()))

In .venv\Lib\site-packages\converter\xslt I see my normalize-record.xsl file.

What am I doing wrong?

0

There are 0 answers