Browse Source

update dev-install plugin: it now correctly references the directory name for installing with Pip rather than the package or module name

master
Niklas Rosenstein 1 year ago
parent
commit
e0c655dfb3
Signed by: NiklasRosenstein GPG Key ID: 06D269B33D25F6C6
1 changed files with 16 additions and 7 deletions
  1. + 16
    - 7
      src/shore/plugins/dev_install.py

+ 16
- 7
src/shore/plugins/dev_install.py

@ -22,7 +22,7 @@
from pkg_resources import resource_string
from shore import __version__
from shore.core.plugins import FileToRender, IMonorepoPlugin
from shore.model import Monorepo
from shore.model import Monorepo, Package
from nr.algo.graph.toposort import toposort
from nr.databind.core import Field, Struct
from nr.interface import implements, override
@ -31,6 +31,10 @@ import json
import os
def _dirname(package: Package):
return os.path.basename(package.directory)
@implements(IMonorepoPlugin)
class DevInstallRenderer:
""" Renders a "bin/dev-install" shell script for a monorepo that installs
@ -64,23 +68,28 @@ class DevInstallRenderer:
def _get_interpackage_dependencies(self, monorepo: Monorepo) -> Dict[str, Dict]:
nodes = {}
package_name_mapping = {}
packages = list(monorepo.get_packages())
for package in packages:
nodes[package.name] = {
package_name_mapping[package.name] = _dirname(package)
nodes[_dirname(package)] = {
'directory': os.path.basename(package.directory),
'requires': [],
'extra_requires': {}
}
print(package_name_mapping)
def _flatten_reqs(dst, reqs):
for req in reqs.required if reqs else ():
if req.package in nodes:
dst.append(req.package)
if req.package in package_name_mapping:
dst.append(package_name_mapping[req.package])
for package in packages:
_flatten_reqs(nodes[package.name]['requires'], package.requirements)
_flatten_reqs(nodes[package.name].setdefault('test', []), package.requirements.test)
_flatten_reqs(nodes[_dirname(package)]['requires'], package.requirements)
_flatten_reqs(nodes[_dirname(package)].setdefault('test', []), package.requirements.test)
for extra, reqs in package.requirements.extra.items():
_flatten_reqs(nodes[package.name].setdefault(extra, []), reqs)
_flatten_reqs(nodes[_dirname(package)].setdefault(extra, []), reqs)
return nodes

Loading…
Cancel
Save