Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot pip install editable #975

Closed
LecrisUT opened this issue Mar 13, 2024 · 10 comments
Closed

Cannot pip install editable #975

LecrisUT opened this issue Mar 13, 2024 · 10 comments
Labels
bug Something isn't working

Comments

@LecrisUT
Copy link
Contributor

LecrisUT commented Mar 13, 2024

I am trying to get a simple editable install for tinkering with this project, but I can't seem to make it editably install the mystmd-py python project:

$ pip install -e /path/to/mystmd/packages/mystmd-py
...
      OSError: Error getting the version from source `nodejs`: file does not exist: _package.json
      [end of output]

It seems that it would not work because even in the release workflow there are manual steps:

      - name: Build Python package
        run: |
          pip install build
          # Copy over needed files
          cp ../mystmd/dist/myst.cjs src/mystmd_py/
          cp ../mystmd/package.json _package.json
          python -m build
        working-directory: packages/mystmd-py

Probably this is covered by

$ npm install
$ npm run build
$ npm run dev

But I am not quire sure if that does the same thing. After running the npm run dev, can I edit in place the typescript files and then those are available to the ~/.local/bin/myst executable?

@LecrisUT LecrisUT added the bug Something isn't working label Mar 13, 2024
@agoose77
Copy link
Contributor

To see the effect of modifications to the underlying TypeScript sources of MyST-MD requires a compilation step, regardless of whether you're deploying the application as a Python package.

In your case, if you just want to reduce the build loop, I don't think we implement a watch target for all of our subpackages yet. I'll look into this, certainly. But, in the mean time, you probably need to run the appropriate build commands by hand. Running npm run build in the root directory is guaranteed to build everything that you need, but it might be slow if you're only tweaking a few places. Alternatively, you can manually build only the packages that have changed and the packages that depend upon them, e.g. for directives and using the CLI packages/myst-directives, packages/myst-cli, packages/mystmd.

To actually use the rebuilt myst application, running the dev script will ensure that it's linked into your local path. You can also just use npx if you're in an environment that doesn't like this kind of hack, e.g. NixOS: npx myst ....

@LecrisUT
Copy link
Contributor Author

Ok, it seems I can get an environment after running npm run dev and then running npm run build after I tinker with the ts files. Now I'm off to try my luck with #974

@LecrisUT
Copy link
Contributor Author

LecrisUT commented Mar 13, 2024

So far I am puzzled, and I'm not sure if it's due to the environment. I tried to edit:

function mathBlockAsOriginal(node: GenericNode, state: ITexParser) {
  state.closeParagraph();
+  console.error(`state=${state}\nnode=${node}`);
+  assert(false);
  const original = originalValue(state.tex, node);
  const value = original?.replace(/(^(\$\$)|(\\\[))|((\$\$)|(\\\])$)/g, '').trim();
  state.pushNode(u('math', { value }));
}

But I did not see any effects on the cli runner. Doing something similar to mystmd/src/index.ts seems to have effects so I am not sure if it's one or the other.

@rowanc1
Copy link
Collaborator

rowanc1 commented Mar 13, 2024

Can you make sure that the python install isn't taking precedence over the npm linked one? For example, which myst. That can sometimes happen if your python paths are after your node ones in your shell.

@agoose77
Copy link
Contributor

@LecrisUT to be clear, you need to build multiple packages if you're testing using the CLI, usually at least:

  • packages/myst-cli
  • packages/mystmd

followed by the actual package you're editing. You'd need to build them in the correct order too. If you just run npm run build in the root (top-level) checkout directory, turbo will ensure everything's built properly.

@LecrisUT
Copy link
Contributor Author

Can you make sure that the python install isn't taking precedence over the npm linked one? For example, which myst. That can sometimes happen if your python paths are after your node ones in your shell.

Yep, I have completely pip uninstall mystmd

If you just run npm run build in the root (top-level) checkout directory, turbo will ensure everything's built properly.

Indeed I am running it like that, which is why I am puzzled that the other assert is not trigerred

@agoose77
Copy link
Contributor

Did your build succeed? If there are errors, the old application might be persisting on disk.

@rowanc1
Copy link
Collaborator

rowanc1 commented Mar 13, 2024

Ah - that function looks like it is in tex-to-myst not myst-to-tex!

Can you try putting a console log/error here:
https://github.com/executablebooks/mystjs/blob/main/packages/myst-to-tex/src/math.ts#L50

@LecrisUT
Copy link
Contributor Author

Did your build succeed? If there are errors, the old application might be persisting on disk.

Yep, it was successful

Ah - that function looks like it is in tex-to-myst not myst-to-tex!

Can you try putting a console log/error here:
https://github.com/executablebooks/mystjs/blob/main/packages/myst-to-tex/src/math.ts#L50

Aaah, that explains it. Indeed I was looking at the wrong package. That solves the issue, thanks for the assist

@rowanc1
Copy link
Collaborator

rowanc1 commented Mar 13, 2024

Glad you are up and running! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants