Commit a787a95f by Sébastien Eustace

Fix an error in install for applications

parent 7959d68f
......@@ -7,6 +7,7 @@
- Fixed the `--no-dev` option in `install` not working properly.
- Fixed prereleases being selected even if another constraint conflicted with them.
- Fixed an error when installing current package in development mode if the generated `setup.py` had special characters.
- Fixed an error in `install` for applications not following a known structure.
## [0.12.2] - 2018-10-17
......
......@@ -29,6 +29,7 @@ exist it will look for <comment>pyproject.toml</> and do the same.
from poetry.installation import Installer
from poetry.io import NullIO
from poetry.masonry.builders import SdistBuilder
from poetry.masonry.utils.module import ModuleOrPackageNotFound
from poetry.utils._compat import decode
from poetry.utils.env import NullEnv
......@@ -58,6 +59,14 @@ exist it will look for <comment>pyproject.toml</> and do the same.
if return_code != 0:
return return_code
try:
builder = SdistBuilder(self.poetry, NullEnv(), NullIO())
except ModuleOrPackageNotFound:
# This is likely due to the fact that the project is an application
# not following the structure expected by Poetry
# If this is a true error it will be picked up later by build anyway.
return 0
self.line(
" - Installing <info>{}</info> (<comment>{}</comment>)".format(
self.poetry.package.pretty_name, self.poetry.package.pretty_version
......@@ -73,8 +82,6 @@ exist it will look for <comment>pyproject.toml</> and do the same.
if has_setup:
self.line("<warning>A setup.py file already exists. Using it.</warning>")
else:
builder = SdistBuilder(self.poetry, NullEnv(), NullIO())
with setup.open("w", encoding="utf-8") as f:
f.write(decode(builder.build_setup()))
......
......@@ -5,6 +5,11 @@ from .include import Include
from .package_include import PackageInclude
class ModuleOrPackageNotFound(ValueError):
pass
class Module:
def __init__(self, name, directory=".", packages=None, includes=None):
self._name = module_name(name)
......@@ -48,7 +53,9 @@ class Module:
}
]
else:
raise ValueError("No file/folder found for package {}".format(name))
raise ModuleOrPackageNotFound(
"No file/folder found for package {}".format(name)
)
for package in packages:
self._includes.append(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment