0

I've read the documentation, and I'm still unclear on how to use setuptools to create a package / module that doesn't require my users to import a double name:

import myModule.myModule as mm

I want to create a separate and independent package to be installed with just myModule:

import myModule as mm

My package / module is very simple and just has one file:

mymodule (git directory)
--> setup.py
--> myModule (directory)
----> __init__.py
----> myModule.py

I just want to have this one file installed in site-packages so that my users can just run import myModule.

martineau
  • 119,623
  • 25
  • 170
  • 301
Locane
  • 2,886
  • 2
  • 24
  • 35
  • What happens when you just use ```import myModule```? – ConcernedHobbit Jul 15 '19 at 17:16
  • Can you show your project file structure and `setup.py`? – mkrieger1 Jul 15 '19 at 17:19
  • Possible duplicate of [How to import a module given the full path?](https://stackoverflow.com/questions/67631/how-to-import-a-module-given-the-full-path) – xiaoyao Don Jul 15 '19 at 17:29
  • 1
    Packages need an `__init__.py`. What file name(s) and folder layout you are using? – martineau Jul 15 '19 at 17:49
  • 1
    I edited the original question, thank you for the feedback – Locane Jul 15 '19 at 18:07
  • 2
    Do you plan on adding more modules to your package? If not, don't make it one — just make `MyModule.py` a normal module. – martineau Jul 15 '19 at 18:15
  • I don't plan on adding more; how do I use setuptools to distribute a module instead of a package? I don't want to have to make users figure out where their python libraries are located to copy my file to it. – Locane Jul 15 '19 at 20:19
  • 1
    If you want to distribute `myModule.py` as a standalone module, then don't put it in a `myModule` package in the first place. Move it to the same level as `setup.py`, fix the imports, verify the tests work, remove `packages` keyword from `setup()` function and add `py_modules=['myModule']`. – hoefling Jul 16 '19 at 08:04

0 Answers0