calculix / ccx2paraview

CalculiX to Paraview converter (frd to vtk/vtu). Makes possible to view and postprocess CalculiX analysis results in Paraview. Generates Mises and Principal components for stress and strain tensors.
GNU General Public License v3.0
92 stars 19 forks source link

PyPI entry point #43

Open kbrindley opened 6 days ago

kbrindley commented 6 days ago

You can create an executable on PATH with the [project.scripts] section. Then users won't need to find the source file in their virtual environment to execute.

https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#creating-executable-scripts

pyproject.toml

[project.scripts]
ccx2paraview = "ccx2paraview.ccx2paraview:main

edit: fixed syntax for :main

kbrindley commented 6 days ago

related: https://github.com/conda-forge/ccx2paraview-feedstock/issues/3

kbrindley commented 1 day ago

I see the existing scripts here: https://github.com/calculix/ccx2paraview/blob/master/pyproject.toml#L36-L39

But I don't see the executables after install. Since I usually work from conda environments, possibly a mixed Conda/PyPI thing?

Test from minimal "pip" only conda environment. Confirm no conda-forge ccx2paraview package installed.

$ conda create --name ccx2paraview -c conda-forge pip --yes
$ conda activate ccx2paraview
$ conda list ccx2paraview
# packages in environment at .../envs/ccx2paraview:
#
# Name                    Version                   Build  Channel

Install with pip and search for executables/entry points

$ pip install ccx2paraview
Collecting ccx2paraview
  Using cached ccx2paraview-3.1.0-py3-none-any.whl.metadata (49 kB)
Using cached ccx2paraview-3.1.0-py3-none-any.whl (38 kB)
Installing collected packages: ccx2paraview
Successfully installed ccx2paraview-3.1.0
$ which ccx2paraview
/usr/bin/which: no ccx2paraview in ...
$ which ccxToVTU
/usr/bin/which: no ccxToVTU ...
$ which ccxToVTK
/usr/bin/which: no ccxToVTK ...

The only file I see in the pip installed package is the ccx2paraview.py module, no cli.py module. Possibly why the entry point is not created?

$ ls $CONDA_PREFIX/lib/python3.*/site-packages/ccx2paraview/
__pycache__/  ccx2paraview.py*  __init__.py*
kbrindley commented 1 day ago

Downloading from here: https://pypi.org/project/ccx2paraview/#files confirms that it is the PyPI package that doesn't have the expected source files. Not a Conda/PIP mixup.

$ tar -tvf ccx2paraview-3.1.0.tar.gz 
-rwxr-xr-x 0/0               0 2020-02-01 17:00 ccx2paraview-3.1.0/src/ccx2paraview/__init__.py
-rwxr-xr-x 0/0           36775 2020-02-01 17:00 ccx2paraview-3.1.0/src/ccx2paraview/ccx2paraview.py
-rwxr-xr-x 0/0              45 2020-02-01 17:00 ccx2paraview-3.1.0/.gitignore
-rwxr-xr-x 0/0           35149 2020-02-01 17:00 ccx2paraview-3.1.0/LICENSE
-rwxr-xr-x 0/0            8490 2020-02-01 17:00 ccx2paraview-3.1.0/README.md
-rwxr-xr-x 0/0             644 2020-02-01 17:00 ccx2paraview-3.1.0/pyproject.toml
-rw-r--r-- 0/0           49384 2020-02-01 17:00 ccx2paraview-3.1.0/PKG-INFO
$ unzip -l ccx2paraview-3.1.0-py3-none-any.whl 
Archive:  ccx2paraview-3.1.0-py3-none-any.whl
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  02-02-2020 00:00   ccx2paraview/__init__.py
    36775  02-02-2020 00:00   ccx2paraview/ccx2paraview.py
    49384  02-02-2020 00:00   ccx2paraview-3.1.0.dist-info/METADATA
       87  02-02-2020 00:00   ccx2paraview-3.1.0.dist-info/WHEEL
    35149  02-02-2020 00:00   ccx2paraview-3.1.0.dist-info/licenses/LICENSE
      489  02-02-2020 00:00   ccx2paraview-3.1.0.dist-info/RECORD
---------                     -------
   121884                     6 files
kbrindley commented 1 day ago

Now I see that maybe the PyPI package is just out-of-date with respect to the repository. Maybe this issue can close if/when a new PyPI package is published from an up-to-date commit?