0

This my first time creating a python package and I am trying to host it on github so I can use it in my code

Its just a simple module with one file, but when I install it with pip install -r requirements.txt the metadata folder is showing up in the site-packages but not my actual module file singleton.py. Hence I cannot do import singleton

My pyproject.toml

[build-system]
requires = [
    "setuptools>=57",
]
build-backend = "setuptools.build_meta"

My setup.cfg

[metadata]
name = singleton
version = 1.0.0
url = https://github.com/syntapy/singleton

[options]
package_dir = 
    =src
packages=find:

[options.packages.find]
where=src

I've tried following the 'using a src/ layout' in the Configuring setup() using setup.cfg files documentation, both with find and with singleton but it doesn't work

What am I doing wrong here?

Thank you in advance for any help

1 Answer 1

1

You should put single Python file in src/singleton/ along with an __init__.py.

The structure is correctly explained in your link:

├── src
│   └── mypackage
│       ├── __init__.py
│       └── mod1.py
├── setup.py
└── setup.cfg

Otherwise, with the old school setup.py (with singleton.py and setup.py in the same folder):

from distutils.core import setup

setup(name='singleton',
    version='1.0.0',
    url='https://github.com/syntapy/singleton',
    py_modules = ['singleton'],
)
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you, I tried that but it still wasn't working. But then I tried to put it in src/singleton/__init__.py and that worked. But do you know of a way to make it so I can just have it in a singleton.py file?
I don't know how with setup.cfg, but with setup.py, it's possible. See edited answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.