0) https://www.python.org/downloads/
1) create directory "mypython"
2) create directory "src" in "mypython"
3) create directory "myPyLib" in "src"
4) create file "hello.py" in directory "myPyLib"
5) add code in "hello.py":
def SayHello(name):
print("Hello ", name)
6) create file "__init__.py" in directory "myPyLib"
7) add code in "__init__.py":
from .hello import SayHello
8) create file "__main__.py" in directory "myPyLib"
9) add code in "__main__.py"
from .hello import SayHello
SayHello("dfg")
10) cmd
11) cd C:\work\Python\mypython\src
12) python -m myPyLib
13) cd..
14) py -m pip install --upgrade pip
15) py -m pip install --user virtualenv
16) py -m venv myvenv
17) .\myvenv\Scripts\activate
18) create file "setup.py" in directory "C:\work\Python\mypython"
19) add code in "setup.py":
from setuptools import setup, find_packages
with open("requirements/req.txt") as f:
required = f.read().splitlines()
setup(
version = "0.0.1",
packages=find_packages(where='src', exclude=["tests*"]),
install_requires=required,
name="myPkg",
author="I am",
author_email="",
description="library for static functions",
classifiers=["Programming Language :: Python :: 3"],
python_requires="(right arrow)=3.7",
package_dir={"": "src"},
include_package_data = True
)
20) create file "pyproject.toml" in directory "C:\work\Python\mypython"
21) add in "pyproject.toml":
[build-system]
requires = [
"setuptools(right arrow)=42",
"wheel"
]
build-backend = "setuptools.build_meta"
22) create directory "requirements" in "C:\work\Python\mypython"
23) create file "req.txt" in directory "requirements"
24) add in "req.txt":
pandas==1.1.4
25) create file "MANIFEST.in" in directory "C:\work\Python\mypython"
26) add in "MANIFEST.in"
include requirements/req.txt
27) in cmd: "pip install pandas"
28) modify "hello.py"
import numpy as np
import pandas as pd
def SayHello(name):
print("Hello ", name)
def CheckPandas():
s = pd.Series([1, 3, 5, np.nan, 6, 8])
print(s)
29) modify "__init__.py":
from .hello import SayHello, CheckPandas
30) modify "__main__.py"
from .hello import SayHello, CheckPandas
SayHello("dfg")
CheckPandas()
31) in cmd: "cd src"
32) "python -m myPyLib"
33) cd..
34) .\myvenv\Scripts\deactivate
35) py -m pip install --upgrade build
36) py -m build
37) cd C:\work\Python\mypython\dist
38) py -m venv mytestvenv
39) .\mytestvenv\Scripts\activate
40) pip install myPkg-0.0.1-py3-none-any.whl
41) py
42) from myPyLib import SayHello, CheckPandas
43) SayHello("aa")
44) CheckPandas()
45) Ctrl+Z