Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyPI entry point #43

Open
kbrindley opened this issue Oct 11, 2024 · 10 comments
Open

PyPI entry point #43

kbrindley opened this issue Oct 11, 2024 · 10 comments

Comments

@kbrindley
Copy link

kbrindley commented Oct 11, 2024

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
Copy link
Author

related: conda-forge/ccx2paraview-feedstock#3

@kbrindley
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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?

@soylentOrange
Copy link
Contributor

@jan-janssen & @kbrindley thanks for providing the conda-forge package.

Still, I was in trouble getting ccx2paraview to work as PyPI package and github readme are out of sync.
I finally managed to get it to work by setting up a conda environment including paraview:

conda create -n calculix_paraview python=3.12 calculix numpy==1.26.4 paraview ccx2paraview  
conda activate calculix_paraview

and using the ccx2paraview package in python:

from ccx2paraview.ccx2paraview import Converter as ccx2paraviewConverter
c = ccx2paraviewConverter(frd_file_name, ['vtu'])
c.run() 

@imirzov the ccx2paraview package is a really great tool! I'm hoping for a new PyPI package release to get this issue handled (or maybe have a section in the README.md added to instruct on how to use the current PyPI package release).

BR,
Robert

@imirzov
Copy link
Collaborator

imirzov commented Nov 2, 2024

Hi and let me explain about GitHub and PyPI documentations.

GitHub repo contains development version of the code, and the documentation is relevant to the actual code modifications.
PyPI contains release version - so, please, refer to the last release documentation about PyPI package. By the way, I've checked PyPI - it has correct readme for the version 3.1.0 (the last release): https://pypi.org/project/ccx2paraview/

@fsimonis did last commits, so we may ask him for comments about pyproject.toml and PyPI automatic publishing. I have no idea what is it. After him I did not create a new release, since the code does not contain new features for an end CalculiX user.

And if you need to modify the code - just do it. I'll merge then. That's how open source works.

@fsimonis
Copy link
Collaborator

fsimonis commented Nov 4, 2024

@imirzov Hi there,

The autopublishing is triggered by a new tag, hence you could create a new release to sync PyPI and the GitHub repo.

One could say that the alias commands and the packaging are new "features", in which case, a minor release would make sense.
Otherwise, a bugfix release would do the trick.

@soylentOrange
Copy link
Contributor

Hi,

I‘m just now testing a bugfix to overcome the SyntaxError warnings when running with Python 3.13… So, if you decide to publishing a new release, you could wait a few hours.

BR,
Robert

@imirzov
Copy link
Collaborator

imirzov commented Nov 7, 2024

Ok, @soylentOrange, you decide if we can create a new release since you're the last person who tested the code. Here is the list of improvements:

  • Added vtkhdf writer
  • Fix syntax warning invalid escape sequence
  • Made the development version installable by pip
  • Add alias scripts for converting to formats
  • Add PyPi publishing workflow
  • Turned into installable package
  • Improvements in von Mises and principal stress calculations

@soylentOrange
Copy link
Contributor

@imirzov & @fsimonis , yes, I think it's worth a new release: 3.2.0
After some additional testing, I've prepared a new PR #50 to update the documentation regarding the current interface.
After this is merged, the new release can be published.

In my opinion the list of improvements is:

  • Added vtkhdf writer (that's not in the code)
  • Fix syntax warning invalid escape sequence on python 3.13
  • Made the development version installable by pip
  • Add alias scripts for converting to formats
  • Add PyPi publishing workflow
  • Turned into installable package
  • Improvements in von Mises and principal stress calculations
  • streamline import of Converter (i.e. from ccx2paraview import Converter)
  • fix broken pvd-file (missing '.' in '.vtu')
  • added description in readme: how to convert to a vtkhdf-file

BR,
Robert

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants