jbweston / miniver

Like Versioneer, but smaller
Creative Commons Zero v1.0 Universal
53 stars 10 forks source link

Allow distributions that place packages in an arbitrary directory #39

Closed jsacrist closed 2 years ago

jsacrist commented 3 years ago

The 0.7.0 release of miniver added support for allowing packages inside of a "src" directory. While this makes miniver more flexible than before, the current implementation fails when the package is inside a directory with a different name.

When building a package that is part of a native namespace, your repository will look something like this:

.                                 # <-- Root of the repository
├── some_namespace                # <-- namespace directory
│   └── some_package              # <-- distribution package directory
│       ├── some_sourcefile.py    #
│       ├── .gitattributes        #
│       ├── __init__.py           #
│       ├── _static_version.py    #
│       └── _version.py           #
├── README.md
└── setup.py

In this scenario, producing a wheel file (by running python3 setup.py bdist_wheel) will fail because miniver's cmdclass (from _version.py) contains classes that make reference to ./some_package/_static_version.py (instead of ./some_namespace/some_package/_static_version.py).

This could be very easily solved if instead of having a dictionary cmdclass in _version.py, we have a function with a signature get_cmd(prefix_dir="") that can pre-pend any arbitrary directory to the classes contained in the dictionary. With this proposed approach, in your setup.py you can call either:

NOTE: Solving this problem is related to issue #38, and it's a pre-requisite to having a solution for that issue.