Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to structure python project with dot "." or underscore "-" in project/package name?

PEP 423 states that project names and package names should be the same and later gives an example where the project/package name contains a dot:

Yes:
Package name: "kheops.pyramid", i.e. import kheops.pyramid
Project name: "kheops.pyramid", i.e. pip install kheops.pyramid

What would the directory structure be for kheops.pyramid and how would setup.py be written (specifically the name and packages values) for that directory structure?

I've also seen that PEP 503 states that names should be normalized by replacing _, -, and . with -. Does this mean that kheops-pyramid should be used rather than kheops.pyramid? If so, wouldn't I need a package whose directory name is kheops-pyramid and wouldn't the - cause issues (eg. syntax error) when trying to import kheops-pyramid?

EDIT:
I tried to make a project/package kheops.pyramid to adhere to PEP 423 but I cannot figure out what directory structure and setup.py combination will allow me to import kheops.pyramid after pip install kheops.pyramid without an error like ImportError: No module named kheops.pyramid.

like image 975
Pedro Cattori Avatar asked Jun 11 '16 15:06

Pedro Cattori


1 Answers

PEP 423 is deferred, so I ended doing to equivalent of pyramid rather than kheops.pyramid via standard python packaging. Here is the package I came up with as an example.

like image 126
Pedro Cattori Avatar answered Oct 17 '22 12:10

Pedro Cattori