I have been unsuccessful in creating a Python package distribution. I have followed the instructions in https://packaging.python.org/tutorials/packaging-projects/ and this is what happens. For e.g. if I create the necessary files and folders as required
first/
first/
__init__.py
setup.py
LICENSE
README.md
myfirst.py
I have made the package name as 'first' in setup.py
import setuptools
with open("README.md", "r") as fh:
long_description = fh.read()
setuptools.setup(
name="tvg11",
version="0.0.1",
author="Ganesh",
author_email="tvganesh.85@gmail.com",
description="A small example package",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/pypa/sampleproject",
packages=setuptools.find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
)
Then I run the commands
python setup.py sdist bdist_wheel
python -m twine upload --repository-url https://test.pypi.org/legacy/ dist/*
which creates dist/, build/ and first.egg-info.
Now I find that if I am in the same directory and do a
pip install --index-url https://test.pypi.org/simple/ first
Then I find that this creates a new folder pycache with the compiled code and I am able to do import first
first/
first/
__pycache__ # new!
build/
dist/
first.egg.info
__init__.py
setup.py
LICENSE
README.md
myfirst.py
However, if I am in any other folder other the root folder 'first/first' and I do a
pip install --index-url https://test.pypi.org/simple/ first
I get a 'Successfully installed' but when I invoke python and do an import first I get ModuleNotFoundError "No module 'first'".
Please let me know what I am doing wrong. The instructions were so simple.