question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using `--from` w/ file or remote repository format fails when the source descends from PythonProject.

See original GitHub issue

Assuming we have a simple project defined locally as follows (that descends from JSIIProject):

in templates/src/index.ts:

export class MyProject extends python.PythonProject {                                                                                                                                                                                                                                                                                                                
  constructor(options: python.PythonProjectOptions) {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
    super(options);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
  }                                                                                                                                                                                                                                                                                                                                                                       
}   

After building the project and compiling the JSII, when I try to use the template from another project directory, such as new_project:

projen new --from file:../templates

I get the following error:

Error: Cannot find module 'templates/.jsii'

If you try the same using a remote repository, you will get:

Error: Cannot find module 'git/.jsii'

I looked into the code, and it looks like this is erroring at this point:

https://github.com/projen/projen/blob/9f4a6ffa9ab90400fbbecdda7d993290b391ebb2/src/cli/cmds/new.ts#L211-L213

Installing from an NPM or private NPM server still works.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
zmullycommented, Sep 14, 2022

@orlandronen1 thanks for the tip, renaming the tarball did work

works:

  • npx projen new zaiPython --packageManager npm --from /home/zmully/gitwork/python-test-2/dist/js/python-test-2.tgz

does not work:

  • npx projen new zaiPython --packageManager npm --from python-test-2@/home/zmully/gitwork/python-test-2/dist/js/python-test-2.tgz
  • npx projen new zaiPython --packageManager npm --from "python-test-2@/home/zmully/gitwork/python-test-2/dist/js/python-test-2.tgz"
  • npx projen new zaiPython --packageManager npm --from "python-test-2@/home/zmully/gitwork/python-test-2/dist/js/python-test-2@0.0.0.jsii.tgz"

And like you said, pulling from a registry solves many of these issues, but it’d be great if that friction could be removed to speed up development.

1reaction
zmullycommented, Sep 6, 2022
zmully@ubu2 /tmp/tmp.LjeUntIV5c $ npm -v
8.15.0

@mrgrain still not working with the package name addition:

zmully@ubu2 /tmp/tmp.WsRcs7o6OH $ cd $(mktemp -d) && npx projen new zaiPython --packageManager npm --from python-test-2@/home/zmully/gitwork/python-test-2/dist/js/python-test-2@0.0.0.jsii.tgz 
/tmp/tmp.LjeUntIV5c
└── (empty)


added 1 package, and audited 68 packages in 1s

7 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
👾 installing external module python-test-2@/home/zmully/gitwork/python-test-2/dist/js/python-test-2@0.0.0.jsii.tgz...

added 1 package, and audited 69 packages in 385ms

7 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
👾 Project definition file was created at /tmp/tmp.LjeUntIV5c/.projenrc.py
/tmp/tmp.LjeUntIV5c/node_modules/projen/node_modules/semver/classes/comparator.js:38
      throw new TypeError(`Invalid comparator: ${comp}`)
      ^

TypeError: Invalid comparator: /home/zmully/gitwork/python-test-2/dist/js/python-test-2@0.0.0.jsii.tgz
    at Comparator.parse (/tmp/tmp.LjeUntIV5c/node_modules/projen/node_modules/semver/classes/comparator.js:38:13)
    at new Comparator (/tmp/tmp.LjeUntIV5c/node_modules/projen/node_modules/semver/classes/comparator.js:22:10)
    at /tmp/tmp.LjeUntIV5c/node_modules/projen/node_modules/semver/classes/range.js:133:47
    at Array.map (<anonymous>)
    at Range.parseRange (/tmp/tmp.LjeUntIV5c/node_modules/projen/node_modules/semver/classes/range.js:133:35)
    at /tmp/tmp.LjeUntIV5c/node_modules/projen/node_modules/semver/classes/range.js:34:22
    at Array.map (<anonymous>)
    at new Range (/tmp/tmp.LjeUntIV5c/node_modules/projen/node_modules/semver/classes/range.js:34:8)
    at Object.toPythonVersionRange (/tmp/tmp.LjeUntIV5c/node_modules/projen/lib/util/semver.js:51:19)
    at RequirementsFile.formatDependency (/tmp/tmp.LjeUntIV5c/node_modules/projen/lib/python/requirements-file.js:45:43)
Read more comments on GitHub >

github_iconTop Results From Across the Web

git: fatal: Could not read from remote repository - Stack Overflow
First please look at .git/config file and see everything is in order. It had wrong set-url and origin values for me. – mixdev....
Read more >
Troubleshooting cloning errors - GitHub Docs
In this article. HTTPS cloning errors. Error: Repository not found. Error: Remote HEAD refers to nonexistent ref, unable to checkout.
Read more >
Work with notebooks and other files in Databricks Repos
Learn how to work with notebooks and other files in Databricks Repos integrated with a remote Git repository.
Read more >
Introduction to Git and GitHub for Python Developers
In this tutorial, I'll walk you through what Git is, how to use it for your personal projects, and how to use it...
Read more >
Create Your Custom, private Python Package That You Can ...
Share your self-built Python package using your git repo. ... They send us a data file with a specific question like, “What type...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found