I created a cudmore-make-pip-install branch that converts the repo to allow "pip install ." from local source.
This required a few additions and changes.
First, I added some files to the root MapManagerCore folder including:
manifest.ini
pyproject.toml
setup.py
The setup.py file does the heavy lifting to allow "pip install .".
Change 1
In general, source code folders are all lower case, see pep8.
Changed source code folder MapManagerCore to all lower case mapmanagercore.
This requires all source code to use all lower case for imports, like from mapmanagercore import MapAnnotations.
Important. When merging this branch we might need to manually change the source code folder from MapManagerCore to all lower case mapmanagercore. This is because I am pushing from macOS and the folder name is the same and macOS does not make a distinction between same folder/file names with different cases. I think git has this same issue?
Modules should have short, all-lowercase names. Underscores can be used in the module name if it improves readability. Python packages should also have short, all-lowercase names, although the use of underscores is discouraged.
Change 2
Moved example.ipynb into examples/ folder
and modified its import to be lowercase import mapmanagercore.
File "/Users/cudmore/opt/miniconda3/envs/mmc-env/lib/python3.11/site-packages/tifffile/tifffile.py", line 8516, in decode_raise_compression
raise ValueError(f'{exc}')
ValueError: <COMPRESSION.ZSTD: 50000> requires the 'imagecodecs' package
Fixed by ading imagecodecs to setup.
Error 2
typing.Self was added in Python 3.11
Fixed by requiring python >= 3.11
Change 3
All source code folders need an __init__.py file. Ideally this is empty but if not empty is ok.
Our setup.py is using a version manager which is of course complicated to understand but should work moving forward.
Important. Never add mapmanagercore/_version.py with git add as it is auto created by versioning in setup.py
Change 4
Set MapManagerCore str to all lower case in mapmanagercore/utils.py
def isMapManagerCore():
"""
Returns true if the caller is in the MapManagerCore module.
"""
frm = inspect.stack()[2]
mod = inspect.getmodule(frm[0])
if mod == None:
return False
return "mapmanagercore" in mod.__name__
Random changes
Added to .gitignore
# macOS hidden files
.AppleDouble
.DS_Store
Install
Finally, here is how the mapmanagercore package can be installed from source.
Create and activate a conda environment named mmc-env
I created a cudmore-make-pip-install branch that converts the repo to allow "
pip install .
" from local source.This required a few additions and changes.
First, I added some files to the root
MapManagerCore
folder including:The
setup.py
file does the heavy lifting to allow "pip install .
".Change 1
In general, source code folders are all lower case, see pep8.
Changed source code folder
MapManagerCore
to all lower casemapmanagercore
.This requires all source code to use all lower case for imports, like
from mapmanagercore import MapAnnotations
.Important. When merging this branch we might need to manually change the source code folder from
MapManagerCore
to all lower casemapmanagercore
. This is because I am pushing from macOS and the folder name is the same and macOS does not make a distinction between same folder/file names with different cases. I think git has this same issue?Here is a snippit from pep8.
Change 2
Moved
example.ipynb
intoexamples/
folderand modified its import to be lowercase
import mapmanagercore
.Error 1
Yields
Fixed by ading
imagecodecs
to setup.Error 2
Fixed by requiring python >= 3.11
Change 3
All source code folders need an
__init__.py
file. Ideally this is empty but if not empty is ok.Added an
__init__.py
to the following folders:Change 3
Added to
mapmanagercore/__init__.py
Our
setup.py
is using a version manager which is of course complicated to understand but should work moving forward.Important. Never add
mapmanagercore/_version.py
withgit add
as it is auto created by versioning in setup.pyChange 4
Set
MapManagerCore
str to all lower case inmapmanagercore/utils.py
Random changes
Added to
.gitignore
Install
Finally, here is how the
mapmanagercore
package can be installed from source.mmc-env
MapManagerCore
folder)Yields (version might be different)
How does this affect Javascript Piodide code?
This part is not done! We need to work out how to import a local pip install of mapmanagercore into the browser.
In general, we want to import mapmanager core from a local wheel
Create a wheel
This creates
dist/mapmanagercore-0.0.post9-py3-none-any.whl
Then in Javascript you do something like this
Where
serverAddress
is the local address of a simple http server.