Closed pR0Ps closed 6 years ago
So from the traceback this is because cherrymusicserver/__init__.py
imports cherrymusic
, and setup.py
imports cherrymusicserver
.
https://github.com/devsnd/cherrymusic/blob/aa4eea153b96537383af336fccfb0cd9beee3ceb/setup.py#L10-L11
The cherrymusicserver
and pathprovider
imports in setup.py
are just used to pull version/description info from the package itself. I see two potential solutions.
The info from cherrymusicserver/__init__.py
and cherrymusicserver/pathprovider.py
could be moved to setup.py
directly, omitting the above imports in setup.py
altogether (based on the assumption that the cherrypy
import in __init__.py
cannot change).
Encase the cherrypy import in __init__.py
in a try/except block that catches the import error and mocks cherrypy if the import is from setup.py
. Ugly hack of a solution but it could be made to work. Eg.
try:
import cherrypy
except ImportError as err:
if sys.argv[0] == 'setup.py':
# Mock cherrypy here
else:
raise err
This would fall apart if a cherrypy
import crops up elsewhere in cherrymusicserver/__init__.py
though (ie. another module imports cherrypy
itself).
@devsnd I'd like to hear your input on this before working on a PR.
Hey @pR0Ps, hey @rjsberry!
Thanks for your report and solution analysis!
I'd propose eliminate the imports in the setup.py (as Richard already suggested). To do so I think it would be best to duplicate the code of the pathprovider.sharedFolderName
in the setup.py to resolve this issue:
https://github.com/devsnd/cherrymusic/blob/aa4eea153b96537383af336fccfb0cd9beee3ceb/setup.py#L79
And for getting rid of the import of the cherrymusicserver
we need to get the VERSION and DESCRIPTION variables from cherrymusicserver/__init__.py
. I'd propose to go completely wild and parse the file manually to find the lines (and strings) that correspond to these variables.
Richard, would you take up that task? If you do it, I promise to release a new version right away 🤞
Attempting to install in a clean virtual environment using
pip
fails with an error aboutcherrypy
not being installed.Expected
setup.py
would install the required dependencies (includingcherrypy
).Actual
Workaround
Install
cherrypy
manually usingpip install cherrypy
before installing cherrymusicEnvironment
(probably not relevant but included for completeness's sake)