Technologicat / pyan

Static call graph generator. The official Python 3 version. Development repo.
GNU General Public License v2.0
324 stars 57 forks source link

Installing pyan3 #19

Closed Djaningo closed 3 years ago

Djaningo commented 4 years ago

Hello, and sorry if my errors are obvious, I'm relativly new. So after installing pyan3 using pip install pyan3 I don't find a way to put it into the PATH of windows 10 so I can use the projet with powershell like in the guidelines pyan *.py --uses --no-defines --colored --grouped --annotated --dot >myuses.dot I tried to put the directory into the PATH "C:\ProgramData\Anaconda3\Lib\site-packages\pyan" or "C:\ProgramData\Anaconda3\Lib\site-packages" and it didn't work

Thanks in advance for anyone who will read and put they minds into it, and sorry if it's a stupid error and my part, anyway, have a good day

Technologicat commented 4 years ago

Hi!

I'm a Linux user myself, so I have to admit I don't know about details specfic to Windows. But let's eliminate some possibilities:

The main script should have the name pyan3 (note the 3). The installer should automatically put it somewhere on your PATH. (At least it does so on Linux - this is a feature of setuptools, and pip essentially uses that internally.) If you search for pyan3 on your system, was it installed somewhere? If so, where? Is that directory on PATH?

Secondly, the main script is installed with no file extension. Does Powershell need the name to end in .exe, .com or .bat to consider a file as an executable?

Finally, does Powershell respect a Unix-style hashbang to look up the correct interpreter for a script? The way the main script works is that it's just a Python file, with the hashbang incantation #!/usr/bin/env python3 at the top.

Technologicat commented 4 years ago

Did you get it working?

As for the hashbang, answering my own question here:

On Windows, “shebang” line processing is supported if you have the Python Launcher for Windows installed (this was added to Python in 3.3 - see PEP 397 for more details).

Found in venv documentation.

the-rccg commented 4 years ago

Working on a Windows machine and can confirm that pyan3 installs under pyan for some reason. You can call it with from the example: python -m pyan.main filename.py --uses --no-defines --colored --grouped --annotated --dot > myuses.dot. The non-uniformity across operating systems is not optimal, but it works.

johnyf commented 3 years ago

After pip install pyan3 from PyPI, the script does not run. It raises:

$ pyan3 -h
Traceback (most recent call last):
  File "/path/to/.virtualenvs/venvname/bin/pyan3", line 7, in <module>
    from pyan import main
ModuleNotFoundError: No module named 'pyan'

This issue exists with version 1.0.4, installed from PyPI. This issue does not arise when 1fb436002846cd78ceb35ab6607c19e90b7fc0f2 is installed (with pip install . in the repository).

Please release the latest version of pyan on PyPI. (Also, it could be released as pyan, instead of pyan3, taking into account that Python 2 has reached its EOL.)

Technologicat commented 3 years ago

@johnyf: Thanks for the heads-up. I'll update the package soon-ish.

But before that, since you're here, I'll take the opportunity to ask: I think I noticed some merged PRs in your repo that are not in mine? If they are compatible, could you PR your latest master (or some other applicable revision, your choice) to me so we could include those changes in the version that's going to PyPI?

Regarding the possible name change, yes, that's a good idea. There's no pyan package yet on PyPI, so we could do that. It'll require some small bureaucracy in making pyan3 a virtual package that only pulls in pyan, and emits a deprecation warning if possible. I can look at this, but I can't promise when. I suggest we release a new version of the pyan3 package for now, and look at the renaming after that.

EDIT: wording: not a new pyan3 package, it exists already, but releasing a new version of it. :)

johnyf commented 3 years ago

@Technologicat thank you for maintaining pyan.

The branch master of johnyf/pyan is at https://github.com/johnyf/pyan/commit/a16f5d5124e1e3a696b0402347fe7f8fdd171a58, which is the same as branch master at https://github.com/Technologicat/pyan/commit/a16f5d5124e1e3a696b0402347fe7f8fdd171a58. Several issues in my repository were automatically closed a few days ago when I pushed the updated master from this repository (because there were commits that referenced these issues).

There existed one unmerged branch at johnyf/pyan with an extra commit that removed trailing whitespace. The commit was outdated, so I worked the equivalent changes, and in addition shorter lines within the file setup.py, and opened #41. Branches other than master at johnyf/pyan are at the same commit as they are at Technologicat/pyan.

Removing pyan3 from PyPI (including past versions) in favor of pyan could be another option to consider. This may cause backwards compatibility issues for users, but it will make evident that the package has been renamed (when users search anew for pyan after pip not finding pyan3).

As noted in https://github.com/Technologicat/pyan/issues/40#issuecomment-692592016 there are changes in the Python AST in Python version 3.8 that would require changing pyan. Given that Python is evolving, analysis of older code may be less critical (regarding removing older pyan3 versions from PyPI). Older versions could still be installed from tags in the repository. On the other hand, analyzing older code may remain relevant for understanding it while porting it to newer Python versions.

Technologicat commented 3 years ago

@johnyf : Thanks for the comment. This repo should now be up to date.

@Djaningo : PyPI package pyan3 updated. Please try again with the latest version, and reopen this issue if necessary.