Beruflich Dokumente
Kultur Dokumente
2020, 15:53
https://towardsdatascience.com/building-a-python-package-without-publishing-e2d36c4686cd Strona 1 z 6
Build Python Packages Without Publishing - Towards Data Science 14.06.2020, 15:53
#ui.py
def get_image_file():
Tk().withdraw()
filename = filedialog.askopenfilename(title =
"Select file",filetypes = [("jpeg files","*.jpg")])
return filename
image_edits.py
#image_edits.py
https://towardsdatascience.com/building-a-python-package-without-publishing-e2d36c4686cd Strona 2 z 6
Build Python Packages Without Publishing - Towards Data Science 14.06.2020, 15:53
def write_grayscale_image(filepath):
original_image = imread(filepath)
grayed_image = cvtColor(original_image,
COLOR_RGB2GRAY)
grayed_filename=os.path.join(os.path.split(filepath)
[0],'grayed_'+os.path.split(filepath)[1])
print(grayed_filename)
imwrite(grayed_filename, grayed_image) #export
grayscaled image
return grayed_filename
$ touch __init__.py
dir/
image_pkg/
ui.py
image_edits.py
__init__.py
https://towardsdatascience.com/building-a-python-package-without-publishing-e2d36c4686cd Strona 3 z 6
Build Python Packages Without Publishing - Towards Data Science 14.06.2020, 15:53
setup.py
import setuptools
setuptools.setup(name='examplepackage',
version='0.1',
description='An example package',
url='#',
author='max',
install_requires=['opencv-python'],
author_email='',
packages=setuptools.find_packages(),
zip_safe=False)
dir/
image_pkg/
ui.py
image_edits.py
__init__.py
setup.py
https://towardsdatascience.com/building-a-python-package-without-publishing-e2d36c4686cd Strona 4 z 6
Build Python Packages Without Publishing - Towards Data Science 14.06.2020, 15:53
Install wheel.
$ pip install .
Our package has been created, and we can now use it from
anywhere. Let’s create a simple app which incorporates our
package contents.
main.py
#main.py
write_grayscale_image(get_image_file())
https://towardsdatascience.com/building-a-python-package-without-publishing-e2d36c4686cd Strona 5 z 6
Build Python Packages Without Publishing - Towards Data Science 14.06.2020, 15:53
https://towardsdatascience.com/building-a-python-package-without-publishing-e2d36c4686cd Strona 6 z 6