radiasoft / pykern

Apache License 2.0
5 stars 7 forks source link

Fix #466 projex generates pyproject.toml #488

Closed robnagler closed 4 months ago

robnagler commented 4 months ago
rorour commented 4 months ago

I'm getting this error. Is projex broken?

rorour commented 4 months ago

Actually not exactly that error, but it seems related.

[py3;@v wxyz]$ pykern projex init_rs_tree "my wxyz project"
Traceback (most recent call last):
  File "/home/vagrant/.pyenv/versions/py3/bin/pykern", line 8, in <module>
    sys.exit(main())
  File "/home/vagrant/src/radiasoft/pykern/pykern/pykern_console.py", line 17, in main
    return pkcli.main("pykern")
  File "/home/vagrant/src/radiasoft/pykern/pykern/pkcli/__init__.py", line 166, in main
    res = argh.dispatch(parser, argv=argv)
  File "/home/vagrant/.pyenv/versions/3.9.15/envs/py3/lib/python3.9/site-packages/argh/dispatching.py", line 183, in dispatch
    for line in lines:
  File "/home/vagrant/.pyenv/versions/3.9.15/envs/py3/lib/python3.9/site-packages/argh/dispatching.py", line 294, in _execute_command
    for line in result:
  File "/home/vagrant/.pyenv/versions/3.9.15/envs/py3/lib/python3.9/site-packages/argh/dispatching.py", line 277, in _call
    result = function(*positional, **keywords)
  File "/home/vagrant/src/radiasoft/pykern/pykern/pkcli/projex.py", line 76, in init_rs_tree
    init_tree(
  File "/home/vagrant/src/radiasoft/pykern/pykern/pkcli/projex.py", line 108, in init_tree
    base = pkresource.filename("projex")
  File "/home/vagrant/src/radiasoft/pykern/pykern/pkresource.py", line 47, in filename
    for f, p in _files(relative_filename, caller_context, packages):
  File "/home/vagrant/src/radiasoft/pykern/pykern/pkresource.py", line 90, in _files
    pkg_resources.resource_filename(
  File "/home/vagrant/.pyenv/versions/3.9.15/envs/py3/lib/python3.9/site-packages/pkg_resources/__init__.py", line 1181, in resource_filename
    return get_provider(package_or_requirement).get_resource_filename(
  File "/home/vagrant/.pyenv/versions/3.9.15/envs/py3/lib/python3.9/site-packages/pkg_resources/__init__.py", line 391, in get_provider
    return _find_adapter(_provider_factories, loader)(module)
  File "/home/vagrant/.pyenv/versions/3.9.15/envs/py3/lib/python3.9/site-packages/pkg_resources/__init__.py", line 1460, in __init__
    self.module_path = os.path.dirname(getattr(module, '__file__', ''))
  File "/home/vagrant/.pyenv/versions/3.9.15/lib/python3.9/posixpath.py", line 152, in dirname
    p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType
robnagler commented 4 months ago

@rorour I can't reproduce the projex failure above:

$ mkdir wxyz; cd wxyz; git init .; pykern projex init_rs_tree "my wxyz project"
Initialized empty Git repository in /home/vagrant/src/radiasoft/wxyz/.git/
$
robnagler commented 4 months ago

g tox still shows some instances that I think can be removed.

11e648a

robnagler commented 4 months ago

It's probably an old python package on your local vm.

rorour commented 4 months ago

Do you know how I can find out which package and/or how to fix it?

moellep commented 4 months ago

You could run "pip list --outdated" to see old packages and update them using a command found here: https://stackoverflow.com/questions/2720014/how-to-upgrade-all-python-packages-with-pip

Probably need to run "pip install -e ." in the sirepo and pykern directory afterward to downgrade anything.

Maybe @robnagler has a better way to do this.

robnagler commented 4 months ago

Try this first:

cd ~/src/radiasoft/pykern
pip install --upgrade --upgrade-strategy only-if-needed .

If projex still fails, we have something that needs bumping in pyproject.toml. Then we would want to know which packages need updating and that's trickier to debug, because you have to upgrade packages one at a time.

rorour commented 4 months ago

cd ~/src/radiasoft/pykern pip install --upgrade --upgrade-strategy only-if-needed .

This fixed it. Thanks