Closed dkriegner closed 1 year ago
I don't know a platform independent installer.
Is it setuptools?
I looked for https://packaging.python.org/en/latest/tutorials/packaging-projects/ and I made pyproject.toml. Is it OK?
setuptools is one option. (it is the traditional tool everyone uses). The other tool one can use is called flit.
I think flit is easier since all information can be in the pyproject.toml file which is the modern approach to python packaging. For you particularly important is the scripts section which allows to define a command line script which should be installed.
The requirements will also be in the pyproject.toml. so the requirements file might be obsolete.
I think it will require you to change a bit the code layout. please try it. I will keep commenting on the code during next week since I am travelling
I don't know how to continue: [build-system] requires = ["Pillow >=9.4.0", "openpyxl>=3.0.9", "opencv>=4.6.0", "shutils>=3.0.9", "numpy>=1.25.2"] build-backend = .... (What must I write here?)
if you want to use flit (which I would recommend for your code which is pure python) then write
[build-system]
requires = ["flit_core >=3.2,<4"]
build-backend = "flit_core.buildapi"
The requirements of your package will go in the project section:
[project]
...
dependencies = [
"Pillow >=9.4.0",
"openpyxl>=3.0.9",
"opencv>=4.6.0",
"shutils>=3.0.9",
"numpy>=1.25.2",
]
Thanks. I've just finished pyproject.toml I'm trying to run a flit command but It doesn't work. I opened this tutorial: https://flit.pypa.io/en/stable/. I don't know how to do this: Run flit init in the directory containing the module to create a pyproject.toml file. It will look something like this...
I changed some things to work with the pip install. actually you never need to call flit
manually. you will always use pip
.
For example I recommend especially for you developing the code to use an editable install via
pip install -e .
After the latest commit this can be executated in the root folder of this repository.
The pip installer then creates an executable "flakes-detector
" which corresponds to your previous main script. If you use the "-e" in the install command you can change the code and after saving the new version should automatically execute. If you do not use "-e" then one always has to reinstall after every code change which is annoying.
please test it if it works for you
Note that I changed the opencv dependency to opencv-python. this might not be always wanted since I guess there are faster versions of this library. feel free to change this
Thanks for your improvements. I've just installed the detector, but it doesn't work. It shut down after the 1st question. I think the problem is with opening the input folder.
yes I think the problem is in the code. The input folder is hardcoded to be within the source directory. I believe this is not good for the future when we want to separate the code and the data. I believe the best would be to use the path in which the script is executed as a basis for all other folders. So the user can decide where to keep their data.
I believe you try to call the main file directly. This does not work. You have to call the installed binary (exe file) which should be in the same folder as the python.exe
On Sun 29. 10. 2023 at 11:08, Jiří Zelenka @.***> wrote:
It doesn't work me:
C:\ProgramData\miniconda3\python.exe C:\Users\jirka\Documents\GitHub\micro-flakes\Detector\main.py Traceback (most recent call last): File "C:\Users\jirka\Documents\GitHub\micro-flakes\Detector\main.py", line 5, in
from .find_objects import find_objects ImportError: attempted relative import with no known parent — Reply to this email directly, view it on GitHub https://github.com/dkriegner/micro-flakes/issues/3#issuecomment-1784154328, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACKZJFIUOODU6DO4BOF4AQLYBZWPFAVCNFSM6AAAAAA6PEA27GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBUGE2TIMZSHA . You are receiving this because you authored the thread.Message ID: @.***>
Or maybe there is a “Scripts” subfolder in the python installation which has the exe.
On Mon 30. 10. 2023 at 10:36, Dominik Kriegner @.***> wrote:
I believe you try to call the main file directly. This does not work. You have to call the installed binary (exe file) which should be in the same folder as the python.exe
On Sun 29. 10. 2023 at 11:08, Jiří Zelenka @.***> wrote:
It doesn't work me:
C:\ProgramData\miniconda3\python.exe C:\Users\jirka\Documents\GitHub\micro-flakes\Detector\main.py Traceback (most recent call last): File "C:\Users\jirka\Documents\GitHub\micro-flakes\Detector\main.py", line 5, in
from .find_objects import find_objects ImportError: attempted relative import with no known parent — Reply to this email directly, view it on GitHub https://github.com/dkriegner/micro-flakes/issues/3#issuecomment-1784154328, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACKZJFIUOODU6DO4BOF4AQLYBZWPFAVCNFSM6AAAAAA6PEA27GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBUGE2TIMZSHA . You are receiving this because you authored the thread.Message ID: @.***>
Truth! It works now for me. I added a user setting, which is saved to a cache file.
Especially since the code will be split into multiple files it will be good to get a proper installer which will create (platform independent) the executable script.
I suggest to add a
pyproject.toml
file and use either setuptools or flit as a build backend creating the installation.